GHSA-m734-r4g6-34f9

Suggest an improvement
Source
https://github.com/advisories/GHSA-m734-r4g6-34f9
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2019/06/GHSA-m734-r4g6-34f9/GHSA-m734-r4g6-34f9.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-m734-r4g6-34f9
Published
2019-06-04T19:36:17Z
Modified
2021-08-04T20:47:58Z
Summary
NoSQL Injection in loopback-connector-mongodb
Details

Versions of loopback-connector-mongodb before 3.6.0 are vulnerable to NoSQL injection.

MongoDB Connector for LoopBack fails to properly sanitize a filter passed to query the database by allowing the dangerous $where property to be passed to the MongoDB Driver. The Driver allows the special $where property in a filter to execute JavaScript (client can pass in a malicious script) on the database Driver. This is an intended feature of MongoDB unless disabled (instructions here).

A proof of concept malicious query:

GET /POST filter={"where": {"$where": "function(){sleep(5000); return this.title.contains('Hello');}"}}

The above makes the database sleep for 5 seconds and then returns all “Posts” with the title containing the word Hello.

Recommendation

Update to version 3.6.0 or later.

Database specific
{
    "cwe_ids":  [
        "CWE-89"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2019-06-04T19:35:47Z",
    "nvd_published_at":  null,
    "severity":  "HIGH"
}
References

Affected packages

npm / loopback-connector-mongodb

Package

Name
loopback-connector-mongodb
View open source insights on deps.dev
Purl
pkg:npm/loopback-connector-mongodb

Affected ranges

Type
SEMVER
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
3.6.0

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2019/06/GHSA-m734-r4g6-34f9/GHSA-m734-r4g6-34f9.json"