Updated ruby gadget for marshal loading#1
Merged
Conversation
p-
requested changes
Oct 17, 2024
Contributor
There was a problem hiding this comment.
Hey @leonardo-doyensec 👋
Sounds great!
I've added some minor nitpicks. (comment out calls of marshal.load)
Thanks!
Contributor
Author
|
Hello @p-, i've added the changes that you have requested |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hello @p- , my name is Leonardo, I'm an Application Security Engineer @ Doyensec.
In the previous weeks I've doing some research around ruby deserialization, and I've noticed that the Marshal gadget was not working anymore on the latest ruby version. So I've adapted it.
Essentially the major change is that the kick-off gadget (
Gem::Specification) is now callingsafe_loadmaking impossible to continue the exploit chain.Since the rest of the exploit is untouched, I've been searching for a similar gadget that called
to_sonce deserialized. I've found it inGem::Version.The only problem with it is that it will throw an exception after the folder creation (which is the first stage of the exploit). Hence two separate loads are required.
Another problem arising is that the
URImodule is not present anymore in ruby as default. Hence, we need to importnet/http. I think this is a fair assumption since with this exploit we will target mostly web applications (whether rails or sinatra) that will import this module.Contacts:
Twitter
Doyensec