# CVE-2022-22980: SpEL Injection in Spring Data MongoDB

> Attackers can execute arbitrary code via SpEL injection in Spring Data MongoDB query methods if input is not sanitized.

- **Severity:** Critical 9.8 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 22 Jun 2022
- **Updated:** 3 Aug 2024
- **Also known as:** GHSA-w24x-87mr-4r23

## What is CVE-2022-22980?

CVE-2022-22980 is a critical code injection vulnerability in Spring Data MongoDB, published on 22 Jun 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

A Spring Data MongoDB application is vulnerable to SpEL Injection when using @Query or @Aggregation-annotated query methods with SpEL expressions that contain query parameter placeholders for value binding if the input is not sanitized.

Weakness: CWE-917 (Improper Neutralization of Special Elements used in an Expression Language Statement)

## Which versions are affected by CVE-2022-22980?

4 open source packages ship an affected version, including org.springframework.data:spring-data-mongodb. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.springframework.data:spring-data-mongodb` | Maven | All versions | 3.3.5 |
| `org.springframework.data:spring-data-mongodb` | Maven | All versions | 3.3.5 |
| `org.springframework.data:spring-data-mongodb` | Maven | From 3.4.0 | 3.4.1 |
| `org.springframework.data:spring-data-mongodb` | Maven | From 3.4.0 | 3.4.1 |

Products: Vmware Spring Data Mongodb.

## How do I fix CVE-2022-22980?

Upgrade org.springframework.data:spring-data-mongodb to a fixed version for your release line: 3.3.5 or 3.4.1.

## Is CVE-2022-22980 being exploited?

There is no known exploitation of CVE-2022-22980 in the wild and no public exploit code.

Public exploit code:

- Poc of CVE-2022-22980 (github_poc): https://github.com/trganda/CVE-2022-22980
- CVE-2022-22980环境 (github_poc): https://github.com/kuron3k0/Spring-Data-Mongodb-Example
- CVE-2022-22980环境 (github_poc): https://github.com/li8u99/Spring-Data-Mongodb-Demo
- CVE-2022-22980 exp && 靶场 (github_poc): https://github.com/jweny/cve-2022-22980
- spring data mongodb remote code execution | cve-2022-22980 poc (github_poc): https://github.com/Vulnmachines/Spring_cve-2022-22980
- [CVE-2022-22980] Spring Data MongoDB SpEL Expression Injection (github_poc): https://github.com/murataydemir/CVE-2022-22980

## Other vulnerabilities in Spring Data MongoDB

- [CVE-2026-41717](https://insights.sbomify.com/CVE-2026-41717/): Spring Data MongoDB - SpEL Expression Injection via Annotated Query Parameter Binding (high 8.1)
- [CVE-2026-41696](https://insights.sbomify.com/CVE-2026-41696/): Spring Data MongoDB Bind Parameter Literal Quoting Breakout (medium 5.9)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-22980 and fix it if it is affected.

What it is: CVE-2022-22980 is a critical code injection vulnerability in Spring Data MongoDB, published on 22 Jun 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2022-22980 in the wild and no public exploit code.

Affected packages and fixed versions:
- org.springframework.data:spring-data-mongodb (Maven): affected all versions; fixed in 3.3.5
- org.springframework.data:spring-data-mongodb (Maven): affected all versions; fixed in 3.3.5
- org.springframework.data:spring-data-mongodb (Maven): affected from 3.4.0; fixed in 3.4.1
- org.springframework.data:spring-data-mongodb (Maven): affected from 3.4.0; fixed in 3.4.1

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/CVE-2022-22980/ (Markdown: https://insights.sbomify.com/CVE-2022-22980/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-22980
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-22980
- OSV: https://osv.dev/vulnerability/CVE-2022-22980

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-22980/
Summaries are generated and may contain mistakes; the official description above is the record.
