Skip to content
DoS Disclosed report Intermediate

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.

h72 Follow

Originally disclosed on HackerOne

Bounty$8,000 High View original
  • 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 }

The original report as published on HackerOne, by h72. 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 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.

More by h72

View all

6 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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.