Null target_class DoS
The `instance_exec` method in mruby sets the VM's `target_class` pointer to the singleton class of the receiver, but if the singleton class cannot be created, it sets it to NULL. The `OP_CLASS` and `OP_MODULE` opcodes then dereference this NULL pointer when defining a class or module, causing a segfault and denial of service.
- Triaged in under an hour
- Fixed in under an hour
- Paid in 28 days
- Disclosed after 28 days
The Object#instance_exec method in mrbgems/mruby-object-ext/src/object.c executes a block in the context of an object. It sets the VM's target_class pointer to the singleton class of this object. target_class is used as the definition target for constants and methods.
If a singleton class cannot be created for an object, target_class is set to NULL. The OP_CLASS and OP_MODULE opcodes in the VM assume target_class is not null when defining new classes and modules.
This causes a null pointer dereference and segfaults the mruby VM.
Sample code:
1.instance_exec { class X; end }
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 does not check whether `target_class` is NULL before using it in the `OP_CLASS` and `OP_MODULE` opcodes.
Impact
An attacker could crash the mruby VM, leading to a denial of service.
What the attacker needed
Ability to run mruby code
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 that runs Ruby code (mruby) has a bug: when you run a block with `instance_exec` on an object that cannot have its own class, the program sets an internal pointer to nothing (NULL). Later, when the block tries to define a new class, the program tries to use that nothing pointer, which crashes the whole program. This means an attacker can crash the program by running a short piece of code.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.