CVE-2021-4435: Yarn Yarn Untrusted Search Path Vulnerability Vulnerability

HIGH
Advisory Identifier: GHSA-mpwj-fcr6-x34c
CVSS 7.7
CWE-426
Published
Advisory Summary

CVE-2021-4435 is a HIGH (CVSS 7.7) yarn untrusted search path vulnerability vulnerability (CWE-426: Untrusted Search Path) affecting Yarn libraries in the npm ecosystem. The issue involves yarn untrusted search path vulnerability. Remediation is available by upgrading affected packages to version 1.22.13.

CVE-2021-4435 at a Glance

CVE Identifier CVE-2021-4435
GHSA Identifier GHSA-mpwj-fcr6-x34c
Severity HIGH
CVSS v3.1 Base Score 7.7
CWE Classification CWE-426: Untrusted Search Path
Affected Product Yarn
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H).

Attack Vector Local (AV:L)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2021-4435

To remediate this vulnerability, upgrade all affected Yarn dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

yarn fixed: 1.22.13
npm install yarn@1.22.13
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls yarn

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2021-4435, inspect your project dependencies using npm:

npm ls yarn

Analyze the terminal output to locate any version of Yarn in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.22.13), your application is affected.

Note: The npm ls yarn command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-426: Untrusted Search Path, where the product searches for critical resources using an externally-supplied search path that can point to resources that are not under the product's direct control. In Yarn, 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

An untrusted search path vulnerability was found in Yarn. When a victim runs certain Yarn commands in a directory with attacker-controlled content, malicious commands could be executed in unexpected ways.

CVE-2021-4435 Affected Yarn Versions

1 component(s)
Fixed Versions:
1.22.13
Product / Package Ecosystem Affected Versions Fixed Version
yarn
npm
< 1.22.13
1.22.13

References

Frequently Asked Questions

What is CVE-2021-4435?
CVE-2021-4435 is a security vulnerability in Yarn involving Yarn untrusted search path vulnerability under CWE-426: Untrusted Search Path.
Which Yarn versions are affected?
Affected versions include releases prior to 1.22.13 across affected packages: yarn.
What version fixes CVE-2021-4435?
Upgrading to 1.22.13 (or the latest patched release for your respective branch) resolves the vulnerability.
Is yarn affected?
Yes, yarn is affected in releases prior to 1.22.13. Upgrade your dependency to 1.22.13 or later.
What is the CVSS score of CVE-2021-4435?
CVE-2021-4435 has a CVSS v3.1 base score of 7.7 (HIGH) with vector string CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2021-4435?
CVE-2021-4435 is classified under CWE-426: Untrusted Search Path (The product searches for critical resources using an externally-supplied search path that can point to resources that are not under the product's direct control.).
How can I check npm dependencies for CVE-2021-4435?
Run the dependency tree command: 'npm ls yarn'. 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-mpwj-fcr6-x34c",
  "modified" : "2024-02-05T20:20:29Z",
  "published" : "2024-02-04T21:30:43Z",
  "aliases" : [ "CVE-2021-4435" ],
  "summary" : "Yarn untrusted search path vulnerability",
  "details" : "An untrusted search path vulnerability was found in Yarn. When a victim runs certain Yarn commands in a directory with attacker-controlled content, malicious commands could be executed in unexpected ways.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "yarn"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.22.13"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-4435"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yarnpkg/yarn/commit/67fcce88935e45092ffa2674c08053f1ef5268a1"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/security/cve/CVE-2021-4435"
  }, {
    "type" : "WEB",
    "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=2262284"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/yarnpkg/yarn"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yarnpkg/yarn/releases/tag/v1.22.13"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-426" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-02-05T20:20:29Z",
    "nvd_published_at" : "2024-02-04T20:15:45Z"
  }
}