Don't replace regex / function placeholders within string literals#79
Merged
okuryu merged 2 commits intoyahoo:masterfrom May 20, 2020
Merged
Don't replace regex / function placeholders within string literals#79okuryu merged 2 commits intoyahoo:masterfrom
okuryu merged 2 commits intoyahoo:masterfrom
Conversation
Previously we weren't checking if the quote that started the placeholder
was escaped or not, meaning an object like
{"foo": /1"/, "bar": "a\"@__R-<UID>-0__@"}
Would be serialized as
{"foo": /1"/, "bar": "a\/1"/}
meaning an attacker could escape out of `bar` if they controlled both
`foo` and `bar` and were able to guess the value of `<UID>`.
UID was generated once on startup, was chosen using `Math.random()` and
had a keyspace of roughly 4 billion, so within the realm of an online
attack.
Here's a simple example that will cause `console.log()` to be called when
the `serialize()`d version is `eval()`d
eval('('+ serialize({"foo": /1" + console.log(1)/i, "bar": '"@__R-<UID>-0__@'}) + ')');
Where `<UID>` is the guessed `UID`.
This fixes the issue by ensuring that placeholders are not preceded by
a backslash.
We also switch to a higher entropy `UID` to prevent people from guessing it.
credits JordanMilne (https://github.com/JordanMilne)
okuryu
reviewed
Apr 6, 2020
okuryu
approved these changes
May 20, 2020
Collaborator
okuryu
left a comment
There was a problem hiding this comment.
Sorry for delay. I would like to try to merge this in. I will be working on a release that includes this as soon as possible. Thank you for your patience.
Collaborator
|
Published |
This was referenced Mar 8, 2021
This was referenced Mar 16, 2021
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.
credits JordanMilne (https://github.com/JordanMilne) #22
I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.
Based on Jordan's comment here I believe he gave approval and I approve any merging I did :)
#22 (comment)