-
Notifications
You must be signed in to change notification settings - Fork 33
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
A vulnerability in ObjectID() #30
Comments
I follow what you're saying. MongoDB might reject it though...? Have you tried inserting a malformed one? The |
Ideally, it'd be best if Mongo would break ObjectID in to it's own module! Perhaps after all these years, they'll reconsider now that this module has gained > 30,000 weekly downloads & 237 public NPM defendants (2100 uses according to Github)! :) |
Thanks for the quick response. |
Hi, i noticed that this issue has a CVE now (CVE-2019-19729), any plans on removing |
From what I've found so far- The payload needs to have an
When it is converted to BSON, the BSON serializer looks at the Therefor, the risk of this being persisted to a MongoDB seems really low. BUT, that's only for MongoDB.
I can remove I've likely missed a point of view- so I wanted to throw this out there first. Thoughts? |
Thanks for disclosing the potential risk of this issue. |
Indeed! Maybe could use |
Sound good! |
Can anyone submit a PR for this? |
Closing until PR submitted. |
🛠️ A fix has been provided for this issue. Please reference: 418sec#2 🔥 This fix has been provided through the https://huntr.dev/ bug bounty platform. |
We found that ObjectID() allows an attacker to generate a malformed objectid by inserting an additional property to his user-input.
The vulnerable code is as follows: bson-objectid will return early if it detects _bsontype == ObjectID in user-input object. As a result, objects in arbitrary forms can bypass formatting if they have a valid bsontype.
https://github.com/williamkapke/bson-objectid/blob/eaaf20d828974c1a2b8e07b522b1ebdc86672f41/objectid.js#L29-L32
Unlike bson-objectid, the official implementation (shown in the following code) enforces a stricter early return condition, i.e., only if the constructor of the user-input object is ObjectID.
https://github.com/mongodb/js-bson/blob/cea186763527e4d3749a8234d335e9c395effe5b/lib/objectid.js#L59-L61
Reproduce script
The text was updated successfully, but these errors were encountered: