Skip to main content
MediumSupply chainOWASP A05:2021CWE-200

How to fix: Rust Cargo.lock Exposed

A Cargo.lock file was found publicly accessible. Rust's lock file pins the exact version and source of every crate in the dependency tree, including transitive dependencies not listed in Cargo.toml.

Why it matters

Exact crate versions let an attacker cross-reference RustSec's advisory database for known vulnerabilities without any guessing, the same reconnaissance shortcut an exposed package-lock.json or Gemfile.lock provides for other ecosystems.

Cargo.lock is meant to travel with the source repository for reproducible builds, not to be served by the compiled web application. It normally ends up web-accessible only when a build's output directory is set to the project root instead of a dedicated public/dist folder.

How to fix it

  1. 1Block access to Cargo.lock in your web server or reverse proxy configuration.
  2. 2Verify your deployment copies only the compiled build output, not the full repository checkout, to the web root.
  3. 3Audit for other Rust project files (Cargo.toml, src/) that may be similarly exposed.

Code examples

Nginx deny rule

nginx
location ~* /(Cargo\.(lock|toml))$ {
  deny all;
  return 404;
}

References

Detected automatically by VulnRadar. The check id is supply-chain-cargo-lock-exposed, stable across every scan so you can filter or diff on it.

See every supply chain check

Questions

How severe is Rust Cargo.lock Exposed?
VulnRadar rates this medium severity in the supply chain category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id supply-chain-cargo-lock-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Rust Cargo.lock Exposed map to?
It maps to CWE-200. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for rust cargo.lock exposed

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Rust Cargo.lock Exposed | VulnRadar