Skip to content
DoS Disclosed report Advanced

Null pointer dereference due to TOCTTOU bug in mrb_time_initialize

In mruby, the Time initialiser cleared its internal data pointer before parsing arguments, and argument parsing can run Ruby code for type coercion. A crafted object whose coercion method touches the same Time object therefore caused a native null pointer dereference and crash.

raydot Follow

Originally disclosed on HackerOne

  • Triaged in 2 hours
  • Fixed in 3 days
  • Paid in 31 days
  • Disclosed after 2 months

mrb_time_initialize sets the data pointer to NULL before parsing function arguments. Parsing function arguments can call out to ruby code to call methods to do type coercion. If the type coercion method tries to access the time object it will dereference a NULL pointer.

The following snippet results in a native crash under mruby-engine:

$x = Time.new
class Tmp
    def to_i
        $x.mday
    end
end
$x.initialize Tmp.new

Attached is a patch to mruby to fix this issue.

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 initialiser nulls the object's data pointer before argument parsing, and argument parsing can re-enter user code that dereferences the still-null pointer.

Impact

An attacker who can supply an object to a Time initialiser could crash the interpreter process, a denial of service.

What the attacker needed

Ability to run Ruby code in mruby

The fix

The initialiser should not clear the data pointer until argument parsing has finished, or should guard against re-entry; the text says a patch was attached but does not state it was merged.

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 time object in this Ruby implementation stores its data in a slot that is emptied at the start of initialisation. While the arguments are being converted to numbers, user code can run and look at that same object, which is still empty, so the program crashes. This is a timing problem: the object is used before it is ready.

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

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.