CVE-2020-1747 Overview
A critical insecure deserialization vulnerability was discovered in the PyYAML library in versions before 5.3.1. The library is susceptible to arbitrary code execution when it processes untrusted YAML files through the full_load method or with the FullLoader loader. Applications that use the library to process untrusted input may be vulnerable to this flaw. An attacker could use this flaw to execute arbitrary code on the system by abusing the python/object/new constructor.
Critical Impact
Remote attackers can achieve arbitrary code execution on vulnerable systems by crafting malicious YAML documents that abuse Python object instantiation through the python/object/new constructor when processed by the FullLoader.
Affected Products
- PyYAML versions prior to 5.3.1
- Fedora 30, 31, 32, and 33
- openSUSE Leap 15.1
- Oracle Communications Cloud Native Core Network Function Cloud Native Environment 22.1.0
Discovery Timeline
- 2020-03-24 - CVE-2020-1747 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2020-1747
Vulnerability Analysis
This vulnerability represents a classic insecure deserialization flaw in PyYAML's handling of YAML documents. The FullLoader class, which was introduced as a safer alternative to the yaml.load() function with Loader=Loader, still permits the instantiation of arbitrary Python objects through the python/object/new constructor tag.
When PyYAML parses a YAML document containing specially crafted tags, it can be tricked into instantiating Python objects and calling their constructors with attacker-controlled arguments. This allows remote attackers to execute arbitrary Python code in the context of the application processing the malicious YAML file.
The vulnerability is particularly dangerous because many applications use PyYAML to parse configuration files, API responses, or user-submitted data without realizing the security implications of using full_load() or FullLoader.
Root Cause
The root cause lies in the improper input validation (CWE-20) within PyYAML's FullLoader class. While the FullLoader was designed to be safer than the unrestricted Loader, it still allows the python/object/new constructor which can be abused to instantiate arbitrary Python objects. The library failed to adequately restrict which Python types could be instantiated during deserialization, allowing attackers to leverage this constructor to call system functions and execute commands.
Attack Vector
The attack vector is network-based, requiring no user interaction or special privileges. An attacker exploits this vulnerability by:
- Crafting a malicious YAML document that contains the !!python/object/new constructor tag
- Embedding a reference to a Python class that can execute system commands (such as subprocess.Popen)
- Providing command arguments that will be executed when the object is instantiated
- Delivering this payload to an application that processes YAML using yaml.full_load() or yaml.load(data, Loader=FullLoader)
When the vulnerable application deserializes the malicious YAML document, PyYAML instantiates the specified Python object, effectively executing the attacker's code on the target system.
The exploitation mechanism involves embedding malicious Python object references in YAML documents. When parsed with the vulnerable loader, these references trigger instantiation of dangerous classes like subprocess.Popen, enabling command execution. Technical details and the security fix are available in the GitHub PyYAML Pull Request.
Detection Methods for CVE-2020-1747
Indicators of Compromise
- YAML files containing !!python/object/new or !!python/object/apply constructor tags in application input directories
- Unexpected process spawning from Python applications that parse YAML content
- Anomalous network connections originating from services that handle YAML input
- Log entries indicating YAML parsing errors followed by system command execution
Detection Strategies
- Implement static code analysis to identify usage of yaml.full_load() or FullLoader in application codebases
- Deploy runtime application monitoring to detect unexpected subprocess creation during YAML parsing operations
- Utilize dependency scanning tools to identify PyYAML versions prior to 5.3.1 in project dependencies
- Monitor for YAML documents containing suspicious Python object constructor patterns in application inputs
Monitoring Recommendations
- Enable verbose logging for applications processing YAML input to capture parsing events and potential exploitation attempts
- Configure file integrity monitoring for configuration files parsed by vulnerable PyYAML instances
- Implement network traffic analysis to detect exfiltration attempts following successful exploitation
- Set up alerts for unusual Python process behavior patterns associated with YAML processing services
How to Mitigate CVE-2020-1747
Immediate Actions Required
- Upgrade PyYAML to version 5.3.1 or later immediately across all environments
- Replace usage of yaml.full_load() with yaml.safe_load() for parsing untrusted input
- Audit all applications that process external YAML content and identify vulnerable code paths
- Implement input validation to reject YAML documents containing Python object constructor tags
Patch Information
PyYAML version 5.3.1 contains the security fix for this vulnerability. The patch restricts the FullLoader from instantiating arbitrary Python objects through the python/object/new constructor. Organizations should update their PyYAML dependency to the patched version using their package manager:
For pip: pip install --upgrade pyyaml>=5.3.1
For additional details, refer to the GitHub PyYAML Pull Request, Red Hat CVE-2020-1747 Details, and the Oracle July 2022 Security Alert.
Workarounds
- Use yaml.safe_load() instead of yaml.full_load() when parsing untrusted YAML content as an immediate mitigation
- Implement input sanitization to strip or reject YAML documents containing !!python/ tags before processing
- Deploy application-level sandboxing to limit the impact of potential code execution
- Consider using alternative YAML parsing libraries that do not support arbitrary object instantiation
# Upgrade PyYAML to patched version
pip install --upgrade 'pyyaml>=5.3.1'
# Verify installed version
pip show pyyaml | grep Version
# Search for vulnerable code patterns in your codebase
grep -r "full_load\|FullLoader" --include="*.py" /path/to/project
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


