# CVE-2021-34371: Deserialization of Untrusted Data in Neo4j

> Attackers can achieve remote code execution via unsafe Java deserialization in the Neo4j RMI service when the shell server is enabled.

- **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:** 5 Aug 2021
- **Updated:** 4 Aug 2024
- **Also known as:** BIT-neo4j-2021-34371, BIT-neo4j-enterprise-2021-34371, GHSA-pc4w-8v5j-29w9

## What is CVE-2021-34371?

CVE-2021-34371 is a critical unsafe deserialization vulnerability in n/a, published on 5 Aug 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Neo4j through 3.4.18 (with the shell server enabled) exposes an RMI service that arbitrarily deserializes Java objects, e.g., through setSessionVariable. An attacker can abuse this for remote code execution because there are dependencies with exploitable gadget chains.

Weakness: CWE-502 (Deserialization of Untrusted Data)

## Which versions are affected by CVE-2021-34371?

4 open source packages ship an affected version, including org.neo4j:neo4j, neo4j and neo4j-enterprise. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.neo4j:neo4j` | Maven | All versions | 3.5.0 |
| `org.neo4j:neo4j` | Maven | All versions | 3.5.0 |
| `neo4j` | Bitnami | All versions | 3.4.19 |
| `neo4j-enterprise` | Bitnami | All versions to 3.4.18 | None |

Products: Neo4j Neo4j.

## How do I fix CVE-2021-34371?

Upgrade org.neo4j:neo4j to 3.5.0 or later.

## Is CVE-2021-34371 being exploited?

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

Public exploit code:

- CVE-2021-34371.jar (github_poc): https://github.com/zwjjustdoit/CVE-2021-34371.jar
- python exploit - Neo4j 3.4.18 - RMI based Remote Code Execution (RCE) (github_poc): https://github.com/tavgar/CVE-2021-34371

## Other vulnerabilities in n/a

- [CVE-2018-18389](https://insights.sbomify.com/CVE-2018-18389/): Incorrect access control in Neo4j Enterprise Database Server via LDAP authentication (critical 9.8)
- [CVE-2013-7259](https://insights.sbomify.com/CVE-2013-7259/): Neo4J vulnerable to Cross-Site Request Forgery (medium 6.8)
- [CVE-2024-34517](https://insights.sbomify.com/CVE-2024-34517/): Neo4j Cypher component mishandles IMMUTABLE privileges (medium 6.5)
- [CVE-2026-14587](https://insights.sbomify.com/CVE-2026-14587/): Unathenticated connection can hold Bolt channel open (medium 5.5)
- [CVE-2026-1471](https://insights.sbomify.com/CVE-2026-1471/): Caching of authentication context (low 2.1)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-34371 and fix it if it is affected.

What it is: CVE-2021-34371 is a critical unsafe deserialization vulnerability in n/a, published on 5 Aug 2021. 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-2021-34371 in the wild and no public exploit code.

Affected packages and fixed versions:
- org.neo4j:neo4j (Maven): affected all versions; fixed in 3.5.0
- org.neo4j:neo4j (Maven): affected all versions; fixed in 3.5.0
- neo4j (Bitnami): affected all versions; fixed in 3.4.19
- neo4j-enterprise (Bitnami): affected all versions up to 3.4.18; no fix listed

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

## Sources

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

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