agentleFS
gurinderugurinderu/craft/skills/rust-security/SKILL.md

rust-security

Skill1 starsChanged 40 days agoMITView on GitHub

Rust security review — dependencies for known vulnerabilities (cargo-audit/RUSTSEC), licenses and supply chain (cargo-deny), unsafe surface (cargo-geiger), and code patterns (semgrep). Approve only when every tool ran locally clean; a tool that did not run caps it at Warning, a red CI check blocks, a green one only informs. Use when security-reviewing a Rust project, vetting dependencies, checking for vulnerable crates or license issues, or setting up a security gate. Triggers: CVE, RUSTSEC, cargo-audit, cargo-deny, cargo-geiger, semgrep.

  • Reads credentials

5 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use rust-debugging.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • DankosikSkill

    rust-debugging

    Causality. Use for an uncertain Rust CLI defect, panic, hang, incorrect output, resource leak, or platform-dependent failure.

    Also in 3 projects that use this

The file

Files
SKILL.md

Rust Security

The security pass over a Rust project: vet what you depend on, measure your unsafe surface, and scan code for dangerous patterns. The craft:rust-security-scanner agent runs this and reports; this skill is the rubric. Tool usage and config are in tools.md.

When to Use

  • Security review of a Rust project or PR
  • Vetting dependencies (vulnerabilities, licenses, supply chain)
  • Setting up a security gate in CI
  • Auditing the unsafe footprint

Threat areas and tools

AreaWhat goes wrongTool
Vulnerable depsa dependency has a known CVE/RUSTSEC advisorycargo audit
Supply chain & policybad license, yanked/duplicate/banned crate, untrusted sourcecargo deny
Unsafe surfacehow much unsafe you and your deps pull incargo geiger
Code patterns / taintinjection, hardcoded secrets, banned APIs, tainted input → sinksemgrep (+ clippy)
App-level (in the diff)SQL/command injection, path traversal, unbounded deserialization, secrets in sourcerust-review (CRITICAL — Safety)

These are complementary: cargo audit/deny look at what you depend on, geiger at unsafe exposure, semgrep/clippy at your code. Run all of them.

Severity & verdict

Same shape as rust-review:

VerdictWhen
Block ⛔a vulnerable dep with a known exploit/fix available; a real injection/secret/taint finding; a denied license; a red CI audit/deny check, even when no tool ran locally
Warning ⚠️advisories with no fix yet (mitigate/track), unmaintained-crate warnings, high unsafe surface; a partial scan — a tool not installed, timed out or broken locally (name each one)
Approve ✅every tool (cargo audit, cargo deny, cargo geiger, semgrep) ran locally and came out clean, no high-confidence code findings

CI informs, never certifies: a red CI check that runs a tool blocks, a green one is reported (CI green for <check>) but never stands in for a tool that did not run here — that tool's signal stays unknown, so the verdict is at most Warning, never Approve.

Report each finding as severity · source(tool) · what · why exploitable · fix/mitigation.

Triage — signal vs noise

  • RUSTSEC advisory with a fixed version → bump it; that's the easy win.
  • Advisory with no fix → assess reachability (do you call the affected path?), pin/patch, or replace the crate; if truly unreachable, document an allow with an expiry, don't ignore silently.
  • Unmaintained crate (RUSTSEC-…-unmaintained) → warning, plan a migration; not an emergency.
  • semgrep finding → confirm the source is actually attacker-controlled and reaches the sink before calling it real (taint can over-report); adversarially verify like any review finding.
  • unsafe in a dependency → geiger counts it; high counts warrant reading the crate's safety story, not automatic rejection.

Custom rules are the point of semgrep

clippy/audit catch the known; semgrep encodes your rules — banned APIs, "never log this type", "don't build SQL with format!", taint from request body to a command. That's its edge over the Rust-native tools (which it complements, not replaces). Examples in tools.md.

Handling secrets in memory

Scanning for hardcoded secrets (above) is only half the job — secrets that legitimately live in memory (API keys, tokens, passwords loaded from env) must not leak via Debug/logs, linger in memory, or land in core dumps/swap. Wrap them in secrecy:

[dependencies]
secrecy = "0.10"
use secrecy::{SecretString, ExposeSecret};

struct Config { api_key: SecretString }     // Debug is redacted (no secret bytes printed)

let key = SecretString::from(std::env::var("API_KEY")?);
client.authenticate(key.expose_secret());   // .expose_secret() is the only way out — greppable
  • SecretBox<T> / SecretString give a redacted Debug (a secret can't accidentally end up in a log line or error) and zeroize the memory on drop (via zeroize, so it doesn't linger).
  • expose_secret() is the single, searchable point where the raw value is accessed — easy to audit and to lint.
  • Load secrets straight into a SecretString at the config boundary (→ rust-cloud-native / rust-cli config); never put a raw String secret on a struct that derives Debug/Serialize.

zeroize (zeroize = "1") is the lower-level primitive if you need to scrub a buffer (keys, decrypted plaintext) without the secrecy wrapper.

Boundaries

  • Reviewing the diff's code for correctness + safety smells → rust-review (this skill is the tooling/supply-chain layer; they share the verdict vocabulary).
  • Soundness of your own unsafe (invariants, UB) → rust-unsafe; verify it with the craft:rust-miri agent.
  • Dependency freshness/unused (not security) → rust-ecosystem.
  • Fuzzing parsers / deserializers / any untrusted-input surface for panics and crashes (cargo-fuzz) → rust-testing.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.