# CVE-2021-4235: Denial of service in gopkg.in/yaml.v2

> Attackers can cause denial of service by providing crafted YAML input to applications using the vulnerable Go YAML library.

- **Severity:** Medium 5.5 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 27 Dec 2022
- **Updated:** 11 Apr 2025
- **Also known as:** AZL-43447, AZL-43642, AZL-43918, AZL-44229, AZL-45237, AZL-45360, CLEANSTART-2026-ZL73481, DEBIAN-CVE-2021-4235, GHSA-r88r-gmrh-7j83, GO-2021-0061, UBUNTU-CVE-2021-4235

## What is CVE-2021-4235?

CVE-2021-4235 is a medium-severity denial of service vulnerability in github.com/go-yaml/yaml, published on 27 Dec 2022. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

Due to unbounded alias chasing, a maliciously crafted YAML file can cause the system to consume significant system resources. If parsing user input, this may be used as a denial of service vector.

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

6 open source packages ship an affected version, including github.com/go-yaml/yaml and gopkg.in/yaml.v2. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/go-yaml/yaml` | Go | All versions | None |
| `github.com/go-yaml/yaml` | Go | All versions to 2.1.0 | None |
| `github.com/go-yaml/yaml` | Go | All versions to 2.1.0 | None |
| `gopkg.in/yaml.v2` | Go | All versions | 2.2.3 |
| `gopkg.in/yaml.v2` | Go | All versions | 2.2.3 |
| `gopkg.in/yaml.v2` | Go | All versions | 2.2.3 |

Products: Yaml Project Yaml.

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

Upgrade to a fixed version.

## Is CVE-2021-4235 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2021-4235 exists.

## Other vulnerabilities in github.com/go-yaml/yaml

- [CVE-2023-2251](https://insights.sbomify.com/CVE-2023-2251/): Uncaught Exception in eemeli/yaml (high 7.5)
- [CVE-2022-3064](https://insights.sbomify.com/CVE-2022-3064/): Excessive resource consumption in gopkg.in/yaml.v2 (high 7.5)

## Fix prompt for AI coding agents

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

What it is: CVE-2021-4235 is a medium-severity denial of service vulnerability in github.com/go-yaml/yaml, published on 27 Dec 2022. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2021-4235 exists.

Affected packages and fixed versions:
- github.com/go-yaml/yaml (Go): affected all versions; no fix listed
- github.com/go-yaml/yaml (Go): affected all versions up to 2.1.0; no fix listed
- github.com/go-yaml/yaml (Go): affected all versions up to 2.1.0; no fix listed
- gopkg.in/yaml.v2 (Go): affected all versions; fixed in 2.2.3
- gopkg.in/yaml.v2 (Go): affected all versions; fixed in 2.2.3
- gopkg.in/yaml.v2 (Go): affected all versions; fixed in 2.2.3

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

## Sources

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

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