Vulnerabilities in pkg:golang/github.com/go-yaml/yaml

PACKAGE
Advisory Identifier: GHSA-r88r-gmrh-7j83
Advisory Summary

CVE-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.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:golang/github.com/go-yaml/yaml

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:golang/github.com/go-yaml/yaml. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-r88r-gmrh-7j83 CVE-2021-4235 MODERATE YAML Go package vulnerable to denial of service
GHSA-wxc4-f4m6-wwqv CVE-2019-11254 MODERATE Excessive Platform Resource Consumption within a Loop in Kubernetes

CVE-2021-4235 at a Glance

CVE Identifier CVE-2021-4235
GHSA Identifier GHSA-r88r-gmrh-7j83
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification General Security Weakness
Affected Product Gopkg.in/yaml.v2
Package Ecosystem Go
Published Date
Last Updated

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).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (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.

gopkg.in/yaml.v2 fixed: 2.2.3
Upgrade gopkg.in/yaml.v2 to 2.2.3
github.com/go-yaml/yaml fixed: Latest secure release
Upgrade github.com/go-yaml/yaml to Latest secure release
Verify Direct and Transitive Dependencies

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

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.

CVE-2021-4235 Affected Gopkg.in/yaml.v2 Versions

2 component(s)
Fixed Versions:
2.2.3
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?
CVE-2021-4235 is a security vulnerability in Gopkg.in/yaml.v2 involving YAML Go package vulnerable to denial of service under General Security Weakness.
Which Gopkg.in/yaml.v2 versions are affected?
Affected versions include releases prior to 2.2.3 across affected packages: gopkg.in/yaml.v2, github.com/go-yaml/yaml.
What version fixes CVE-2021-4235?
Upgrading to 2.2.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gopkg.in/yaml.v2 affected?
Yes, gopkg.in/yaml.v2 is affected in releases prior to 2.2.3. Upgrade your dependency to 2.2.3 or later.
Is github.com/go-yaml/yaml affected?
Yes, github.com/go-yaml/yaml is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2021-4235?
CVE-2021-4235 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2021-4235?
CVE-2021-4235 is classified under General Security Weakness.
How can I check Go dependencies for CVE-2021-4235?
Run the dependency tree command: 'inspect dependencies for gopkg.in/yaml.v2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}