50 releases

0.20.0 Feb 16, 2024
0.18.3 Oct 24, 2023
0.17.6 May 10, 2023
0.17.5 Mar 23, 2023
0.2.0 Mar 6, 2017

#62 in Cargo plugins

Download history 12838/week @ 2024-01-03 13334/week @ 2024-01-10 13900/week @ 2024-01-17 13295/week @ 2024-01-24 14944/week @ 2024-01-31 15094/week @ 2024-02-07 15386/week @ 2024-02-14 14551/week @ 2024-02-21 14808/week @ 2024-02-28 15177/week @ 2024-03-06 18100/week @ 2024-03-13 17068/week @ 2024-03-20 12366/week @ 2024-03-27 14306/week @ 2024-04-03 14221/week @ 2024-04-10 11011/week @ 2024-04-17

54,348 downloads per month
Used in 14 crates (13 directly)

Apache-2.0 OR MIT

345KB
7K 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.70 or later.

Installation

Packaging status

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

$ cargo install cargo-audit

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 --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 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
~275K SLoC