|
| 1 | +- Feature Name: crates-io-security |
| 2 | +- Start Date: 2025-10-06 |
| 3 | +- RFC PR: [rust-lang/rfcs#0000](https://github.com/rust-lang/rfcs/pull/0000) |
| 4 | +- Rust Issue: [rust-lang/rust#0000](https://github.com/rust-lang/rust/issues/0000) |
| 5 | + |
| 6 | +# Summary |
| 7 | +[summary]: #summary |
| 8 | + |
| 9 | +This RFC proposes that crates.io should provide insight into vulnerabilities and unsound |
| 10 | +API surface based on the RustSec advisory database. |
| 11 | + |
| 12 | +# Motivation |
| 13 | +[motivation]: #motivation |
| 14 | + |
| 15 | +One of the roles that crates.io serves for Rust developers is as a discovery mechanism for library |
| 16 | +packages. As such, it is important that users can quickly assess the quality of a given crate, |
| 17 | +including security considerations such as unsound code/API or known vulnerabilities. |
| 18 | +The RustSec advisory database is a curated database of security advisories for Rust crates, |
| 19 | +which tracks known vulnerabilities, unsound code, and maintenance status of crates. |
| 20 | + |
| 21 | +The Rust ecosystem has a culture of having smaller, focused crates with a clear purpose. |
| 22 | +As a result, many Rust projects have a large number of dependencies, which increases the |
| 23 | +risk of introducing problems in the final artifact via the supply chain of dependencies. |
| 24 | + |
| 25 | +We've seen an increasing number of security issues via transitive dependencies: |
| 26 | + |
| 27 | +* In 2024, some releases of the popular xz-utils package (written in C) contained |
| 28 | + a [malicious backdoor] affecting OpenSSH servers running on the local system. |
| 29 | +* In 2025, a phishing campaign [targeted crates.io users] using the `rustfoundation.dev` domain |
| 30 | + name to impersonate the Rust Foundation and steal maintainer's credentials. |
| 31 | + |
| 32 | +While known actively malicious crates would be deleted from crates.io by the responsible team, |
| 33 | +unintentional vulnerabilities and unsound APIs can still pose a risk to Rust developers. |
| 34 | + |
| 35 | +The Open Source Security Foundation (OpenSSF) has enumerated [Principles for Package Repository |
| 36 | +Security]; while crates.io already addresses many of these, one of these is: |
| 37 | + |
| 38 | +> The package repository warns of known security vulnerabilities in dependencies in the package |
| 39 | +> repository UI. |
| 40 | +
|
| 41 | +The RustSec advisory database tooling already supports exporting advisories in the OSV format. |
| 42 | + |
| 43 | +[malicious backdoor]: https://en.wikipedia.org/wiki/XZ_Utils_backdoor |
| 44 | +[targeted crates.io users]: https://blog.rust-lang.org/2025/09/12/crates-io-phishing-campaign/ |
| 45 | +[Principles for Package Repository Security]: https://repos.openssf.org/principles-for-package-repository-security.html |
| 46 | + |
| 47 | +# Guide-level explanation |
| 48 | +[guide-level-explanation]: #guide-level-explanation |
| 49 | + |
| 50 | +The crates.io website will display information about known vulnerabilities and unsound APIs. |
| 51 | +This might take the form of a Security tab on a crate's page. If there are known vulnerabilities |
| 52 | +for the currently selected version, the tab might be highlighted. The Security tab will be |
| 53 | +there whether there are existing advisories for a crate or not, and the linked page will show |
| 54 | +a message indicating that there are no published advisories if that is the case. |
| 55 | + |
| 56 | +Opening the Security tab for a crate should show a list of advisories that affect the crate, |
| 57 | +including a summary of the issue, a list of affected versions, and links to more information. |
| 58 | +Care should be taken to ensure that the mere existence of past vulnerabilities does not negatively |
| 59 | +impact the perceived quality of a crate; very popular crates are much more likely to have |
| 60 | +vulnerabilities reported against them, simply due to their popularity and the amount of scrutiny. |
| 61 | + |
| 62 | +The Security tab should give Rust developers a quick overview of the security status of a crate, |
| 63 | +and allow them to make informed decisions about whether to use the crate in their projects. |
| 64 | + |
| 65 | +While this information is available today via the RustSec website (including feeds that can |
| 66 | +automatically be consumed by tooling), having this information directly on crates.io would |
| 67 | +make it accessible and visible to a wider audience. |
| 68 | + |
| 69 | +# Reference-level explanation |
| 70 | +[reference-level-explanation]: #reference-level-explanation |
| 71 | + |
| 72 | +The RustSec project publishes a number of Rust crates that can be used to parse and query the |
| 73 | +advisory database, which can be reused in the crates.io codebase. For now, crates.io will only |
| 74 | +display advisories in the UI; we will not be adding API to query RustSec advisories. Downstream |
| 75 | +users who want to consume this data can use the RustSec crates and the [advisory-db repository] |
| 76 | +directly. |
| 77 | + |
| 78 | +[advisory-db repository]: https://github.com/RustSec/advisory-db |
| 79 | + |
| 80 | +# Drawbacks |
| 81 | +[drawbacks]: #drawbacks |
| 82 | + |
| 83 | +The RustSec project is maintained by an independent team of volunteers, so the crates.io Security |
| 84 | +tab will be reflecting data that is maintained by what amounts to a kind of third party. |
| 85 | +The Leadership Council has an [ongoing discussion] on governance for the Secure Code WG that |
| 86 | +governs the RustSec project, which might be relevant to this proposal. |
| 87 | + |
| 88 | +Rust developers might be scared off of using crates that have known vulnerabilities, even if |
| 89 | +those vulnerabilities are not relevant to their use case, or have been fixed in later versions. |
| 90 | +This seems like a reasonable trade-off to me -- we should allow informed users to make decisions |
| 91 | +that are best for their projects. |
| 92 | + |
| 93 | +[ongoing discussion]: https://github.com/rust-lang/leadership-council/issues/140 |
| 94 | + |
| 95 | +# Rationale and alternatives |
| 96 | +[rationale-and-alternatives]: #rationale-and-alternatives |
| 97 | + |
| 98 | +crates.io is the official package repository for the Rust ecosystem, so sharing important security |
| 99 | +context via this interface seems like an effective way to make it accessible to a wide audience. |
| 100 | + |
| 101 | +Widely used tools like [cargo-audit] and [cargo-deny] already provide a way to check for |
| 102 | +security-sensitive issues in a Rust project's dependencies, but these tools are opt-in and require |
| 103 | +users to be aware of them and to run them. They are also more focused on auditing a project's |
| 104 | +existing dependencies rather than helping inform users in the discovery phase. |
| 105 | + |
| 106 | +Alternatively, we might make the RustSec advisory database available directly via cargo. This |
| 107 | +seems mostly unrelated to what crates.io does, and seems like an interesting future possibility. |
| 108 | + |
| 109 | +[cargo-audit]: https://crates.io/crates/cargo-audit |
| 110 | +[cargo-deny]: https://crates.io/crates/cargo-deny |
| 111 | + |
| 112 | +# Prior art |
| 113 | +[prior-art]: #prior-art |
| 114 | + |
| 115 | +Neither npm nor PyPI currently seem to provide support for displaying security advisories. |
| 116 | + |
| 117 | +# Unresolved questions |
| 118 | +[unresolved-questions]: #unresolved-questions |
| 119 | + |
| 120 | +This seems like a relatively straightforward feature with a limited scope. The main questions |
| 121 | +are about the desirability of the feature, the implementation approach, and the governance |
| 122 | +of the source data. |
| 123 | + |
| 124 | +# Future possibilities |
| 125 | +[future-possibilities]: #future-possibilities |
| 126 | + |
| 127 | +In the future, it would be valuable if lockfile updates exposed open vulnerabilities in a |
| 128 | +project's dependency graph in the Cargo CLI, for example on `cargo update` or `cargo check`. |
| 129 | + |
| 130 | +crates.io could extend its existing API to query advisories for a given crate. |
0 commit comments