How to check your Cargo.lock for vulnerabilities with cargo audit
- Steps
- 6
- Hands-on
- 10 min
- Reading
- 7 min
- Checked
- Oct 26
The short version
Install cargo-audit once (cargo install cargo-audit --locked), then run cargo audit next to your Cargo.lock. It matches every crate version in the lockfile against the RustSec advisory database and exits with code 1 when it finds a known vulnerability, which makes it a one-line CI gate. We ran it on nine of our own lockfiles on October 26, 2026: 35 vulnerabilities in 4 of 9, 24 of them in one 484-crate project. Fixing most of them took cargo update.

What you need
- A Rust project with a Cargo.lock
- Rust and Cargo installed
- Internet access to fetch the RustSec database (or a local copy)
Part of the article OpenClaw got 591 advisories. 1 in 4 top npm installs is the real hole. This page answers one question from it in depth.
On this page · 12 sections
Rust's safety story is about memory, not about your supply chain. A typical service pulls in hundreds of crates you never chose, and the bugs that matter in 2026 live in that layer: TLS, HTTP/2, QUIC. The tooling to see them is free and takes ten minutes. Nobody is going to run it for you, and the vendors selling "software supply chain platforms" for five figures a year are mostly reselling the same open database. We covered the npm side of this in OpenClaw's advisories and the npm supply chain; this is the Rust version, with our own numbers.
Rather not install anything? Our Cargo.lock check runs the same kind of match in your browser: paste or drop the file, and nothing is uploaded.
Before you start
cargo audit reads Cargo.lock, not Cargo.toml. The lockfile holds the exact versions you build, including dev-dependencies and every transitive crate. If a library repo does not commit its lockfile, run cargo generate-lockfile first so there is something to scan. The scan checks known advisories only: it will not find a bug nobody has reported yet.
Step 01: Install cargo audit
cargo install cargo-audit --locked
This compiles the tool from crates.io and adds cargo audit as a subcommand. We used version 0.22.1. On a slow or low-memory machine the build takes a few minutes; it is a one-time cost.
Step 02: Scan the lockfile
cargo audit
The first run clones the RustSec database into ~/.cargo/advisory-db. Ours loaded 1,378 advisories. To scan a lockfile somewhere else, point at it:
cargo audit -f path/to/Cargo.lock
Our nine lockfiles held 2,330 package entries between them. Each scan took a couple of seconds once the database was local.
Step 03: Read the report
Our run on the Tokio Prompt lockfile, Oct 26 2026. Trimmed between the second finding and the summary; the database path is shortened.
Every finding has the same shape: Crate, Version, Title, Date, ID, URL, a Solution line with the first fixed version, and the Dependency tree that explains how it got into your build. Read the tree first. It tells you whether you can fix it with a lockfile bump or need to change a direct dependency.
What our worst lockfile actually had:
| Crate in our lockfile | Advisories | First fixed version | What it is |
|---|---|---|---|
| rustls-webpki 0.102.8 and 0.103.9 | 5 each | 0.103.16 | Certificate checks: CRLs, name constraints, distrusted intermediates |
| quinn-proto 0.11.14 | 5 | 0.11.18 | QUIC: remote memory exhaustion and panics |
| rustls 0.23.37 | 4 | 0.23.46 | TLS: handshake, secret leak in Debug, downgrade |
| webpki-roots 1.0.6 | 1 | 1.0.10 | Bundled roots trust distrusted emSign intermediates |
| h2 0.4.13 | 1 | 0.4.16 | HTTP/2: unbounded empty DATA frames |
| rmcp 0.16.0 | 1 | 1.4.0 | DNS rebinding in the MCP HTTP transport |
| protobuf 2.28.0 | 1 | 3.7.2 | Crash from uncontrolled recursion |
| crossbeam-epoch 0.9.18 | 1 | 0.9.20 | Invalid pointer dereference in a fmt impl |
Source: cargo audit 0.22.1 output, RustSec IDs RUSTSEC-2026-0049 through RUSTSEC-2026-0382 plus RUSTSEC-2024-0437, Oct 26 2026.
Two patterns jump out. The TLS stack carries most of it: 15 of the 24 findings sit in rustls, rustls-webpki and webpki-roots, and 6 of those were published in the last two weeks (Oct 14 to Oct 20). And dev-dependencies count: the crossbeam-epoch finding came in only through criterion, a benchmark crate. It never ships in the binary, but the scanner cannot know that, so you decide.
Step 04: Fix with cargo update
Most fixes are patch releases inside your existing semver range, so the lockfile is the only thing that changes:
cargo update -p rustls
cargo update -p rustls-webpki
cargo update -p quinn-proto
cargo audit
When the Solution line names a new major version (protobuf 2.x to 3.7.2, rmcp 0.16 to 1.4 above), cargo update cannot get there. Find the parent in the dependency tree and bump it in Cargo.toml, or replace it. That is real work, and it is why old lockfiles rot: the cheap fixes pile up behind one expensive one.
To check one crate before you touch anything, every advisory has a page on our Rust advisory database, for example all rustls advisories.
Step 05: Gate CI on it
cargo audit exits 1 when it finds a vulnerability and 0 when it does not. We confirmed both: the 24-finding lockfile returned 1, the O'BLOCK lockfile returned 0. So in any CI system:
cargo install cargo-audit --locked
cargo audit
The O'BLOCK lockfile still had 2 warnings (paste and ttf-parser are unmaintained). They pass by default. Add -D warnings and they fail the build too; it returned 1 on the same file. Pick on purpose: unmaintained crates are a slow risk, not an emergency.
To accept a finding you have reviewed:
cargo audit --ignore RUSTSEC-2026-0204
or put the ID under [advisories] ignore = [...] in .cargo/audit.toml with a comment saying why.
Step 06: Re-check on a schedule
Your lockfile does not change, but the database does. Of the 24 findings in our worst file, 13 were published after July 1, 2026. Run the scan nightly or weekly, not only on push, or let something do it for you: our Cargo.lock check page shows the database date it used, and the weekly re-check option emails only what changed.
cargo audit vs OSV vs cargo deny
Tokio Prompt lockfile, 484 packages, scanned both ways on Oct 26 2026.
We also sent the same lockfile's 483 registry packages to the free OSV querybatch API. It returned 51 advisory IDs on 17 package versions, against cargo audit's 24 vulnerabilities plus 8 warnings. The gap is mostly bookkeeping, not missed bugs: OSV lists the RUSTSEC id and the GitHub (GHSA) id for the same bug separately, and it includes unsound and unmaintained notices. It also caught one fresh one our local run did not show as a vulnerability: RUSTSEC-2026-0386, an I/O safety issue in tokio's AsyncFd constructors published Oct 13.
- cargo audit: one job, lockfile vs RustSec, clear exit code. Start here.
- cargo deny: advisories plus license, ban, duplicate and source rules from a
deny.toml. Use it when you want one policy gate. - OSV: language-agnostic API, good when one script has to scan Rust, npm and PyPI together.
What goes wrong
- "couldn't fetch advisory database ... packed-refs.lock": a previous run died mid-fetch and left a git lock. We hit this on our own machine. Point at a fresh copy with
--db ./advisory-db, or delete the stale.lockfile once no other cargo audit is running. - No Cargo.lock: libraries often do not commit one. Run
cargo generate-lockfile, scan, and know you are scanning today's resolution, not what your users get. - Offline or air-gapped CI: use
--no-fetchwith a database copy you sync separately. Pair it with cargo vendor for offline builds. - The fix is a major version:
cargo update -pwill say nothing changed. Bump the parent crate in Cargo.toml instead. - A finding in a dev-dependency: real, but it does not ship. Ignore it with a written reason rather than deleting your benchmarks.
Related
- OpenClaw, npm and the advisory flood: the same problem on the JavaScript side.
- Offline Rust builds: almost nobody is shutdown-ready and how to vendor dependencies.
- How to publish a Rust crate: if you maintain one, your users run this scan on you.
- What is IDOR?: the bug class that tops OWASP, and why a clean scan does not mean a safe app.
FAQ
How do I check my Cargo.lock for vulnerabilities?
Install cargo-audit with cargo install cargo-audit --locked, then run cargo audit in the folder that has Cargo.lock. It matches every crate version against the RustSec advisory database and exits with code 1 if it finds a known vulnerability. To skip the install, paste the file into a browser checker such as tensorust.com/tools/cargo-lock-check/.
What is the difference between cargo audit and cargo deny?
cargo audit only checks a lockfile against RustSec advisories. cargo deny also checks advisories, plus license rules, banned crates, duplicate versions and allowed sources, configured in deny.toml. Use cargo audit for a quick scan and cargo deny when you want one policy gate in CI.
Does cargo audit check dev-dependencies?
Yes. It scans every package in Cargo.lock, and the lockfile includes dev-dependencies. In our test, a crossbeam-epoch advisory came in only through criterion, a benchmark dev-dependency.
How do I ignore a cargo audit advisory?
Pass --ignore RUSTSEC-YYYY-NNNN on the command line, or list the ID under [advisories] ignore in .cargo/audit.toml. Write down why next to it, and re-check when a fix ships.
Why does OSV report more vulnerabilities than cargo audit?
OSV returns every alias for the same bug (a RUSTSEC id and a GHSA id), and it includes unsound and unmaintained notices. On our 484-package lockfile OSV returned 51 IDs on 17 package versions, while cargo audit reported 24 vulnerabilities and 8 warnings.
Sources
All checked October 26, 2026.
- RustSec, Advisory Database and rustsec/advisory-db on GitHub: the database cargo audit loads (1,378 advisories in our clone, Oct 26 2026). Individual advisories cited: RUSTSEC-2026-0204, RUSTSEC-2026-0258, RUSTSEC-2026-0382, RUSTSEC-2026-0381, RUSTSEC-2026-0386.
- crates.io, cargo-audit (version 0.22.1 used here), maintained by the Rust Secure Code Working Group.
- OSV, POST /v1/querybatch: the batch API we sent 483 registry packages to on Oct 26 2026.
- Embark Studios, cargo-deny book: what cargo deny checks beyond advisories.
- Our own test: cargo audit 0.22.1 on Windows 11 against nine of our own Cargo.lock files (2,330 package entries), with --json for the counts and exit codes checked with and without -D warnings, October 26, 2026.
- Tensorust, OpenClaw vulnerabilities and npm advisories.
Do this next
Every number on this page links to its source and was checked on Oct 26, 2026. Spot an error or a newer figure? Email matt@tensorust.com and it gets fixed. Related: Cargo.lock check (in your browser), Rust advisory database, Cargo.toml checker.
Read next
- Article · Oct 24, 2026OpenClaw got 591 advisories. 1 in 4 top npm installs is the real hole
- Article · Oct 26, 2026Offline Rust builds: 17,527 downloads, almost nobody is shutdown-ready
- Article · Oct 24, 202634 critical GitHub outages since April. 98% of Rust still lives there
- Guide · Oct 25, 2026UUID as a primary key in Postgres: use uuidv7(), store it as uuid, and measure
- Guide · Oct 25, 2026Cold email deliverability: set up SPF, DKIM and DMARC, then send slower than you think
Get the next one by email.
What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.
No spam, never sold. Every email has a one-click unsubscribe.
