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

Don't replace regex / function placeholders within string literals #79

Merged
merged 2 commits into from
May 20, 2020

Conversation

Siebes
Copy link
Contributor

@Siebes Siebes commented Apr 1, 2020

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)

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)
package-lock.json Outdated Show resolved Hide resolved
@Siebes Siebes requested a review from okuryu April 9, 2020 00:22
Copy link
Collaborator

@okuryu okuryu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@okuryu okuryu merged commit f21a6fb into yahoo:master May 20, 2020
@okuryu
Copy link
Collaborator

okuryu commented May 28, 2020

Published [email protected] today. Thanks!

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.

3 participants