Fixes and updates for the DRuby RCE module #14300
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By far the most important change this PR makes is in commit 49145bf. This fixes a security issue whereby a user who has run the
exploit/linux/misc/drb_remote_codeexec
is vulnerable to it themselves. This was issue was privately reported to the Metasploit project through our vulnerability disclosure process. All credit to Jeff Dileo of NCC Group for reporting this vulnerability.While testing this vulnerability I found that we could simply remove the affected service in question. Prior to this patch, a new instance of the service would be started each time the module was executed. Only one DRuby service instance is necessary to be vulnerable but either way this is a leak that should be addressed. After removing the service I tested each of the targets to ensure that none were dependent on it which led me to issues with the syscall target. The explicit delay between the fork and exec was enough to fix this for me. With this in place the default/instance_eval target and syscall targets are working for me. The trap target did not work for me before or after this patch, so that's still an outstanding issue from what I can tell.
I also added a check method. This can be used to check for vulnerable instances of DRuby services, both from Metasploit and otherwise.
Verification
List the steps needed to make sure this thing works
ruby client.rb
), use the PID it prints out to find TCP ports that it's listening on. There should be a high port that's used for the DRuby service. Note this port down, it'll be used for the rest of testing. Don't hit enter so it stays running.msfconsole
irb -e "puts 'msfconsole pid: ' + Process.pid.to_s"
msfconsole
irb -e "puts 'msfconsole pid: ' + Process.pid.to_s"
Example
In the following example, the address of the machine running Metasploit is 192.168.159.128
Resources
The following two scripts helped me through this process. The originals came from the Ruby 2.7.1 Documentation.
DRuby Client
DRuby Server