Close Menu
AsiaTokenFundAsiaTokenFund
  • Home
  • Crypto News
    • Bitcoin
    • Altcoin
  • Web3
    • Blockchain
  • Trading
  • Regulations
    • Scams
  • Submit Article
  • Contact Us
  • Terms of Use
    • Privacy Policy
    • DMCA
What's Hot

JUST IN: UBS to Offer Bitcoin and Ethereum Trading in Major Crypto Push

January 23, 2026

Gold Hits $5000 as Bitcoin Lags, Analysts Eye 400% Rally

January 23, 2026

Algorand (ALGO) Price Jumps 2% as USDC News Sparks Fresh Demand

January 23, 2026
Facebook X (Twitter) Instagram
Facebook X (Twitter) YouTube LinkedIn
AsiaTokenFundAsiaTokenFund
ATF Capital
  • Home
  • Crypto News
    • Bitcoin
    • Altcoin
  • Web3
    • Blockchain
  • Trading
  • Regulations
    • Scams
  • Submit Article
  • Contact Us
  • Terms of Use
    • Privacy Policy
    • DMCA
AsiaTokenFundAsiaTokenFund

Github: Understanding Unsafe Deserialization Vulnerabilities in Ruby Projects

0
By Aggregated - see source on June 21, 2024 Blockchain
Share
Facebook Twitter LinkedIn Pinterest Email





Unsafe deserialization vulnerabilities in Ruby projects can enable attackers to execute arbitrary commands on remote servers by sending JSON data. According to The GitHub Blog, these vulnerabilities occur when the deserialization process allows the instantiation of arbitrary classes or class-like structures specified in the serialized data.

How Unsafe Deserialization Works

In Ruby, unsafe deserialization vulnerabilities are often exploited through libraries that support polymorphism, such as the Oj JSON serialization library. Attackers can chain multiple classes together to execute code on the system under attack. These classes, known as gadgets, are combined into a gadget chain to form a larger exploit.

For instance, when using the Oj library for deserializing JSON, a project can be vulnerable if it includes a construct like:

data = Oj.load(untrusted_json)

The Oj library, by default, supports the instantiation of classes specified in JSON, which can be disabled by using Oj.safe_load instead.

To demonstrate how this works, consider a class named SimpleClass with a hash method that executes a command:

class SimpleClass
  def initialize(cmd)
    @cmd = cmd
  end

  def hash
    system(@cmd)
  end
end

A JSON payload to instantiate this class might look like:

{
    "^o": "SimpleClass",
    "cmd": "open -a calculator"
}

Loading this JSON with Oj.load would not trigger the hash method directly, but placing the class inside a hash as the key can trigger the method:

Oj.load(json_payload)

This would execute the command specified in the @cmd member variable.

Building a Detection Gadget

To detect unsafe deserialization vulnerabilities, one can build a detection gadget chain. For example, a class like Gem::Requirement can be used, which has a hash method that calls to_s on an internal member. By creating a suitable JSON payload, one can trigger this chain to detect vulnerabilities.

The detection gadget can also be extended to a full-fledged remote code execution (RCE) chain. This involves using classes and methods that are part of Ruby or its dependencies to execute arbitrary commands.

Preventing Unsafe Deserialization

To prevent such vulnerabilities, it is crucial to use safe deserialization methods. For example, using Oj.safe_load instead of Oj.load can prevent the instantiation of arbitrary classes. Additionally, tools like CodeQL can help detect unsafe deserialization by analyzing the source code for vulnerable patterns.

For developers with access to the source code, GitHub’s code scanning with CodeQL can identify unsafe deserialization sinks. If the source code is not accessible, detection gadgets can be used to identify vulnerabilities remotely.

Understanding how unsafe deserialization works and implementing secure coding practices can help avoid these vulnerabilities. For more detailed examples and detection methodologies, refer to the original blog post by The GitHub Blog.

Image source: Shutterstock



Credit: Source link

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email

Related Posts

AAVE Price Prediction: Targets $190-195 by February 2026 Despite Current Technical Weakness

January 23, 2026

ARB Price Prediction: Targets $0.25-$0.28 Recovery by February 2026

January 23, 2026

FlashAttention-4 Hits 1,605 TFLOPS on NVIDIA Blackwell GPUs

January 22, 2026
Leave A Reply Cancel Reply

What's New Here!

JUST IN: UBS to Offer Bitcoin and Ethereum Trading in Major Crypto Push

January 23, 2026

Gold Hits $5000 as Bitcoin Lags, Analysts Eye 400% Rally

January 23, 2026

Algorand (ALGO) Price Jumps 2% as USDC News Sparks Fresh Demand

January 23, 2026

RIVER Price Pulls Back 7% After Rally as Justin Sun’s $8M Bet Triggers Volatility

January 23, 2026
AsiaTokenFund
Facebook X (Twitter) LinkedIn YouTube
  • Home
  • Crypto News
    • Bitcoin
    • Altcoin
  • Web3
    • Blockchain
  • Trading
  • Regulations
    • Scams
  • Submit Article
  • Contact Us
  • Terms of Use
    • Privacy Policy
    • DMCA
© 2026 asiatokenfund.com - All Rights Reserved!

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.