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

[security] Prevent overriding of build-in properties by default #19

Merged
merged 3 commits into from Apr 19, 2018

Conversation

3rd-Eden
Copy link
Member

Currently, it's possible to override built-in properties of the resulting query string object if a malicious string is inserted in the query string, for example ?toString& will set the toString method of the object to the true boolean. This patch ensures that we never override built-in properties or previously set properties.

.travis.yml Outdated
- "0.8"
before_install:
- 'if [ "${TRAVIS_NODE_VERSION}" == "0.8" ]; then npm install -g npm@2.14.15; fi'
- "5"
Copy link
Member

Choose a reason for hiding this comment

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

Old and no longer supported, I'd remove it.

// methods like `toString` or __proto__ are not overriden by malicious
// querystrings.
//
if (key in result) continue;
Copy link
Member

Choose a reason for hiding this comment

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

We should be safe even without this, as all of them can be safely overridden, with the exception of __proto__ but setting it to a string has no effect.

That said I'm also ok with this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Without the key in result check, the test will fail because toString() can be overridden.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's my point, if your query string has a parameter called toString the expected behaviour is probably to find that parameter in the parsed object.

It overrides the toString inherited by Object.prototype but that another issue. I mean ideally the parsed object should not inherit from Object.prototype at all but we can't use Object.create(null) due to old browsers support.

@lpinca
Copy link
Member

lpinca commented Apr 19, 2018

This needs a major version bump.

@3rd-Eden 3rd-Eden merged commit 422eb4f into master Apr 19, 2018
@3rd-Eden 3rd-Eden deleted the secvul-1 branch April 19, 2018 13:34
Zero-1729 added a commit to Zero-1729/coin-dodge that referenced this pull request Jun 8, 2019
Updated 'querystringify' to fix [WS-2018-0588 vulnerability](unshiftio/querystringify#19)
wraith13 added a commit to wraith13/background-phi-colors-vscode that referenced this pull request Jun 9, 2019
Pejo-306 added a commit to Pejo-306/JSteroids that referenced this pull request Jun 9, 2019
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