CVE-2020-1747: PyYAML Improper Input Validation

pyyaml Updated 02 Oct 2025

Summary

20/04/2021
Yes i
Critical
9.8

CVE-2020-1747: Improper Input Validation in PyYAML. Affects pyyaml versions >= 5.1b7, < 5.3.1. Fixed in 5.3.1. How to fix ↓

Also tracked for

The same CVE-2020-1747 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

PyYAML is an open-source library for parsing and manipulating YAML (YAML Ain't Markup Language) files in Python. It provides functionality to load YAML data into Python objects and serialize Python objects into YAML format. PyYAML is widely used in various applications for processing YAML files. However, versions before 5.3.1 of PyYAML are vulnerable to an improper input validation issue.

Vulnerability Detail

The vulnerability in PyYAML (versions before 5.3.1) allows for arbitrary code execution when processing untrusted YAML files using the full_load method or the FullLoader loader. This vulnerability can be exploited by an attacker to execute arbitrary code on the system by abusing the python/object/new constructor. Applications that use PyYAML to process untrusted input are susceptible to this flaw. The severity of this vulnerability is rated as CRITICAL with a CVSS score of 9.8.

How To Fix

Minimum fixed version

5.3.1

This is the first release that contains the fix.

pip install --upgrade "pyyaml==5.3.1"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If upgrading PyYAML is not immediately possible, a possible workaround is to avoid using the full_load method or the FullLoader loader with untrusted YAML files. Instead, consider using alternative methods or libraries for parsing and processing YAML data until the PyYAML package can be updated.

Conclusion

In conclusion, PyYAML versions before 5.3.1 are vulnerable to an improper input validation issue that can lead to arbitrary code execution. It is crucial to upgrade to the latest version of PyYAML (5.3.1 or later) to mitigate this vulnerability. If immediate upgrade is not possible, it is advised to avoid using the vulnerable methods or loaders with untrusted YAML files. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for pyyaml →

Share this vulnerability

FAQ

PyYAML is an open-source library for parsing and manipulating YAML files in Python. It provides functionality to load YAML data into Python objects and serialize Python objects into YAML format.

Versions of PyYAML before 5.3.1 are affected by this vulnerability.

An attacker can exploit this vulnerability by providing a specially crafted YAML file that triggers the improper input validation issue in PyYAML. By abusing the python/object/new constructor, the attacker can execute arbitrary code on the system.

This vulnerability is rated as CRITICAL with a CVSS score of 9.8.

To fix this vulnerability, it is recommended to upgrade PyYAML to version 5.3.1 or later. Updating the PyYAML package can be done by running the command 'pip install --upgrade pyyaml'.

Related vulnerabilities

Recent vulnerabilities recorded for pyyaml.

How To Fix

Minimum fixed version

5.3.1

This is the first release that contains the fix.

pip install --upgrade "pyyaml==5.3.1"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback