Segmentation fault when a Ruby method is invoked by a C method via Object#send
A crash bug in mruby: aliasing Object#send over initialize lets a C function (Class#new) invoke a Ruby method through send with arbitrary arguments, and doing so causes a segmentation fault. An attacker who can run Ruby code on the interpreter could crash the process.
- Triaged in 2 days
- Fixed in 4 months
- Paid in 4 months
- Disclosed after 5 months
We can arrange for C to call Object#send by aliasing it over initialize. This will cause Class#new (a C function) to call #initialize (which is actually Object#send) with arbitrary arguments.
If we invoke a Ruby method through Object#send, mruby segfaults:
def foo
end
class X
alias_method :initialize, :send
end
X.new.send(:foo)
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 does not correctly handle Object#send being invoked as the initialiser from C code, leading to invalid memory access.
Impact
Invoking a Ruby method through Object#send in this arrangement crashes the interpreter with a segmentation fault.
What the attacker needed
Ability to run Ruby code in mruby
How it was found
- Define a Ruby method to call.
- Reopen a class and alias send over initialize.
- Create a new instance of that class and call send on it with the method name.
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. A segmentation fault is a crash where the program tries to use memory it is not allowed to touch, so the whole process dies. Here, a particular way of calling a method makes the interpreter crash instead of running normally.
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.