Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated Crack::JSON.parse to actually use SafeYAML #50

Merged
merged 2 commits into from Jan 24, 2014

Conversation

dtao
Copy link
Contributor

@dtao dtao commented Jan 23, 2014

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 a Foo object.

jnunemaker pushed a commit that referenced this pull request Jan 24, 2014
updated Crack::JSON.parse to actually use SafeYAML
@jnunemaker jnunemaker merged commit 762dd6c into jnunemaker:master Jan 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants