# CVE-2021-42697: Uncontrolled Recursion in Akka HTTP

> Remote attackers can cause denial of service in Akka HTTP by sending deeply nested comments in User-Agent headers, exhausting the stack.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/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 Nov 2021
- **Updated:** 4 Aug 2024
- **Also known as:** GHSA-3hw2-h67c-wq66

## What is CVE-2021-42697?

CVE-2021-42697 is a high-severity denial of service vulnerability in n/a, published on 2 Nov 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Akka HTTP 10.1.x before 10.1.15 and 10.2.x before 10.2.7 can encounter stack exhaustion while parsing HTTP headers, which allows a remote attacker to conduct a Denial of Service attack by sending a User-Agent header with deeply nested comments.

Weakness: CWE-674 (Uncontrolled Recursion)

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

18 open source packages ship an affected version, including com.typesafe.akka:akka-http-core_2.12, com.typesafe.akka:aakka-http-core_2.13.0-M3 and com.typesafe.akka:akka-http-core_2.11. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `com.typesafe.akka:akka-http-core_2.12` | Maven | From 10.1.0 | 10.1.15 |
| `com.typesafe.akka:akka-http-core_2.12` | Maven | From 10.1.0 | 10.1.15 |
| `com.typesafe.akka:akka-http-core_2.12` | Maven | From 10.2.0-M1 | 10.2.7 |
| `com.typesafe.akka:akka-http-core_2.12` | Maven | From 10.2.0-M1 | 10.2.7 |
| `com.typesafe.akka:aakka-http-core_2.13.0-M3` | Maven | From 10.1.0 | None |
| `com.typesafe.akka:aakka-http-core_2.13.0-M3` | Maven | From 10.1.0 | None |
| `com.typesafe.akka:akka-http-core_2.11` | Maven | From 10.1.0 | 10.1.15 |
| `com.typesafe.akka:akka-http-core_2.11` | Maven | From 10.1.0 | 10.1.15 |
| `com.typesafe.akka:akka-http-core_2.13` | Maven | From 10.1.0 | 10.1.15 |
| `com.typesafe.akka:akka-http-core_2.13` | Maven | From 10.1.0 | 10.1.15 |
| `com.typesafe.akka:akka-http-core_2.13` | Maven | From 10.2.0-M1 | 10.2.7 |
| `com.typesafe.akka:akka-http-core_2.13` | Maven | From 10.2.0-M1 | 10.2.7 |
| `com.typesafe.akka:akka-http-core_2.13.0-M5` | Maven | From 10.1.0 | None |
| `com.typesafe.akka:akka-http-core_2.13.0-M5` | Maven | From 10.1.0 | None |
| `com.typesafe.akka:akka-http-core_2.13.0-RC2` | Maven | From 10.1.0 | None |
| `com.typesafe.akka:akka-http-core_2.13.0-RC2` | Maven | From 10.1.0 | None |
| `com.typesafe.akka:akka-http-core_2.13.0-RC3` | Maven | From 10.1.0 | None |
| `com.typesafe.akka:akka-http-core_2.13.0-RC3` | Maven | From 10.1.0 | None |

Products: Akka Http Server.

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

Upgrade com.typesafe.akka:akka-http-core_2.12 to a fixed version for your release line: 10.1.15 or 10.2.7.

## Is CVE-2021-42697 being exploited?

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

Public exploit code:

- Proof of concept exploit for CVE-2021-42697: Akka HTTP 10.1.x before 10.1.15 and 10.2.x before 10.2.7 can encounter stack exhaustion while parsing HTTP headers, which allows a remote attacker to conduct a Denial of Service attack by sending a User-Agent header with deeply nested comments. (github_poc): https://github.com/cxosmo/CVE-2021-42697
- Akka HTTP 10.1.14 - Denial of Service (exploitdb)

## Other vulnerabilities in n/a

- [CVE-2023-44487](https://insights.sbomify.com/CVE-2023-44487/): HTTP/2 Rapid Reset Attack (high 7.5, exploited in the wild)
- [CVE-2017-1000118](https://insights.sbomify.com/CVE-2017-1000118/): Improper Restriction of Operations within the Bounds of a Memory Buffer in akka-http-core (high 7.5)

## Fix prompt for AI coding agents

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

What it is: CVE-2021-42697 is a high-severity denial of service vulnerability in n/a, published on 2 Nov 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-42697 in the wild and no public exploit code.

Affected packages and fixed versions:
- com.typesafe.akka:akka-http-core_2.12 (Maven): affected from 10.1.0; fixed in 10.1.15
- com.typesafe.akka:akka-http-core_2.12 (Maven): affected from 10.1.0; fixed in 10.1.15
- com.typesafe.akka:akka-http-core_2.12 (Maven): affected from 10.2.0-M1; fixed in 10.2.7
- com.typesafe.akka:akka-http-core_2.12 (Maven): affected from 10.2.0-M1; fixed in 10.2.7
- com.typesafe.akka:aakka-http-core_2.13.0-M3 (Maven): affected from 10.1.0; no fix listed
- com.typesafe.akka:aakka-http-core_2.13.0-M3 (Maven): affected from 10.1.0; no fix listed
- com.typesafe.akka:akka-http-core_2.11 (Maven): affected from 10.1.0; fixed in 10.1.15
- com.typesafe.akka:akka-http-core_2.11 (Maven): affected from 10.1.0; fixed in 10.1.15
- com.typesafe.akka:akka-http-core_2.13 (Maven): affected from 10.1.0; fixed in 10.1.15
- com.typesafe.akka:akka-http-core_2.13 (Maven): affected from 10.1.0; fixed in 10.1.15
- com.typesafe.akka:akka-http-core_2.13 (Maven): affected from 10.2.0-M1; fixed in 10.2.7
- com.typesafe.akka:akka-http-core_2.13 (Maven): affected from 10.2.0-M1; fixed in 10.2.7

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

## Sources

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

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