rustsec / rustsec/rustsec

No warning if Cargo.lock is out of date

Open
#322 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2k
Forks
198
Avg merge
2d 6h
Merged PRs (30d)
8

Description

> cargo new foo && cd foo
     Created binary (application) `foo` package
> cargo audit
    Fetching advisory database from `https://github.com/RustSec/advisory-db.git`
      Loaded 251 security advisories (from /home/wim/.cargo/advisory-db)
    Updating crates.io index
    Scanning Cargo.lock for vulnerabilities (1 crate dependencies)
> cargo add pest_derive
    Updating 'https://github.com/rust-lang/crates.io-index' index
      Adding pest_derive v2.1.0 to dependencies
> cargo audit
    Fetching advisory database from `https://github.com/RustSec/advisory-db.git`
      Loaded 251 security advisories (from /home/wim/.cargo/advisory-db)
    Updating crates.io index
    Scanning Cargo.lock for vulnerabilities (1 crate dependencies)

If I then run a command that forces a lockfile update, you can see that both the count of "crate dependencies" increases, and a vulnerability is found:

> cargo metadata --format-version=1 >/dev/null
    Updating crates.io index
> cargo audit
    Fetching advisory database from `https://github.com/RustSec/advisory-db.git`
      Loaded 251 security advisories (from /home/wim/.cargo/advisory-db)
    Updating crates.io index
    Scanning Cargo.lock for vulnerabilities (21 crate dependencies)
Crate:         generic-array
Version:       0.12.3
Title:         arr! macro erases lifetimes
Date:          2020-04-09
ID:            RUSTSEC-2020-0146
URL:           https://rustsec.org/advisories/RUSTSEC-2020-0146
Solution:      Upgrade to >=0.14.0
Dependency tree:
generic-array 0.12.3
├── digest 0.8.1
│   └── sha-1 0.8.2
│       └── pest_meta 2.1.3
│           └── pest_generator 2.1.3
│               └── pest_derive 2.1.0
│                   └── foo 0.1.0
└── block-buffer 0.7.3
    └── sha-1 0.8.2

error: 1 vulnerability found!

IMO cargo audit should follow the cargo-subcommand standard of performing a lockfile update itself if not passed --locked/--offline etc. but at the very least should tell the user if the Cargo.lock is inconsistent with the Cargo.toml.

> cargo audit --version
cargo-audit 0.13.1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the mismatch using the shown cargo new, cargo add, and cargo audit commands, then compare the behavior with and without --locked or --offline. Trace how cargo audit reads Cargo.toml and Cargo.lock; done means it either updates the lockfile under the default behavior or clearly warns when the lockfile is inconsistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.