GHSA-m734-r4g6-34f9 NoSQL Injection in loopback-connector-mongodb

Not scored Published

Attackers can execute arbitrary JavaScript on the database via NoSQL injection in the LoopBack MongoDB connector, leading to code execution or denial of service.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is GHSA-m734-r4g6-34f9?

GHSA-m734-r4g6-34f9 is a code injection vulnerability in loopback-connector-mongodb, published on 4 Jun 2019. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

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.

Which versions are affected by GHSA-m734-r4g6-34f9?

2 open source packages ship an affected version, including loopback-connector-mongodb.

PackageAffectedFixed in
loopback-connector-mongodb npmAll versions3.6.0
loopback-connector-mongodb npmAll versions3.6.0

How do I fix GHSA-m734-r4g6-34f9?

Upgrade loopback-connector-mongodb to 3.6.0 or later.

Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.

Is GHSA-m734-r4g6-34f9 being exploited?

There is no known exploitation of GHSA-m734-r4g6-34f9 in the wild and no public exploit code.

Sources

Is GHSA-m734-r4g6-34f9 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free