CVE-2021-4235: Gopkg.in/yaml.v2 Denial of Service Vulnerability
MODERATECVE-2021-4235 is a MODERATE (CVSS 5.5) denial of service vulnerability (General Security Weakness) affecting Gopkg.in/yaml.v2 libraries in the Go ecosystem. The issue involves yaml go package vulnerable to denial of service. Remediation is available by upgrading affected packages to version 2.2.3.
CVE-2021-4235 at a Glance
Security Impact
CVSS: 5.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H).
How to Fix CVE-2021-4235
To remediate this vulnerability, upgrade all affected Gopkg.in/yaml.v2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade gopkg.in/yaml.v2 to 2.2.3
Upgrade github.com/go-yaml/yaml to Latest secure release
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for gopkg.in/yaml.v2
How to Check if You Are Affected
To determine whether your application is affected by CVE-2021-4235, inspect your project dependencies for Gopkg.in/yaml.v2:
inspect dependencies for gopkg.in/yaml.v2
Analyze the terminal output to locate any version of Gopkg.in/yaml.v2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.2.3), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under General Security Weakness. In Gopkg.in/yaml.v2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2021-4235 Affected Gopkg.in/yaml.v2 Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
gopkg.in/yaml.v2
|
Go |
< 2.2.3
|
2.2.3
|
|
github.com/go-yaml/yaml
|
Go |
≤ 2.1.0
|
|
References
Frequently Asked Questions
What is CVE-2021-4235?
Which Gopkg.in/yaml.v2 versions are affected?
What version fixes CVE-2021-4235?
Is gopkg.in/yaml.v2 affected?
Is github.com/go-yaml/yaml affected?
What is the CVSS score of CVE-2021-4235?
What CWE is associated with CVE-2021-4235?
How can I check Go dependencies for CVE-2021-4235?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-r88r-gmrh-7j83",
"modified" : "2025-04-11T23:46:34Z",
"published" : "2022-12-28T00:30:23Z",
"aliases" : [ "CVE-2021-4235" ],
"summary" : "YAML Go package vulnerable to denial of service",
"details" : "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.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "gopkg.in/yaml.v2"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.2.3"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/go-yaml/yaml"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "2.1.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-4235"
}, {
"type" : "WEB",
"url" : "https://github.com/go-yaml/yaml/pull/375"
}, {
"type" : "WEB",
"url" : "https://github.com/go-yaml/yaml/commit/bb4e33bf68bf89cad44d386192cbed201f35b241"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/go-yaml/yaml"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2023/07/msg00001.html"
}, {
"type" : "WEB",
"url" : "https://pkg.go.dev/vuln/GO-2021-0061"
} ],
"database_specific" : {
"cwe_ids" : [ ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-12-30T19:02:10Z",
"nvd_published_at" : "2022-12-27T22:15:00Z"
}
}