updated Crack::JSON.parse to actually use SafeYAML #50
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.
I hate to say this, but it looks like crack was never actually using SafeYAML (despite having it as a dependency)?
It was actually pretty tricky to even find a scenario where this mattered! For one, crack automatically adds a space after the ":" character; so injecting symbols wasn't possible.
It also does this magical replacement of "/" with "!ruby/regexp /"; so arbitrary object serialization using, e.g., "!ruby/object:Foo" would get all mangled.
I did find this, though: a malicious attacker could bypass both of these by making crack think it's in the middle of a quoted string. The trick is to put an opening quote in a YAML comment: crack then ignores subsequent "/" and ":" characters; meanwhile, YAML ignores the first line.
You can see that without the change to
require 'safe_yaml'
, the test I added actually deserializes aFoo
object.