# CVE-2017-18342: PyYAML insecure deserialization in yaml.load API

Source: https://junglewise.ai/threats/cve-2017-18342-pyyaml-insecure-deserialization-in-yaml-load-api  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2019-01-04. Updated: 2026-07-01  
License: CC BY 4.0 with a link back

CVE-2017-18342 · Severity: critical · CVSS 9.8 · Published 2019-01-04

PyYAML is a popular software library used by developers to process YAML data files. A security flaw in older versions allows the library to execute hidden malicious commands embedded within a data file. If an application uses this library to process data from an untrusted source, an attacker could take complete control of the underlying server.

Technologies: [PyYAML (PyPI)](https://junglewise.ai/threats/technologies/pyyaml). Vendors: [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is CVE-2017-18342 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2017-18342 being exploited in the wild.

**How severe is CVE-2017-18342?** Critical severity, with a CVSS score of 9.8, published 4 January 2019.

**Which products and versions are affected?** PyYAML (PyPI) < 5.1, ECOSYSTEM:introduced=0,fixed=5.1.

**Is there a fix for CVE-2017-18342?** Yes. PyYAML (PyPI): upgrade to 5.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2017-18342 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2017-18342?** Check whether you run PyYAML (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- PyYAML (PyPI): upgrade to 5.1 or later

  ```sh
  pip install "PyYAML>=5.1"
  ```


## Technical details

PyYAML versions prior to 5.1 are vulnerable to a deserialization flaw (CWE-502) within the `yaml.load()` API. The root cause is the library's default behavior of allowing the instantiation of arbitrary Python objects during the parsing of YAML data. A remote, unauthenticated attacker can exploit this by providing a specially crafted YAML string that triggers the execution of arbitrary code on the host system. While a fix was attempted in version 4.1, it was yanked due to breaking changes; the vulnerability is fully addressed in version 5.1 by requiring the use of `yaml.safe_load()` or similar secure loaders.

## Affected products

- PyYAML PyYAML < 5.1

## Identifiers

- CVE-2017-18342
- GHSA-rprw-h62v-c2w7
- PYSEC-2018-49

## Timeline

- 2019-01-04: advisory: GitHub Advisory published
- 2019-01-04: patched: Version 5.1 released with the fix

## References

- [https://api.github.com/users/theinfosecguy](https://api.github.com/users/theinfosecguy)
- [https://github.com/theinfosecguy](https://github.com/theinfosecguy)
- [https://api.github.com/users/theinfosecguy/gists%7B/gist_id%7D](https://api.github.com/users/theinfosecguy/gists%7B/gist_id%7D)
- [https://api.github.com/users/theinfosecguy/repos](https://api.github.com/users/theinfosecguy/repos)
- [https://avatars.githubusercontent.com/u/33570148?v=4](https://avatars.githubusercontent.com/u/33570148?v=4)
- [https://api.github.com/users/theinfosecguy/events%7B/privacy%7D](https://api.github.com/users/theinfosecguy/events%7B/privacy%7D)

## Related threats

- [Improper Input Validation in PyYAML](https://junglewise.ai/threats/cve-2020-14343-improper-input-validation-in-pyyaml)
- [Improper Input Validation in PyYAML](https://junglewise.ai/threats/cve-2020-1747-improper-input-validation-in-pyyaml)
- [PyYAML unsafe deserialization in load and load_all](https://junglewise.ai/threats/cve-2019-20477-pyyaml-unsafe-deserialization-in-load-and-load-all)
- [PYSEC-2020-195 - PyYAML 5.1 through 5.1.2 has insufficient restrictions on the load and load_all functions because of…](https://junglewise.ai/threats/pysec-2020-195-pyyaml-5-1-through-5-1-2-has-insufficient-restrictions-52e85ed8)
