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.
- 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.
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
- Create a Decimal object and keep a reference to it.
- Reassign the Decimal constant to a different class.
- Apply unary minus to the saved object.
- 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.