Skip to main content
LowSupply chainOWASP A05:2021CWE-540

How to fix: Rust Cargo.toml exposed

The response is a Rust crate manifest: a [package] table with an edition key and a [dependencies] table.

Why it matters

The manifest names every direct dependency and the feature flags each is built with, which matters in Rust because features change what code is compiled in. It also exposes any git or path dependency, and a git dependency pointing at a private repository discloses an internal host and the fact that unpublished crates are in the build.

Distinct from a served Cargo.lock, which gives the full resolved transitive tree: the manifest gives the author's intent, including version ranges that will resolve differently on the next build and the feature set that decides which code paths exist. Both are build inputs and neither should be reachable from a compiled binary's deployment.

How to fix it

  1. 1Deploy the compiled binary and its runtime assets only, not the crate source directory.
  2. 2If the manifest named a private git dependency, confirm that repository is not publicly readable.
  3. 3Audit the dependency set with cargo audit now that the list is public.

Code examples

Multi-stage build that ships only the binary

DOCKERFILE
FROM rust:1-slim AS build
WORKDIR /src
COPY . .
RUN cargo build --release

FROM debian:stable-slim
COPY --from=build /src/target/release/app /usr/local/bin/app
CMD ["app"]

Audit the dependency set

bash
cargo audit

References

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

See every supply chain check

Questions

How severe is Rust Cargo.toml exposed?
VulnRadar rates this low 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-toml-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Rust Cargo.toml exposed map to?
It maps to CWE-540. 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.toml 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.toml exposed | VulnRadar