# CVE-2021-38561: golang.org/x/text/language Out-of-bounds Read vulnerability

> An attacker can cause a denial of service by triggering a panic via malformed BCP 47 language tags in the Go text library.

- **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:** 26 Dec 2022
- **Updated:** 14 Apr 2025
- **Also known as:** AZL-41221, AZL-41469, AZL-44622, AZL-44952, AZL-45375, CLEANSTART-2025-PK28736, CLEANSTART-2026-SD67923, DEBIAN-CVE-2021-38561, GHSA-ppp9-7jff-5vj2, GO-2021-0113, UBUNTU-CVE-2021-38561, openSUSE-SU-2024:12599-1

## What is CVE-2021-38561?

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

### Official description

golang.org/x/text/language in golang.org/x/text before 0.3.7 can panic with an out-of-bounds read during BCP 47 language tag parsing. Index calculation is mishandled. If parsing untrusted user input, this can be used as a vector for a denial-of-service attack.

Weakness: CWE-125 (Out-of-bounds Read)

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

3 open source packages ship an affected version, including golang.org/x/text. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `golang.org/x/text` | Go | All versions | 0.3.7 |
| `golang.org/x/text` | Go | All versions | 0.3.7 |
| `golang.org/x/text` | Go | All versions | 0.3.7 |
| `cni` | openSUSE:Tumbleweed | All versions | 1.1.2-2.1 |

Products: Golang Text.

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

Upgrade golang.org/x/text to 0.3.7 or later.

## Is CVE-2021-38561 being exploited?

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

## Other vulnerabilities in n/a

- [CVE-2022-32149](https://insights.sbomify.com/CVE-2022-32149/): Denial of service via crafted Accept-Language header in golang.org/x/text/language (high 7.5)
- [CVE-2020-28852](https://insights.sbomify.com/CVE-2020-28852/): Denial of service in n/a (high 7.5)

## Fix prompt for AI coding agents

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

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

Affected packages and fixed versions:
- golang.org/x/text (Go): affected all versions; fixed in 0.3.7
- golang.org/x/text (Go): affected all versions; fixed in 0.3.7
- golang.org/x/text (Go): affected all versions; fixed in 0.3.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-38561/ (Markdown: https://insights.sbomify.com/CVE-2021-38561/index.md)
```

## Sources

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

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