Safeguard
Compliance•

How do I write a license allow list for Rust crates?

Build a cargo deny license policy: an SPDX allow list, per-crate exceptions, clarify entries for unclear files, and how private crates are treated.

Safeguard Security Team
3 min read

List the SPDX license identifiers your company accepts in the allow key of the [licenses] table in deny.toml. Anything not listed is denied. Use exceptions for one crate that needs a different license, and clarify when a crate has no machine readable license data.

Start from legal, not from the tool

The tool enforces a list. Someone has to decide the list. Ask legal or the person who owns open source policy which licenses are acceptable for your distribution model, because the answer differs for a SaaS service, a shipped binary and an internal tool. Then translate it into identifiers.

The keys

KeyWhat it does
allowSPDX identifiers you permit, including forms such as Apache-2.0 WITH LLVM-exception
confidence-thresholdMinimum score to trust detection from a license file, default 0.8
exceptionsExtra licenses allowed for a named crate only
clarifyHand assigned license expression, tied to the hash of a license file
privateControls whether unpublished workspace crates are checked
unused-allowed-licenseWarn, allow or deny when an allowed license never appears

Defaults worth knowing: dev dependencies are not included, build dependencies are, and unlisted licenses are denied. A WITH exception is treated as different from the bare license, so list both if you accept both.

Example

[licenses]
confidence-threshold = 0.95
allow = ["MIT", "Apache-2.0", "BSD-3-Clause"]

[[licenses.exceptions]]
allow = ["Zlib"]
name = "some-crate"

[licenses.private]
ignore = true

The crate name here is a placeholder. Real exceptions should name a real crate and carry a comment saying who approved it.

Why clarify is safer than ignoring

When a crate ships an unusual license file, you can state the expression yourself and bind it to the file hash. If the file changes in a later release, the hash no longer matches and the clarification stops applying, so the check fails and a human looks again. That is the behavior you want.

Steps

  1. Get the approved license list from legal.
  2. Run cargo deny check licenses and read the failures.
  3. Add accepted identifiers to allow.
  4. For each remaining failure, decide: replace the crate, add an exception, or clarify.
  5. Mark unpublished workspace crates as private so they do not fail.
  6. Gate pull requests on the check.

Try it yourself

Click through it at your own pace, or open it full screen. Look at how one control maps to several compliance frameworks.

Quick check

Is a license check legal advice?

No. It enforces the list your counsel approves. Detection can be wrong, so keep the confidence threshold high and review exceptions.

Should dev dependencies be checked?

By default they are not. Include them if your tests or tools are distributed with your product.

Safeguard compliance and evidence automation can collect dependency inventory and policy results for audits, and you can try a free scan 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.