# GHSA-8j8c-7jfh-h6hx: Code Injection in js-yaml

- Severity: High (rating, scored by GitHub)
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2019-06-04T20:14:07.000Z
- Modified: 2020-08-31T18:36:43.000Z
- Weaknesses: CWE-94

## Description

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.

(As written by GitHub Advisory Database.)

## Affected

- js-yaml (npm): before 3.13.1

## References

- <https://github.com/nodeca/js-yaml/pull/480> (web)
- <https://github.com/nodeca/js-yaml/pull/480/commits/e18afbf1edcafb7add2c4c7b22abc8d6ebc2fa61> (web)
- <https://www.npmjs.com/advisories/813> (web)

## Sources

- GitHub Advisory Database: [GHSA-8j8c-7jfh-h6hx](https://github.com/advisories/GHSA-8j8c-7jfh-h6hx), CC-BY-4.0, modified 2020-08-31

---

Page: https://cve.day/GHSA-8j8c-7jfh-h6hx · Whole record: https://cve.day/GHSA-8j8c-7jfh-h6hx.json · Rebuilt by cve.day 2026-11-25T22:56:44.750Z
