Email me

Guide · 7 min read

Filed under Rust Guides

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.

Bar chart titled 35 known vulnerabilities in 4 of our 9 Rust lockfiles. cargo audit results: Tokio Prompt 484 crates 24, crypto-orderbook 253 crates 8, fin-stream 211 crates 2, Every-Other-Token 239 crates 1, and zero for chaos-rpg, O'BLOCK, llm-cost-dashboard, corescout and agent-runtime.
cargo audit 0.22.1 against the RustSec database as of Oct 26 2026, run on nine of our own Cargo.lock files. Warnings (unsound, unmaintained, yanked) are not in these counts. Chart by Tensorust from our own cargo audit runs.

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
  1. Before you start
  2. Install cargo audit
  3. Scan the lockfile
  4. Read the report
  5. Fix with cargo update
  6. Gate CI on it
  7. Re-check on a schedule
  8. cargo audit vs OSV vs cargo deny
  9. What goes wrong
  10. Related
  11. FAQ
  12. Sources

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

Terminal capture of cargo audit on a 484-crate lockfile: 1,378 advisories loaded, the crossbeam-epoch RUSTSEC-2026-0204 finding with its Solution line and a dependency tree ending in criterion, the start of the h2 RUSTSEC-2026-0258 finding, and the summary: 24 vulnerabilities found, 8 allowed warnings found. 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

Bar chart titled Same lockfile, two scanners, different counts: cargo audit vulnerabilities 24, cargo audit warnings 8, OSV querybatch advisory IDs 51, OSV package versions hit 17. 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.
Troubleshooting

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 .lock file 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-fetch with a database copy you sync separately. Pair it with cargo vendor for offline builds.
  • The fix is a major version: cargo update -p will 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.

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.

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

Back to The Manual →   All articles →

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.

Up next

The article this answer comes fromOpenClaw got 591 advisories. 1 in 4 top npm installs is the real holeOpen-source advisories tripled in 2026 and AI tools are 15.5% of them. OpenClaw has 591, but 24.7% of top npm installs carry a fixed high-severity hole.Read it next →

Art: Nicholas Roerich, Depsang Plains (1925-26). Public domain, via Wikimedia Commons.

Get the receipts 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.

Did this answer your question?

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ

What are people saying about this? Read and post on The Floor →