CVE-2019-20477: Pyyaml Deserialization Of Untrusted Data Vulnerability

CRITICAL
Advisory Identifier: GHSA-3pqx-4fqf-j49f
CVSS 9.8
CWE-502
Published
Advisory Summary

CVE-2019-20477 is a CRITICAL (CVSS 9.8) deserialization of untrusted data vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Pyyaml libraries in the PyPI ecosystem. The issue involves deserialization of untrusted data in pyyaml. Remediation is available by upgrading affected packages to version 5.2.

CVE-2019-20477 at a Glance

CVE Identifier CVE-2019-20477
GHSA Identifier GHSA-3pqx-4fqf-j49f
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-502: Deserialization of Untrusted Data
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-2019-20477

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.2
pip install pyyaml>=5.2
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-2019-20477, 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.2), 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-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. 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

PyYAML 5.1 through 5.1.2 has insufficient restrictions on the load and load_all functions because of a class deserialization issue, e.g., Popen is a class in the subprocess module. NOTE: this issue exists because of an incomplete fix for CVE-2017-18342.

CVE-2019-20477 Affected Pyyaml Versions

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

References

Frequently Asked Questions

What is CVE-2019-20477?
CVE-2019-20477 is a security vulnerability in Pyyaml involving Deserialization of Untrusted Data in PyYAML under CWE-502: Deserialization of Untrusted Data.
Which Pyyaml versions are affected?
Affected versions include releases prior to 5.2 across affected packages: pyyaml.
What version fixes CVE-2019-20477?
Upgrading to 5.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pyyaml affected?
Yes, pyyaml is affected in releases prior to 5.2. Upgrade your dependency to 5.2 or later.
What is the CVSS score of CVE-2019-20477?
CVE-2019-20477 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-2019-20477?
CVE-2019-20477 is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check PyPI dependencies for CVE-2019-20477?
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-3pqx-4fqf-j49f",
  "modified" : "2024-10-25T21:15:15Z",
  "published" : "2021-04-20T16:40:42Z",
  "aliases" : [ "CVE-2019-20477" ],
  "summary" : "Deserialization of Untrusted Data in PyYAML",
  "details" : "PyYAML 5.1 through 5.1.2 has insufficient restrictions on the load and load_all functions because of a class deserialization issue, e.g., Popen is a class in the subprocess module. NOTE: this issue exists because of an incomplete fix for CVE-2017-18342.",
  "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.1"
      }, {
        "fixed" : "5.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2019-20477"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-3pqx-4fqf-j49f"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pyyaml/PYSEC-2020-176.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/yaml/pyyaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yaml/pyyaml/blob/master/CHANGES"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/33VBUY73AA6CTTYL3LRWHNFDULV7PFPN"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/52N5XS73Z5S4ZN7I7R56ICCPCTKCUV4H"
  }, {
    "type" : "WEB",
    "url" : "https://www.exploit-db.com/download/47655"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-502" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-04-08T19:24:04Z",
    "nvd_published_at" : "2020-02-19T04:15:00Z"
  }
}