DRb denial of service vulnerability
The DRb server in Ruby's standard library crashes when it receives malformed input over TCP, because it passes an attacker-controlled reference to ObjectSpace._id2ref. An attacker who can send data to the DRb port can therefore take the server down.
- Disclosed after 9 months
It is possible to crash the DRb server by providing malformed input.
By following DRb example (https://ruby-doc.org/stdlib-2.7.0/libdoc/drb/rdoc/DRb.html#module-DRb-label-Server+code) it was created the simple server and client code (attached):
drb_server.rbdrb_client.rb(client code was modified to perform basic fuzzing of TCP payload)
Running both script results in crashing the drb_server.rb and producing core dump:
-- Ruby level backtrace information ----------------------------------------
/home/user/.rbenv/versions/2.7.1/lib/ruby/2.7.0/drb/drb.rb:1730:in `block in main_loop'
/home/user/.rbenv/versions/2.7.1/lib/ruby/2.7.0/drb/drb.rb:1730:in `loop'
/home/user/.rbenv/versions/2.7.1/lib/ruby/2.7.0/drb/drb.rb:1734:in `block (2 levels) in main_loop'
/home/user/.rbenv/versions/2.7.1/lib/ruby/2.7.0/drb/drb.rb:1641:in `perform'
/home/user/.rbenv/versions/2.7.1/lib/ruby/2.7.0/drb/drb.rb:1677:in `setup_message'
/home/user/.rbenv/versions/2.7.1/lib/ruby/2.7.0/drb/drb.rb:1665:in `init_with_client'
/home/user/.rbenv/versions/2.7.1/lib/ruby/2.7.0/drb/drb.rb:931:in `recv_request'
/home/user/.rbenv/versions/2.7.1/lib/ruby/2.7.0/drb/drb.rb:620:in `recv_request'
/home/user/.rbenv/versions/2.7.1/lib/ruby/2.7.0/drb/drb.rb:1856:in `to_obj'
/home/user/.rbenv/versions/2.7.1/lib/ruby/2.7.0/drb/drb.rb:1537:in `to_obj'
/home/user/.rbenv/versions/2.7.1/lib/ruby/2.7.0/drb/drb.rb:366:in `to_obj'
/home/user/.rbenv/versions/2.7.1/lib/ruby/2.7.0/drb/drb.rb:366:in `_id2ref'
The crash occurs at https://github.com/ruby/ruby/blob/master/lib/drb/drb.rb#L366
./lib/drb/drb.rb#L366 ObjectSpace._id2ref(ref)
Impact
DoS of the DRb server is possible by injection of malicious input.
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 server passes an unvalidated client-supplied object reference to ObjectSpace._id2ref, which raises or aborts on an invalid reference instead of being handled.
Impact
An attacker able to send input to the DRb server can cause a denial of service by crashing it.
What the attacker needed
Network access to the DRb server port
How it was found
- Set up the simple DRb server and client from the Ruby documentation example.
- Modify the client to send fuzzed TCP payloads to the server.
- Run both scripts and observe the server crash with a core dump.
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.
DRb is a way for Ruby programs to call methods on objects in another Ruby process over the network. The server trusts a number sent by the client and uses it to look up an object; a bad number makes the whole server process crash. Anyone who can reach that network port can then 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.