Skip to content

cargo-audit: add binary scan size limits#1

Open
glaziermag wants to merge 6 commits intomainfrom
binary-scan-limits
Open

cargo-audit: add binary scan size limits#1
glaziermag wants to merge 6 commits intomainfrom
binary-scan-limits

Conversation

@glaziermag
Copy link
Owner

@glaziermag glaziermag commented Jan 25, 2026

Hi! My name is Gabriel, and I’m interested in the RustSec project and have been digging into binary scanning limits.

Related upstream issue: rustsec#740

Summary

  • add cargo audit bin CLI flags for max input binary size and auditable payload size
  • enforce a bounded read before parsing auditable data to avoid OOM on very large inputs
  • add a regression test ensuring oversized inputs are rejected

Test plan

  • cargo test -p cargo-audit
  • cargo test --all-features -p cargo-audit
  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-features --exclude=rustsec -- -D warnings
  • cargo clippy --package=rustsec --features=dependency-tree,osv-export,binary-scanning -- -D warnings

Adds configurable limits for binary input size and auditable payload size to avoid OOM risks when scanning binaries.
Avoids a semver-breaking change to AuditConfig by applying binary scan limits directly on the auditor. Adds a default 100MB input cap (0 disables) and supports overriding the auditable payload limit.
Add a regression test which ensures `cargo audit bin --max-binary-size` rejects oversized inputs.
@djc
Copy link

djc commented Jan 26, 2026

You filed this against your fork. If you intend to upstream these changes, you'll want to submit a PR against the upstream repo. Please squash all your commits before doing so.

@glaziermag
Copy link
Owner Author

Thanks! I’ve upstreamed this as a single squashed commit PR: rustsec#1516 (rustsec#1516). I’ll follow up there going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants