Vulnerabilities in pkg:pypi/pyyaml

PACKAGE
Advisory Identifier: GHSA-6757-jp84-gxfx
Advisory Summary

CVE-2020-1747 is a CRITICAL (CVSS 9.8) improper input validation vulnerability (CWE-20: Improper Input Validation) affecting Pyyaml libraries in the PyPI ecosystem. The issue involves improper input validation in pyyaml. Remediation is available by upgrading affected packages to version 5.3.1.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/pyyaml

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/pyyaml. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-6757-jp84-gxfx CVE-2020-1747 CRITICAL Improper Input Validation in PyYAML
GHSA-3pqx-4fqf-j49f CVE-2019-20477 CRITICAL Deserialization of Untrusted Data in PyYAML

CVE-2020-1747 at a Glance

CVE Identifier CVE-2020-1747
GHSA Identifier GHSA-6757-jp84-gxfx
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-20: Improper Input Validation
Affected Product Pyyaml
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 9.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2020-1747

To remediate this vulnerability, upgrade all affected Pyyaml dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

pyyaml fixed: 5.3.1
pip install pyyaml>=5.3.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show pyyaml

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2020-1747, inspect your installed packages using pip:

pip show pyyaml

Analyze the terminal output to locate any version of Pyyaml in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.3.1), your application is affected.

Note: The pip show pyyaml command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Pyyaml, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

A vulnerability was discovered in the PyYAML library in versions before 5.3.1, 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. An attacker could use this flaw to execute arbitrary code on the system by abusing the python/object/new constructor.

CVE-2020-1747 Affected Pyyaml Versions

1 component(s)
Fixed Versions:
5.3.1
Product / Package Ecosystem Affected Versions Fixed Version
pyyaml
PyPI
≥ 5.1b7
< 5.3.1
5.3.1

References

NVD — CVE-2020-1747 NVD
https://nvd.nist.gov/vuln/detail/CVE-2020-1747
Pyyaml Source Repository REPOSITORY
https://github.com/github/advisory-database/pull/4942
Pyyaml Source Repository REPOSITORY
https://github.com/yaml/pyyaml/pull/386
Security Fix Commit FIX COMMIT
https://github.com/yaml/pyyaml/commit/0cedb2a0697b2bc49e4f3841b8d4590b6b15657e
Security Fix Commit FIX COMMIT
https://github.com/yaml/pyyaml/commit/5080ba513377b6355a0502104846ee804656f1e0
bugzilla.redhat.com/show_bug.cgi WEB
https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2020-1747
GitHub Advisory / Wiki ADVISORY
https://github.com/advisories/GHSA-6757-jp84-gxfx
Pyyaml Source Repository REPOSITORY
https://github.com/pypa/advisory-database/tree/main/vulns/pyyaml/PYSEC-2020-96.yaml
Pyyaml Source Repository REPOSITORY
https://github.com/yaml/pyyaml
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/7PPAS6C4SZRDQLR7C22A5U3QOLXY33JX
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/K5HEPD7LEVDPCITY5IMDYWXUMX37VFMY
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/MMQXSZXNJT6ERABJZAAICI3DQSQLCP3D
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/WORRFHPQVAFKKXXWLSSW6XKUYLWM6CSH
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ZBJA3SGNJKCAYPSHOHWY3KBCWNM5NYK2
Pyyaml Security Information SECURITY
https://www.oracle.com/security-alerts/cpujul2022.html
Pyyaml Security Information SECURITY
http://lists.opensuse.org/opensuse-security-announce/2020-04/msg00017.html
Pyyaml Security Information SECURITY
http://lists.opensuse.org/opensuse-security-announce/2020-05/msg00017.html

Frequently Asked Questions

What is CVE-2020-1747?
CVE-2020-1747 is a security vulnerability in Pyyaml involving Improper Input Validation in PyYAML under CWE-20: Improper Input Validation.
Which Pyyaml versions are affected?
Affected versions include releases prior to 5.3.1 across affected packages: pyyaml.
What version fixes CVE-2020-1747?
Upgrading to 5.3.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pyyaml affected?
Yes, pyyaml is affected in releases prior to 5.3.1. Upgrade your dependency to 5.3.1 or later.
What is the CVSS score of CVE-2020-1747?
CVE-2020-1747 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2020-1747?
CVE-2020-1747 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check PyPI dependencies for CVE-2020-1747?
Run the dependency tree command: 'pip show pyyaml'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-6757-jp84-gxfx",
  "modified" : "2024-10-31T16:17:34Z",
  "published" : "2021-04-20T16:14:24Z",
  "aliases" : [ "CVE-2020-1747" ],
  "summary" : "Improper Input Validation in PyYAML",
  "details" : "A vulnerability was discovered in the PyYAML library in versions before 5.3.1, 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. An attacker could use this flaw to execute arbitrary code on the system by abusing the python/object/new constructor.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "pyyaml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.1b7"
      }, {
        "fixed" : "5.3.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-1747"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/github/advisory-database/pull/4942"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yaml/pyyaml/pull/386"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yaml/pyyaml/commit/0cedb2a0697b2bc49e4f3841b8d4590b6b15657e"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yaml/pyyaml/commit/5080ba513377b6355a0502104846ee804656f1e0"
  }, {
    "type" : "WEB",
    "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2020-1747"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-6757-jp84-gxfx"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pyyaml/PYSEC-2020-96.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/yaml/pyyaml"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/7PPAS6C4SZRDQLR7C22A5U3QOLXY33JX"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/K5HEPD7LEVDPCITY5IMDYWXUMX37VFMY"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/MMQXSZXNJT6ERABJZAAICI3DQSQLCP3D"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/WORRFHPQVAFKKXXWLSSW6XKUYLWM6CSH"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ZBJA3SGNJKCAYPSHOHWY3KBCWNM5NYK2"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpujul2022.html"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2020-04/msg00017.html"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2020-05/msg00017.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-04-07T22:29:00Z",
    "nvd_published_at" : "2020-03-24T15:15:00Z"
  }
}