# GHSA-f5cv-xrv9-r8w7: NoSQL injection in express-cart

> Attackers can exploit NoSQL injection in login handlers to extract authentication tokens and gain unauthorized access to user or admin accounts.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 1 Sep 2020

## What is GHSA-f5cv-xrv9-r8w7?

GHSA-f5cv-xrv9-r8w7 is a SQL injection vulnerability in express-cart, published on 1 Sep 2020. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Versions of `express-cart` before 1.1.8 are vulnerable to NoSQL injection. 

The vulnerability is caused by the lack of user input sanitization in the login handlers. In both cases, the customer login and the admin login, parameters from the JSON body are sent directly into the MongoDB query which allows to insert operators. 

These operators can be used to extract the value of the field blindly in the same manner of a blind SQL injection. In this case, the `$regex` operator is used to guess each character of the token from the start.

## Recommendation

Update to version 1.1.8 or later.

## Which versions are affected by GHSA-f5cv-xrv9-r8w7?

2 open source packages ship an affected version, including express-cart.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `express-cart` | npm | All versions | 1.1.8 |
| `express-cart` | npm | All versions | 1.1.8 |

## How do I fix GHSA-f5cv-xrv9-r8w7?

Upgrade express-cart to 1.1.8 or later.

## Is GHSA-f5cv-xrv9-r8w7 being exploited?

There is no known exploitation of GHSA-f5cv-xrv9-r8w7 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-f5cv-xrv9-r8w7 and fix it if it is affected.

What it is: GHSA-f5cv-xrv9-r8w7 is a SQL injection vulnerability in express-cart, published on 1 Sep 2020. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-f5cv-xrv9-r8w7 in the wild and no public exploit code.

Affected packages and fixed versions:
- express-cart (npm): affected all versions; fixed in 1.1.8
- express-cart (npm): affected all versions; fixed in 1.1.8

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-f5cv-xrv9-r8w7/ (Markdown: https://insights.sbomify.com/GHSA-f5cv-xrv9-r8w7/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-f5cv-xrv9-r8w7

---
From sbomify Insights: https://insights.sbomify.com/GHSA-f5cv-xrv9-r8w7/
Summaries are generated and may contain mistakes; the official description above is the record.
