FAQ - Help and questions

What do I do when an advisory affects a crate I cannot update yet?

#security#cargo-deny#rustsec#supply-chainpublished 0 replies0 views
ReplyWatch
Share
Hacker NewsRedditLinkedInE-mail

Short answer

Read the advisory to see whether your code reaches the affected function, look for a fixed version or an alternative crate, and only then record an ignore entry that names the advisory ID, a reason and a date to review. An ignore without a reason or an end date turns a known risk into a forgotten one.

Checked with cargo-deny 0.20.2, rustc 1.93.0, Windows 11

Frequently asked question, written and answered by the Ruststudio team. Replies are open: corrections are welcome.

#1

Answer#

Sometimes the fixed version needs a newer compiler, a breaking change in your own code, or does not exist (an abandoned crate). Silencing the tool is acceptable only as a decision with a record.

Work through these questions in order:

  1. Is there a fix? The advisory page lists patched versions. cargo update -p <crate> may be enough.
  2. Is the vulnerable crate pulled in by another crate? cargo tree -i <crate> shows who depends on it; updating or replacing that parent may remove it.
  3. Does your code reach the affected part? Advisories name the affected functions or platforms. The advisory behind the example below says that the problem only affects non-Windows targets.
  4. Can you remove the dependency, or use an alternative crate?
  5. If none of that is possible now: ignore it explicitly, with a reason and a review date.

Ignoring in deny.toml (the format of cargo-deny 0.20.2, as tested on the advisory from the cargo audit thread):

deny.tomltoml
[advisories]
version = 2
ignore = [
    { id = "RUSTSEC-2020-0071", reason = "demo only: the affected function is not called, re-check by 2027-03-01" },
]

With that file, cargo deny check advisories on the test project printed:

text
advisories ok

and without the ignore entry the same command reported error[vulnerability] with the advisory ID. The reason text is free text; the review date inside it is a convention that you must enforce yourself, for example with a calendar reminder or a CI step.

How to do it#

  1. Keep ignores in one file under version control, reviewed like code.
  2. Write why it does not apply, and who decided.
  3. Set a date to look again. Remove the entry as soon as a fix exists.
  4. Mention it in release notes if users could be affected.

Common mistakes#

  • Ignoring by crate instead of by advisory ID: a later, different advisory for the same crate is then hidden.
  • Leaving an ignore in place for years.
  • Judging severity from the score alone. The context (what the code does with untrusted data) matters more.

Can I run the check without failing the build on warnings?#

Yes, cargo-deny lets you set the level (deny, warn, allow) for several categories in deny.toml. Keep vulnerabilities at deny.

Who should be allowed to add an ignore?#

Anyone through a pull request, but with a reviewer who is not the author. The file is a record of accepted risk.

Sources#

    QuoteReply
    Share
    Hacker NewsRedditLinkedInE-mail

    No replies yet