54 releases

0.21.0 Oct 29, 2024
0.21.0-pre.0 Jul 30, 2024
0.20.1 Aug 16, 2024
0.20.0 Feb 16, 2024
0.2.0 Mar 6, 2017

#73 in Cargo plugins

Download history 15450/week @ 2024-08-01 14632/week @ 2024-08-08 16229/week @ 2024-08-15 16724/week @ 2024-08-22 16454/week @ 2024-08-29 16589/week @ 2024-09-05 15379/week @ 2024-09-12 15821/week @ 2024-09-19 16958/week @ 2024-09-26 17535/week @ 2024-10-03 20228/week @ 2024-10-10 18170/week @ 2024-10-17 16409/week @ 2024-10-24 17250/week @ 2024-10-31 17174/week @ 2024-11-07 14292/week @ 2024-11-14

68,327 downloads per month
Used in 12 crates (11 directly)

Apache-2.0 OR MIT

355KB
7.5K SLoC

RustSec: cargo audit

Latest Version Build Status Safety Dance MSRV Apache 2.0 OR MIT licensed Project Chat

Audit your dependencies for crates with security vulnerabilities reported to the RustSec Advisory Database.

Requirements

cargo audit requires Rust 1.74 or later.

Installation

Packaging status

cargo audit is a Cargo subcommand and can be installed with cargo install:

$ cargo install cargo-audit --locked

Once installed, run cargo audit at the toplevel of any Cargo project.

Alpine Linux

# apk add cargo-audit

Arch Linux

# pacman -S cargo-audit

MacOS

$ brew install cargo-audit

OpenBSD

# pkg_add cargo-audit

Screenshot

Screenshot

cargo audit fix subcommand

This tool supports an experimental feature to automatically update Cargo.toml to fix vulnerable dependency requirements.

To enable it, install cargo audit with the fix feature enabled:

$ cargo install cargo-audit --locked --features=fix

Once installed, run cargo audit fix to automatically fix vulnerable dependency requirements in your Cargo.toml:

Screenshot

This will modify Cargo.toml in place. To perform a dry run instead, which shows a preview of what dependencies would be upgraded, run cargo audit fix --dry-run.

cargo audit bin subcommand

Run cargo audit bin followed by the paths to your binaries to audit them:

Screenshot

If your programs have been compiled with cargo auditable, the audit is fully accurate because all the necessary information is embedded in the compiled binary.

For binaries that were not compiled with cargo auditable it will recover a part of the dependency list by parsing panic messages. This will miss any embedded C code (e.g. OpenSSL) as well as roughly half of the Rust dependencies because the Rust compiler is very good at removing unnecessary panics, but that's better than having no vulnerability information whatsoever.

Ignoring advisories

The first and best way to fix a vulnerability is to upgrade the vulnerable crate.

But there may be situations where an upgrade isn't available and the advisory doesn't affect your application. For example the advisory might involve a cargo feature or API that is unused.

In these cases, you can ignore advisories using the --ignore option.

$ cargo audit --ignore RUSTSEC-2017-0001

This option can also be configured via the audit.toml file.

Using cargo audit on Travis CI

To automatically run cargo audit on every build in Travis CI, you can add the following to your .travis.yml:

language: rust
cache: cargo # cache cargo-audit once installed
before_script:
  - cargo install --force --locked cargo-audit
  - cargo generate-lockfile
script:
  - cargo audit

Using cargo audit on GitHub Action

Please use audit-check action directly.

Reporting Vulnerabilities

Report vulnerabilities by opening pull requests against the RustSec Advisory Database GitHub repo:

Report Vulnerability

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~8–18MB
~238K SLoC