When you review a Rust dependency on GitHub, you are reading its source. When cargo build runs, it compiles the .crate artifact downloaded from crates.io — a separate upload. Those two are not guaranteed to be the same bytes, and nothing in the normal workflow checks that they are.

That gap is exactly what the onering attack (June 2026) used: a malicious build.rs build script was slipped into the published artifact while never appearing in the crate's public git history. Anyone auditing the repository saw clean code; anyone who ran cargo build executed the injected script at compile time.

cargo-witness is a small, zero-cost tool that closes that gap. It downloads the exact .crate Cargo would install, extracts it, and diffs it against the crate's real source.

What it verifies against

The hard part is deciding which source to compare against. cargo-witness uses the strongest anchor available, in order: