agentleFS
JSBtechnologiesJSBtechnologies/rustkb/skills/rust-security/SKILL.md

rust-security

Skill0 starsChanged 43 days agoMITView on GitHub

Security guidance for Rust code and projects. Use when reviewing Rust code for security; adding, updating or vetting dependencies (cargo add, Cargo.toml/Cargo.lock changes, cargo-deny/cargo-audit/cargo-vet setup, deny.toml, supply-chain or SBOM work, publishing to crates.io); writing or reviewing `unsafe`, FFI, `Send`/`Sync` impls, transmute or MaybeUninit; handling untrusted input (parsers, network protocols, file uploads, paths, shell commands, SQL, deserialization, regex); choosing or using crypto (TLS/rustls, password hashing, random tokens, encryption, HMAC, JWT); managing secrets and keeping them out of logs; building authn/authz, CORS, CSRF, sessions, rate limits or SSRF-safe fetchers in axum/tower-http services; fuzzing, Miri or sanitizers; and responding to RustSec advisories, yanked or malicious crates.

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. po4yka/rust-skills★ 5same name
    2. adxptived/Rust-Skills★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository4 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Live data beats memory: When the rustkb MCP server is available, use check_advisories for RustSec/OSV lookups on any crate+version you add …

    line 23
  2. Distinctive:

    Every input boundary: size limit, depth limit, no panics, validated types.

    line 81

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

rust-security

Security depth for Rust: supply chain, unsafe review, secure coding against untrusted input, crypto choices, web-service hardening, security testing, and advisory response. General language idioms (including basic unsafe/FFI mechanics) live in rust-idioms; crate selection in rust-ecosystem; project/CI structure in rust-architecture.

Live data beats memory. When the rustkb MCP server is available, use check_advisories for RustSec/OSV lookups on any crate+version you add or audit (never recall advisory status from memory), crate_info for current versions, and search / get_item / explain_lint / rust_release for versioned API docs, lint docs and release notes.

Core rules

Most frequent security mistakes in agent-written Rust, with the rule to apply:

IDRule
SUP-01Gate CI on cargo deny check with a committed deny.toml (advisories, licenses, bans, sources).
SUP-03Commit Cargo.lock; build and test with --locked.
SUP-04Vet every new crate: exact name (typosquats), repo, owners, maintenance, advisories, transitive weight.
SUP-07build.rs and proc macros execute at build time: no secrets in build jobs, don't build untrusted repos with credentials.
UNS-01unsafe_code = "forbid" unless the crate exists to wrap FFI/low-level code.
UNS-02Never use unsafe (raw pointers, transmute, static mut) to get past a borrow-checker error.
UNS-06unsafe impl Send/Sync needs T: Send/T: Sync bounds and a written thread-safety proof.
UNS-07No set_len over uninitialized memory, no MaybeUninit::uninit().assume_init(); use vec![0; n] or spare_capacity_mut.
SEC-02No unwrap/expect/indexing/unchecked arithmetic on untrusted input — panics are DoS.
SEC-03Bound every read, allocation and decompression by a byte/element limit (Read::take).
SEC-05Checked arithmetic and try_from for sizes/money/indices; consider overflow-checks = true in release.
SEC-07No Path::join with user input; cap-std or Component::Normal-only joins.
SEC-08Command::new(prog).arg(x), never sh -c with interpolation; reject leading -.
SEC-09Bind SQL parameters; never AssertSqlSafe(format!(..)) in sqlx; allowlist identifiers.
SEC-11Compare tokens/MACs in constant time (subtle, Mac::verify_slice).
SEC-13Secrets in secrecy types; no derived Debug on String secrets; #[instrument(skip(..))].
CRYPTO-01Never implement crypto primitives, MACs, RNGs or protocols; use vetted high-level APIs.
CRYPTO-04Never disable TLS certificate verification (danger_accept_invalid_certs, always-OK verifiers).
CRYPTO-05Passwords: Argon2id via argon2 (PHC string), in spawn_blocking.
CRYPTO-06Secrets from a CSPRNG (rand::rng(), getrandom::fill), ≥128 bits; never seeded/small RNGs.
WEB-02Authorize every object access (scope queries by owner); 404 for others' objects.
WEB-04CORS with explicit origins; never permissive/mirrored origins with credentials.

Routing

SituationRead
Setting up cargo-deny / deny.toml, cargo-audit, cargo-vet, SBOM, auditable binariesreferences/supply-chain.md
Adding or upgrading a dependency; choosing features; git dependenciesreferences/supply-chain.md (SUP-04..06)
Publishing a crate from CI (trusted publishing, tokens)references/supply-chain.md (SUP-10)
Writing or reviewing unsafe, FFI exports/imports, Send/Sync impls, transmute, MaybeUninit, packed structsreferences/unsafe-review.md
Parsing untrusted bytes/JSON/binary formats; limits, recursion, integer overflowreferences/secure-coding.md (SEC-01..06)
File paths from users, spawning processes, SQL (sqlx/diesel), deserializationreferences/secure-coding.md (SEC-07..10)
Secrets: comparison, storage in memory, logging, Debug impls; temp files and fs racesreferences/secure-coding.md (SEC-11..14)
TLS clients/servers, rustls provider, certificates, reqwest configreferences/crypto.md (CRYPTO-02..04)
Password hashing, random tokens/keys, encryption, HMAC, JWTreferences/crypto.md (CRYPTO-05..08)
axum/tower-http service: auth extractors, IDOR, body limits, timeouts, CORS, CSRFreferences/web-security.md (WEB-01..05)
Rate limiting, security headers, sessions/cookies, error leakage, SSRF, XSSreferences/web-security.md (WEB-06..11)
Fuzzing, property tests for invariants, Miri, sanitizers, Kani, negative authz testsreferences/testing-for-security.md
cargo-deny/audit reports an advisory; yanked crate; reporting or publishing a vulnerability; malicious cratereferences/incident-and-advisories.md

Security review checklist (quick pass)

  1. cargo deny check passes; new dependencies vetted (SUP-04); lockfile committed.
  2. grep -rn "unsafe\|transmute\|static mut\|set_len\|from_raw_parts" — each hit has a // SAFETY: proof that survives the UNS-04 checklist.
  3. Every input boundary: size limit, depth limit, no panics, validated types.
  4. grep -rn "AssertSqlSafe\|format!(.*SELECT\|sh\", \"-c\|danger_\|permissive()" — each hit is justified or fixed.
  5. Secrets: secrecy types, no derived Debug over plain String secrets, instrument skips, constant-time comparisons.
  6. Crypto: no hand-rolled primitives, Argon2id for passwords, CSPRNG tokens, TLS verified.
  7. Web: auth extractor on every protected route, object-level authz, CORS/CSRF/rate limits/body limits configured, generic error bodies.
  8. Tests: fuzz target per parser, Miri for unsafe, negative authz tests.

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.