# CVE-2024-32971: Defect in query plan cache may cause incorrect operations to be executed in Apollo Router

> Apollo Router may execute incorrect GraphQL operations due to a cache defect, leading to unintended data access or modifications when distributed caching is enabled.

- **Severity:** Critical 9.1 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/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:** 2 May 2024
- **Updated:** 2 Aug 2024
- **Also known as:** GHSA-q9p4-hw9m-fj2v

## What is CVE-2024-32971?

CVE-2024-32971 is a critical vulnerability in apollographql router, published on 2 May 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Apollo Router is a configurable, graph router written in Rust to run a federated supergraph that uses Apollo Federation 2. The affected versions of Apollo Router contain a bug that in limited circumstances, could lead to unexpected operations being executed which can result in unintended data or effects. This only affects Router instances configured to use distributed query plan caching. The root cause of this defect is a bug in Apollo Router’s cache retrieval logic: When this defect is present and distributed query planning caching is enabled, asking the Router to execute an operation (whether it is a query, a mutation, or a subscription) may result in an unexpected variation of that operation being executed or the generation of unexpected errors. The issue stems from inadvertently executing a modified version of a previously executed operation, whose query plan is stored in the underlying cache (specifically, Redis). Depending on the type of the operation, the result may vary. For a query, results may be fetched that don’t match what was requested (e.g., rather than running `fetchUsers(type: ENTERPRISE)` the Router may run `fetchUsers(type: TRIAL)`. For a mutation, this may result in incorrect mutations being sent to underlying subgraph servers (e.g., rather than sending `deleteUser(id: 10)` to a subgraph, the Router may run `deleteUser(id: 12)`. Users who are using distributed query plan caching, are advised to either upgrade to version 1.45.1 or above or downgrade to version 1.43.2 of the Apollo Router. Apollo Router versions 1.44.0 or 1.45.0 are not recommended for use and have been withdrawn. Users unable to upgrade can disable distributed query plan caching to mitigate this issue.

Weakness: CWE-670 (Always-Incorrect Control Flow Implementation), CWE-440 (Expected Behavior Violation)

## Which versions are affected by CVE-2024-32971?

2 open source packages ship an affected version, including apollo-router.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `apollo-router` | crates.io | From 1.44.0 | 1.45.1 |
| `apollo-router` | crates.io | From 1.44.0 | 1.45.1 |

## How do I fix CVE-2024-32971?

Upgrade apollo-router to 1.45.1 or later.

## Is CVE-2024-32971 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-32971 and fix it if it is affected.

What it is: CVE-2024-32971 is a critical vulnerability in apollographql router, published on 2 May 2024. 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-2024-32971 in the wild and no public exploit code.

Affected packages and fixed versions:
- apollo-router (crates.io): affected from 1.44.0; fixed in 1.45.1
- apollo-router (crates.io): affected from 1.44.0; fixed in 1.45.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-2024-32971/ (Markdown: https://insights.sbomify.com/CVE-2024-32971/index.md)
```

## Sources

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

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