-
Notifications
You must be signed in to change notification settings - Fork 173
Enhance prototype pollution protection #288
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
Enhance prototype pollution protection #288
Conversation
…nd 'prototype' as map keys
|
This fixes a potental security issue. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #288 +/- ##
=======================================
Coverage 97.36% 97.36%
=======================================
Files 16 16
Lines 1138 1138
Branches 252 252
=======================================
Hits 1108 1108
Misses 30 30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks. Will release a new version immediatly. |
|
Awesome thank you for your attention on this. |
|
A better fix would be to just make msgpack-javascript/src/Decoder.ts Line 138 in dd2190b
state.map = { __proto__: null };Then you don't have to reject any key names. |
| const o = { | ||
| foo: "bar", | ||
| }; | ||
| // override constructor as an enumerable property | ||
| Object.defineProperty(o, "constructor", { | ||
| value: new Date(0), | ||
| enumerable: true, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same thing as
| const o = { | |
| foo: "bar", | |
| }; | |
| // override constructor as an enumerable property | |
| Object.defineProperty(o, "constructor", { | |
| value: new Date(0), | |
| enumerable: true, | |
| }); | |
| const o = { | |
| foo: "bar", | |
| constructor: new Date(0), | |
| }; |
| throws(() => { | ||
| decode(encoded); | ||
| }, DecodeError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of just testing that it fails to decode, you should've instead tested that, even in the hostile environment where you've imagined a current security issue, the library does not trigger it.
|
Alternatively, on msgpack-javascript/src/Decoder.ts Line 664 in dd2190b
you can just use |
Added constructor and prototype to the not allowed keys