GHSA-8j8c-7jfh-h6hx: Js yaml Code Injection Vulnerability

HIGH
CWE-94
Published
Advisory Summary

GHSA-8j8c-7jfh-h6hx is a HIGH code injection vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Js yaml libraries in the npm ecosystem. The issue involves code injection in js-yaml. Remediation is available by upgrading affected packages to version 3.13.1.

GHSA-8j8c-7jfh-h6hx at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-8j8c-7jfh-h6hx
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Js yaml
Package Ecosystem npm
Published Date
Last Updated

How to Fix GHSA-8j8c-7jfh-h6hx

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

js-yaml fixed: 3.13.1
npm install js-yaml@3.13.1
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 js-yaml

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-8j8c-7jfh-h6hx, inspect your project dependencies using npm:

npm ls js-yaml

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

Note: The npm ls js-yaml 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-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Js yaml, 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

Versions of `js-yaml` prior to 3.13.1 are vulnerable to Code Injection. The `load()` function may execute arbitrary code injected through a malicious YAML file. Objects that have `toString` as key, JavaScript code as value and are used as explicit mapping keys allow attackers to execute the supplied code through the `load()` function. The `safeLoad()` function is unaffected. An example payload is `{ toString: !<tag:yaml.org,2002:js/function> 'function (){return Date.now()}' } : 1` which returns the object { "1553107949161": 1 } ## Recommendation Upgrade to version 3.13.1.

GHSA-8j8c-7jfh-h6hx Affected Js yaml Versions

1 component(s)
Fixed Versions:
3.13.1
Product / Package Ecosystem Affected Versions Fixed Version
js-yaml
npm
< 3.13.1
3.13.1

References

Frequently Asked Questions

What is GHSA-8j8c-7jfh-h6hx?
GHSA-8j8c-7jfh-h6hx is a security vulnerability in Js yaml involving Code Injection in js-yaml under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Js yaml versions are affected?
Affected versions include releases prior to 3.13.1 across affected packages: js-yaml.
What version fixes GHSA-8j8c-7jfh-h6hx?
Upgrading to 3.13.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is js-yaml affected?
Yes, js-yaml is affected in releases prior to 3.13.1. Upgrade your dependency to 3.13.1 or later.
What CWE is associated with GHSA-8j8c-7jfh-h6hx?
GHSA-8j8c-7jfh-h6hx is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check npm dependencies for GHSA-8j8c-7jfh-h6hx?
Run the dependency tree command: 'npm ls js-yaml'. 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-8j8c-7jfh-h6hx",
  "modified" : "2020-08-31T18:36:43Z",
  "published" : "2019-06-04T20:14:07Z",
  "aliases" : [ ],
  "summary" : "Code Injection in js-yaml",
  "details" : "Versions of `js-yaml` prior to 3.13.1 are vulnerable to Code Injection. The `load()` function may execute arbitrary code injected through a malicious YAML file. Objects that have `toString` as key, JavaScript code as value and are used as explicit mapping keys allow attackers to execute the supplied code through the `load()` function. The `safeLoad()` function is unaffected.\n\nAn example payload is \n`{ toString: !<tag:yaml.org,2002:js/function> 'function (){return Date.now()}' } : 1` \nwhich returns the object \n{\n  \"1553107949161\": 1\n}\n\n\n## Recommendation\n\nUpgrade to version 3.13.1.",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "js-yaml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.13.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nodeca/js-yaml/pull/480"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nodeca/js-yaml/pull/480/commits/e18afbf1edcafb7add2c4c7b22abc8d6ebc2fa61"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/advisories/813"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2019-06-04T20:13:53Z",
    "nvd_published_at" : null
  }
}