Safeguard
Developer Tools•

How do I update one vulnerable crate without touching the rest?

Use cargo update with a crate name and the precise option to move one dependency to a patched version while leaving the rest of Cargo.lock alone.

Safeguard Security Team
3 min read

Run cargo update crate_name --precise 1.2.3 to move one dependency in Cargo.lock to a specific patched version. With a name given, Cargo performs a conservative update: only that crate changes, and its own dependencies change only if they must. Preview with the dry run option first.

When you need this

An advisory says versions below 1.2.3 are affected. Your lockfile has 1.2.1. You want the fix without a surprise update of forty other crates in the same pull request, because a big lockfile diff is hard to review and hard to roll back.

Steps

  1. Find the patched version in the advisory. Confirm it is not yanked.
  2. Check that your version requirement allows it. A requirement of 1.2 accepts 1.2.3, but a pinned =1.2.1 does not, and you would need to edit Cargo.toml.
  3. Preview the change:
cargo update crate_name --dry-run
  1. Apply the precise update:
cargo update crate_name --precise 1.2.3
  1. Rebuild and run tests, then re-run your advisory check.
  2. Commit the lockfile change alone, with the advisory ID in the message.

What the options do

OptionEffect
a crate nameConservative update of that crate only
preciseSets the exact version, and for git dependencies can be a revision
recursiveAlso forces its dependencies to update (cannot be combined with precise)
dry-runShows changes without writing the lockfile
lockedFails if the lockfile would change, which suits CI

The documentation says you can select a yanked version with precise, but advises against it.

When it will not work

If a parent crate pins the vulnerable crate to an older range, Cargo cannot move it without breaking that requirement. Then you have three options: update the parent, use a patch section to point at a fixed copy, or accept the risk with a written reason and an expiry. To find the parent, use the inverted tree view for that crate.

Why this is a good habit

Small, single purpose lockfile changes are easy to review, easy to revert and easy to connect to an advisory in your audit trail. They also keep fix pull requests from becoming a mixed bundle that nobody wants to approve.

Try it yourself

Click through it at your own pace, or open it full screen. Look at how a known fix version is turned into a small change.

Quick check

Does precise change Cargo.toml?

No. It edits the lockfile only, within the range your manifest already allows.

Can I use precise and recursive together?

No. The documentation says they cannot be combined.

Safeguard autonomous remediation can open fix pull requests with evidence. It is off by default and every category starts on Manual, so changes need your approval. A free scan is at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.