Skip to content
Memory corruption Disclosed report Advanced

Type confusion in wrap_decimal leading to memory corruption

The Decimal constant could be reassigned to a different class, so the internal wrap_decimal routine looked up the wrong class and produced an invalid object. This led to a native crash and the reporter suspected it could be turned into arbitrary code execution.

raydot Follow

Originally disclosed on HackerOne

Critical View original
  • Triaged in 8 hours
  • Fixed in 12 hours
  • Paid in 21 days
  • Disclosed after 51 days

Decimal can be redefined, causing the Decimal class lookup in wrap_decimal to be invalid. This can lead to memory corruption or arbitrary code execution.

The following snippet results in a native crash in mruby-engine olddecimal = Decimal.new(1) Decimal = Hash a = -olddecimal puts a

I suspect you caught this along with charliesome's similar bug for Struct. If not I'll follow up with a patch and an RCE exploit.

The original report as published on HackerOne, by raydot. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the code resolved the Decimal class by name at runtime instead of holding a stable reference, so reassigning the constant made the unary minus operation wrap the value with the wrong class.

Impact

The snippet caused a native crash, and the reporter believed it could potentially lead to arbitrary code execution.

What the attacker needed

Ability to reassign the Decimal constant

How it was found

  1. Create a Decimal object and keep a reference to it.
  2. Reassign the Decimal constant to a different class.
  3. Apply unary minus to the saved object.
  4. Observe the native crash.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A program keeps a reference to a class called Decimal and later assumes that name still points to the same class. If someone reassigns that name to something else, the program uses the wrong kind of object and can crash. The reporter thought a skilled attacker might go further and run their own code.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by raydot

View all

4 more disclosed reports, best first.

More from shopify-scripts

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.