GHSA-8j8c-7jfh-h6hx: Js yaml Code Injection Vulnerability
HIGHGHSA-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
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.
npm install js-yaml@3.13.1
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
GHSA-8j8c-7jfh-h6hx Affected Js yaml Versions
1 component(s)| 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?
Which Js yaml versions are affected?
What version fixes GHSA-8j8c-7jfh-h6hx?
Is js-yaml affected?
What CWE is associated with GHSA-8j8c-7jfh-h6hx?
How can I check npm dependencies for GHSA-8j8c-7jfh-h6hx?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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
}
}