# CVE-2020-14343: Improper Input Validation in PyYAML

> Attackers can execute arbitrary code by providing malicious YAML files to applications using the vulnerable PyYAML library.

- **Severity:** Critical 9.8 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 9 Feb 2021
- **Updated:** 4 Aug 2024
- **Also known as:** ALPINE-CVE-2020-14343, AZL-31782, CLSA-2025-1762733645, DEBIAN-CVE-2020-14343, GHSA-8q59-q68h-6hv4, MGASA-2021-0119, OESA-2021-1257, PYSEC-2021-142, RHSA-2021:2583, RLSA-2021:2583, SUSE-SU-2021:2818-1, SUSE-SU-2022:3231-1, SUSE-SU-2026:4402-1, UBUNTU-CVE-2020-14343, USN-4940-1

## What is CVE-2020-14343?

CVE-2020-14343 is a critical code injection vulnerability in PyYAML, published on 9 Feb 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

A vulnerability was discovered in the PyYAML library in versions before 5.4, where it 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. This flaw allows an attacker to execute arbitrary code on the system by abusing the python/object/new constructor. This flaw is due to an incomplete fix for CVE-2020-1747.

Weakness: CWE-20 (Improper Input Validation)

## Which versions are affected by CVE-2020-14343?

3 open source packages ship an affected version, including pyyaml and PyYAML. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `pyyaml` | PyPI | All versions | 5.4 |
| `pyyaml` | PyPI | All versions | 5.4 |
| `PyYAML` | PyPI | All versions | 5.4 |
| `Cython` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.29.14-4.module+el8.4.0+8888+89bc7e79 |
| `Cython-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.29.14-4.module+el8.4.0+8888+89bc7e79 |
| `PyYAML` | Red Hat:enterprise_linux:8::appstream | All versions | 0:5.4.1-1.module+el8.4.0+10706+5c295a3e |
| `PyYAML-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:5.4.1-1.module+el8.4.0+10706+5c295a3e |
| `babel` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.7.0-10.module+el8.4.0+8888+89bc7e79 |
| `mod_wsgi` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.6.8-3.module+el8.4.0+8888+89bc7e79 |
| `numpy` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.17.3-5.module+el8.4.0+8888+89bc7e79 |
| `numpy-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.17.3-5.module+el8.4.0+8888+89bc7e79 |
| `python-PyMySQL` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.10.1-1.module+el8.4.0+9692+8e86ab84 |
| `python-asn1crypto` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.2.0-3.module+el8.4.0+8888+89bc7e79 |
| `python-cffi` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.13.2-3.module+el8.4.0+8888+89bc7e79 |
| `python-cffi-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.13.2-3.module+el8.4.0+8888+89bc7e79 |
| `python-chardet` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.0.4-19.module+el8.4.0+8888+89bc7e79 |
| `python-cryptography` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.8-3.module+el8.4.0+8888+89bc7e79 |
| `python-cryptography-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.8-3.module+el8.4.0+8888+89bc7e79 |
| `python-idna` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.8-6.module+el8.4.0+8888+89bc7e79 |
| `python-jinja2` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.10.3-4.module+el8.4.0+8888+89bc7e79 |
| `python-lxml` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.4.1-5.module+el8.4.0+9001+fc421f6c |
| `python-lxml-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:4.4.1-5.module+el8.4.0+9001+fc421f6c |
| `python-markupsafe` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.1.1-6.module+el8.4.0+8888+89bc7e79 |
| `python-markupsafe-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.1.1-6.module+el8.4.0+8888+89bc7e79 |
| `python-ply` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.11-10.module+el8.4.0+9579+e9717e18 |
| `python-psutil` | Red Hat:enterprise_linux:8::appstream | All versions | 0:5.6.4-3.module+el8.4.0+8888+89bc7e79 |
| `python-psutil-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:5.6.4-3.module+el8.4.0+8888+89bc7e79 |
| `python-psycopg2` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.8.4-4.module+el8.4.0+8888+89bc7e79 |
| `python-psycopg2-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.8.4-4.module+el8.4.0+8888+89bc7e79 |
| `python-pycparser` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.19-3.module+el8.4.0+8888+89bc7e79 |
| `python-pysocks` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.7.1-4.module+el8.4.0+8888+89bc7e79 |
| `python-requests` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.22.0-9.module+el8.4.0+8888+89bc7e79 |
| `python-urllib3` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.25.7-4.module+el8.4.0+8888+89bc7e79 |
| `python-wheel` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.33.6-5.module+el8.4.0+8888+89bc7e79 |
| `python38` | Red Hat:enterprise_linux:8::appstream | All versions | 0:3.8.6-3.module+el8.4.0+9579+e9717e18 |
| `python38-Cython` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.29.14-4.module+el8.4.0+8888+89bc7e79 |
| `python38-Cython-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.29.14-4.module+el8.4.0+8888+89bc7e79 |
| `python38-PyMySQL` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.10.1-1.module+el8.4.0+9692+8e86ab84 |
| `python38-asn1crypto` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.2.0-3.module+el8.4.0+8888+89bc7e79 |
| `python38-babel` | Red Hat:enterprise_linux:8::appstream | All versions | 0:2.7.0-10.module+el8.4.0+8888+89bc7e79 |

Products: Oracle Communications Cloud Native Core Network Function Cloud Native Environment, Pyyaml Pyyaml.

## How do I fix CVE-2020-14343?

Upgrade pyyaml to 5.4 or later.

## Is CVE-2020-14343 being exploited?

There is no known exploitation of CVE-2020-14343 in the wild and no public exploit code.

Public exploit code:

- A web application vulnerable to CVE-2020-14343 insecure deserialization leading to command execution in PyYAML package. (github_poc): https://github.com/j4k0m/loader-CVE-2020-14343
- CVE-2020-14343的payload (github_poc): https://github.com/Kairo-one/CVE-2020-14343-PyYAML
- https://github.com/sijie52/yasa-cve-2020-14343 (github_poc): https://github.com/sijie52/yasa-cve-2020-14343
- Controlled vulnerability research and reproduction lab for CVE-2020-14343 in PyYAML (github_poc): https://github.com/saina15/cve-2020-14343-lab

## Other vulnerabilities in PyYAML

- [CVE-2020-7733](https://insights.sbomify.com/CVE-2020-7733/): Regular Expression Denial of Service (ReDoS) (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2020-14343 and fix it if it is affected.

What it is: CVE-2020-14343 is a critical code injection vulnerability in PyYAML, published on 9 Feb 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2020-14343 in the wild and no public exploit code.

Affected packages and fixed versions:
- pyyaml (PyPI): affected all versions; fixed in 5.4
- pyyaml (PyPI): affected all versions; fixed in 5.4
- PyYAML (PyPI): affected all versions; fixed in 5.4

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2020-14343/ (Markdown: https://insights.sbomify.com/CVE-2020-14343/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2020-14343
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2020-14343
- OSV: https://osv.dev/vulnerability/CVE-2020-14343

---
From sbomify Insights: https://insights.sbomify.com/CVE-2020-14343/
Summaries are generated and may contain mistakes; the official description above is the record.
