CVE-2019-16760: Cargo Cargo Prior To Rust 1.26.0 Vulnerability

HIGH
Advisory Identifier: GHSA-9f3p-wvj7-q82x
CVSS 7.5
CWE-494
Published
Advisory Summary

CVE-2019-16760 is a HIGH (CVSS 7.5) cargo prior to rust 1.26.0 vulnerability (CWE-494: Download of Code Without Integrity Check) affecting Cargo libraries in the crates.io ecosystem. The issue involves cargo prior to rust 1.26.0 may download the wrong dependency. Remediation is available by upgrading affected packages to version 0.27.0.

CVE-2019-16760 at a Glance

CVE Identifier CVE-2019-16760
GHSA Identifier GHSA-9f3p-wvj7-q82x
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-494: Download of Code Without Integrity Check
Affected Product Cargo
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:N/I:H/A:N).

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 None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2019-16760

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

cargo fixed: 0.27.0
Upgrade cargo to 0.27.0
Verify Direct and Transitive Dependencies

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

inspect dependencies for cargo

How to Check if You Are Affected

To determine whether your application is affected by CVE-2019-16760, inspect your project dependencies for Cargo:

inspect dependencies for cargo

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

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-494: Download of Code Without Integrity Check, where the product downloads source code or an executable from a remote location and executes the code without sufficiently verifying the origin and integrity of the code. In Cargo, 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

Cargo prior to Rust 1.26.0 may download the wrong dependency if your package.toml file uses the `package` configuration key. Usage of the `package` key to rename dependencies in `Cargo.toml` is ignored in Rust 1.25.0 and prior. When Rust 1.25.0 and prior is used Cargo may download the wrong dependency, which could be squatted on crates.io to be a malicious package. This not only affects manifests that you write locally yourself, but also manifests published to crates.io. Rust 1.0.0 through Rust 1.25.0 is affected by this advisory because Cargo will ignore the `package` key in manifests. Rust 1.26.0 through Rust 1.30.0 are not affected and typically will emit an error because the `package` key is unstable. Rust 1.31.0 and after are not affected because Cargo understands the `package` key. Users of the affected versions are strongly encouraged to update their compiler to the latest available one. Preventing this issue from happening requires updating your compiler to be either Rust 1.26.0 or newer. There will be no point release for Rust versions prior to 1.26.0. Users of Rust 1.19.0 to Rust 1.25.0 can instead apply linked patches to mitigate the issue.

CVE-2019-16760 Affected Cargo Versions

1 component(s)
Fixed Versions:
0.27.0
Product / Package Ecosystem Affected Versions Fixed Version
cargo
crates.io
< 0.27.0
0.27.0

References

Frequently Asked Questions

What is CVE-2019-16760?
CVE-2019-16760 is a security vulnerability in Cargo involving Cargo prior to Rust 1.26.0 may download the wrong dependency under CWE-494: Download of Code Without Integrity Check.
Which Cargo versions are affected?
Affected versions include releases prior to 0.27.0 across affected packages: cargo.
What version fixes CVE-2019-16760?
Upgrading to 0.27.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is cargo affected?
Yes, cargo is affected in releases prior to 0.27.0. Upgrade your dependency to 0.27.0 or later.
What is the CVSS score of CVE-2019-16760?
CVE-2019-16760 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2019-16760?
CVE-2019-16760 is classified under CWE-494: Download of Code Without Integrity Check (The product downloads source code or an executable from a remote location and executes the code without sufficiently verifying the origin and integrity of the code.).
How can I check crates.io dependencies for CVE-2019-16760?
Run the dependency tree command: 'inspect dependencies for cargo'. 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-9f3p-wvj7-q82x",
  "modified" : "2024-08-29T18:03:14Z",
  "published" : "2022-05-24T16:57:30Z",
  "aliases" : [ "CVE-2019-16760" ],
  "summary" : "Cargo prior to Rust 1.26.0 may download the wrong dependency",
  "details" : "Cargo prior to Rust 1.26.0 may download the wrong dependency if your package.toml file uses the `package` configuration key. Usage of the `package` key to rename dependencies in `Cargo.toml` is ignored in Rust 1.25.0 and prior. When Rust 1.25.0 and prior is used Cargo may download the wrong dependency, which could be squatted on crates.io to be a malicious package. This not only affects manifests that you write locally yourself, but also manifests published to crates.io. Rust 1.0.0 through Rust 1.25.0 is affected by this advisory because Cargo will ignore the `package` key in manifests. Rust 1.26.0 through Rust 1.30.0 are not affected and typically will emit an error because the `package` key is unstable. Rust 1.31.0 and after are not affected because Cargo understands the `package` key. Users of the affected versions are strongly encouraged to update their compiler to the latest available one. Preventing this issue from happening requires updating your compiler to be either Rust 1.26.0 or newer. There will be no point release for Rust versions prior to 1.26.0. Users of Rust 1.19.0 to Rust 1.25.0 can instead apply linked patches to mitigate the issue.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "cargo"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.27.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rust-lang/rust/security/advisories/GHSA-phjm-8x66-qw4r"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2019-16760"
  }, {
    "type" : "WEB",
    "url" : "https://gist.github.com/pietroalbini/0d293b24a44babbeb6187e06eebd4992"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/forum/#!topic/rustlang-security-announcements/rVQ5e3TDnpQ"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/forum/#%21topic/rustlang-security-announcements/rVQ5e3TDnpQ"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2019/10/08/3"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-494" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-08-29T18:03:14Z",
    "nvd_published_at" : "2019-09-30T22:15:00Z"
  }
}