# CVE-2019-16760: Cargo prior to Rust 1.26.0 may download the wrong dependency

> Attackers can hijack dependencies by squatting on crates.io when Cargo ignores package renaming keys, leading to malicious code execution.

- **Severity:** Medium 4.6 (`CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 30 Sep 2019
- **Updated:** 5 Aug 2024
- **Also known as:** ALPINE-CVE-2019-16760, CLEANSTART-2026-KD42401, DEBIAN-CVE-2019-16760, GHSA-9f3p-wvj7-q82x, GHSA-phjm-8x66-qw4r

## What is CVE-2019-16760?

CVE-2019-16760 is a medium-severity vulnerability in rust cargo, published on 30 Sep 2019. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

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.

Weakness: CWE-494 (Download of Code Without Integrity Check), CWE-16

## Which versions are affected by CVE-2019-16760?

2 open source packages ship an affected version, including cargo. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `cargo` | crates.io | All versions | 0.27.0 |
| `cargo` | crates.io | All versions | 0.27.0 |

Products: Rust-Lang Rust.

## How do I fix CVE-2019-16760?

Upgrade cargo to 0.27.0 or later.

## Is CVE-2019-16760 being exploited?

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

## Other vulnerabilities in rust cargo

- [CVE-2020-36318](https://insights.sbomify.com/CVE-2020-36318/): Use after free in n/a (critical 9.8)
- [CVE-2018-1000810](https://insights.sbomify.com/CVE-2018-1000810/): Integer overflow in n/a (critical 9.8)
- [CVE-2021-29922](https://insights.sbomify.com/CVE-2021-29922/): Security feature bypass in n/a (critical 9.1)
- [CVE-2024-43402](https://insights.sbomify.com/CVE-2024-43402/): Rust OS Command Injection/Argument Injection vulnerability (high 8.2)
- [CVE-2018-1000657](https://insights.sbomify.com/CVE-2018-1000657/): Memory corruption in n/a (high 7.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2019-16760 and fix it if it is affected.

What it is: CVE-2019-16760 is a medium-severity vulnerability in rust cargo, published on 30 Sep 2019. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2019-16760 in the wild and no public exploit code.

Affected packages and fixed versions:
- cargo (crates.io): affected all versions; fixed in 0.27.0
- cargo (crates.io): affected all versions; fixed in 0.27.0

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-2019-16760/ (Markdown: https://insights.sbomify.com/CVE-2019-16760/index.md)
```

## Sources

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

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