MCPInstall

rust-web-security

Threat-model, implement, review, and test Rust web security, including authentication, object and tenant authorization, sessions, cookies, JWT and OIDC validation, CSRF, CORS, SSRF, input limits, secrets, cryptographic dependency boundaries, audit logging, and negative security tests. Use when users ask to secure or audit Rust web services, tokens, browser transport, multi-tenant access, secret handling, or security incident fixes.

Installs
107
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/full-stack-skills/rust-skills --skill rust-web-security
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads rust-web-security automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Rust Web Security Delivery

Establish attacker, asset, and trust boundaries first; then select crates and middleware. Rust's memory safety does not automatically provide authentication, authorization, protocol enforcement, or business logic security; default to deny all, and use negative testing to prove control is effective.

Confirming the Security Contract

Before modifications:

  • Identify service exposure surfaces, callers, browser/API/service-to-service traffic, and management endpoints;
  • Determine where TLS terminates, which proxies are trusted, and how client IP/host/scheme originates;
  • Define identity providers, authentication protocols, token/session types/lifecycles;
  • Specify roles, scopes, object ownership, tenant boundaries, and sensitive business operations;
  • Manage key storage/renewal for cookies, passwords, API keys, webhooks;
  • Configure CORS, CSRF, redirects, uploads, outbound URLs, and webhook scenarios;
  • Define rate limiting budgets per body size/parallelism/timeout requirements and abuse resistance policies;
  • Establish audit event definitions, privacy standards, compliance needs, and incident response procedures;
  • Lock versions of axum, tower, rustls, cookie crates along with Rust MSRV.

When security requirements are incomplete, explicitly state assumptions and uncovered risks. Do not bypass validation by weakening tests to achieve pass/fail outcomes.

Workflow

1. Establish Attack Surface and Baselines

rustc --version --verbose
cargo metadata --format-version 1
cargo tree -e features
cargo test --all-targets

Enumerate all routes, methods, extractors, middleware proxies callbacks management endpoints outbound requests. Identify authentication context establishment points authorization decision points session/token storage key loading and audit logging locations. Run existing repository security gates; install or upgrade security tools must comply with project constraints.

2. Write Threat Model and Authorization Matrix

Record at minimum:

Asset -> Entry Point -> Trust Boundary -> Attacker Capability -> Control -> Verification Evidence

Construct subject × action × resource × tenant × context matrices for each sensitive operation. Authentication only proves "who"; authorization must verify in every request whether the user can perform this action on that object. Default deny; do not rely solely on login checks or frontend button visibility.

Object-level, attribute-level, and tenant-based authorization details are available at Threat Model and Authorization.

3. Establish Identity in a Single Boundary

  • Use mature IdP/protocols with maintained crates; do not invent token/password protocols yourself;
  • Convert authentication results into minimal Principal/claims contexts;
  • Failures of auth middleware must terminate requests without anonymous identity fallbacks to silent downgrade;
  • Return 401 for missing or invalid credentials, and 403 when identity is known but permissions are denied;
  • Management, internal, and user identities require distinct audiences, scopes, or credentials;
  • For high-risk operations requiring re-authentication, MFA, or transactional confirmation without relying on stale sessions.

4. Correctly Validate Tokens, Sessions, and Passwords

JWT validation must enforce fixed allowed algorithms verifying signatures, issuer, audience, expiry, not-before, token type/scope requirements; different token types require mutually exclusive verification rules with JWKS caching/renewal handling. Decoding headers/claims does not constitute valid authentication.

Cookie sessions should include Secure, HttpOnly flags aligned to threat models for SameSite, minimal Path; typically omit broad Domain. Rotate session IDs after login and privilege escalation; define server-side invalidation and absolute/idle expiration upon logout or revocation.

Password hashing uses maintained password-hashing APIs with Argon2id-like parameters measured per deployment size; avoid generic fast hashes. Expensive KDFs must not block async runtime workers. API keys/tokens should be displayed once, stored in verifiable forms with scope prefixes, expiry, and renewal capabilities. OAuth/OIDC/JWT/session/password/API key details are covered at Authentication Tokens and Sessions.

5. Authorize Each Resource Boundary

  • Authorization inputs include trusted principals, actions, actual resource attributes, and tenant;
  • Query by tenant first, then object/field permissions to prevent BOLA/IDOR attacks;
  • Management roles must have explicit scopes; do not treat is_admin as a global escape hatch;
  • Batch operations authorize per-object or via equivalent database policies;
  • Write DTOs use allowlists preventing mass assignment of sensitive fields like role, tenant, owner;
  • Cached authorization results include policy version, subject, resource, action, and expiration.

Database Row Level Security (RLS) provides defense-in-depth but cannot replace application-level strategies and testing.

6. Harden Browser and Transport Boundaries

  • Enforce full HTTPS coverage with HSTS, certificates, mTLS, and TLS policies validated at the actual termination layer;
  • Trust only forwarded headers explicitly injected by trusted proxies to avoid host/scheme/IP spoofing;
  • CORS defines browser read strategies rather than server-side access control; use precise origin allowlists when credentials are present; Implement CSRF token defenses alongside state-changing cookie-based auth endpoints; rely on SameSite cookies solely to align protection against threats within the specific threat model.

Set Content Security Policy (CSP), frame, content-type, referrer, and cache headers matching the response body type. Apply rate limits on body size, header manipulation, uploads, pagination, parallelism, timeouts, and expensive operations. Prevent SSRF via user-controllable URL/webhook restrictions: limit scheme/host/port; parse all addresses to block private networks/metadata targets; re-verify after redirects.

Outbound responses also enforce size/type/time constraints. See Browser Transport and Input for specific checks.

7. Protect Secrets and Establish Audit

  • Inject secrets from controlled configuration/secret managers into code, image layers, errors, or logs only; use secrecy types to reduce accidental exposure via Debug serialization without claiming memory isolation equivalence;
  • Explicitly define key ID, owner, purpose, algorithm, creation/expiry/renewal/cancellation policies;
  • Mark/sanitize sensitive body content before trace logging; audit login failures, permission denials, policy/role/key changes and high-risk operations.

Audit records must include actor, action, target, outcome, request ID, and timestamp without secrets. Prevent log injection attacks by limiting the number of attacker-controllable labels. Rotating or revoking production keys, sessions, users, tokens alters external state; only explicitly authorized actions may execute these changes.

8. Prove Control via Negative Testing

Cover at least:

  1. Unauthenticated/expired requests with invalid issuer/audience/algorithms/token types;
  2. Tenant-level permission gaps (same tenant vs cross-tenant), object ownership, and field-level privilege escalation;
  3. Session fixation, logout/revoke scenarios, absolute/idle expiration policies;
  4. CSRF/CORS preflight attacks against malicious origins/cookie attributes;
  5. SSRF via private networks, IPv6, DNS multi-address resolution, redirects, non-HTTP schemes;
  6. Large body sizes, slow requests, high concurrency costs and expensive authentication flows;
  7. Error responses leaking trace IDs or audit log secrets;
  8. Dependency vulnerabilities and feature/crypto backend changes.

See Secrets Audit and Testing for test/audit/supply chain documentation.

Common Gates

cargo fmt --all -- --check
cargo check --all-targets
cargo test --all-targets
cargo clippy --all-targets -- -D warnings
cargo audit

cargo audit requires the tool and advisory data to be available. If either is unavailable, report that the audit was not run rather than claiming a pass. Supplement it with cargo deny, DAST, proxy/TLS configuration tests, and authorization-matrix validation according to repository policy.

Completion Criteria

  • Threat model, trust boundaries, and authorization matrices are explicit;
  • All sensitive routes default to deny all and verify object/tenant/action ownership;
  • Tokens/sessions/passwords/API keys use mature protocols with complete verification;
  • TLS/proxies/CORS/CSRF/header/resource limits align with actual deployment configurations;
  • Secrets do not appear in responses/logs; rotation/revoke policies are explicit;
  • Negative testing and dependency audits pass; unverified IdP, proxies, TLS or production configs explicitly marked.

Handoff Boundaries

Primary ResponsibilityOwner
Router, extractor, handler, middleware, shutdown logicrust-web
User/session/tenant/API key persistence and transactionsrust-database
Async KDF isolation, timeouts, cancellation concurrency limitsrust-concurrency
Test layering, fuzz testing coverage/performance gatesrust-testing
Dependency features, crypto backend, build/release configurationrust-cargo-build
Cryptography/FFI/unsafe implementation reviewrust-unsafe-ffi

On-Demand Resources

  • Threat Model and Authorization: Read when designing permissions, tenant boundaries, sensitive business flows.
  • Authentication Tokens and Sessions: Access OIDC/JWT/cookie sessions/passwords/API keys during implementation.
  • Browser Transport and Input: Configure TLS/proxies/CORS/CSRF/header/uploads/SSRF checks when deploying services.
  • Secrets Audit and Testing: Handle secrets, logs, negative testing, dependency audits during implementation.
  • Crypto Dependency Boundaries: Select AEAD/KDF/constant-time/clearing crates; review nonce/transcript/WASM or protocol versions when implementing cryptographic features.
  • Example Scenarios: Read for end-to-end task decomposition templates requiring production-ready examples.

examples/golden-authorization/: Offline compilation and validation of default deny/object/tenant authorization golden tests available here.

FAQ

What does the rust-web-security skill do?

Threat-model, implement, review, and test Rust web security, including authentication, object and tenant authorization, sessions, cookies, JWT and OIDC validation, CSRF, CORS, SSRF, input limits, secrets, cryptographic dependency boundaries, audit logging, and negative security tests. Use when users ask to secure or audit Rust web services, tokens, browser transport, multi-tenant access, secret handling, or security incident fixes.

How do I install rust-web-security?

Run npx skills add https://github.com/full-stack-skills/rust-skills --skill rust-web-security in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/rust-web-security/ (personal) or .claude/skills/rust-web-security/ (project).

Which AI agents can use rust-web-security?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is rust-web-security safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains rust-web-security?

It is published by full-stack-skills in full-stack-skills/rust-skills. It has 107 recorded installs.

More from full-stack-skills/rust-skills

View all →

rust-testing

full-stack-skills/rust-skills

Design, implement, and validate Rust tests, including unit, integration, doctest, compile-fail, property, fuzz, benchmark, coverage, async, concurrency, process, daemon, IPC, terminal, platform, and hardware-facing test strategies. Use when users ask for Rust test architecture, flaky-test diagnosis, coverage gates, benchmarks, trybuild, cargo-nextest, real-process tests, or failure-path verification.

Testing & QA148 installs

rust-concurrency

full-stack-skills/rust-skills

Open the skill to read its SKILL.md instructions.

Backend & APIs137 installs

rust-style-clippy

full-stack-skills/rust-skills

Open the skill to read its SKILL.md instructions.

Backend & APIs137 installs

rust-performance

full-stack-skills/rust-skills

Measure, profile, optimize, and regression-test Rust performance across latency, throughput, CPU, allocations, memory, binary size, and compile time using representative workloads, Criterion, iai-callgrind, cargo-flamegraph, samply, DHAT, heap or pprof tools, cargo-bloat, cargo-llvm-lines, and build timings. Use when users report slow Rust code, high memory or CPU, large binaries, noisy benchmarks, tail-latency regressions, or need performance budgets and evidence-backed optimization.

Backend & APIs135 installs

rust-code-review

full-stack-skills/rust-skills

Review Rust changes for correctness, memory and thread safety, error semantics, unnecessary allocation or cloning, lock scope, API compatibility, test gaps, documentation, and dependency risk, applying the Rust API Guidelines checklist (C-PANIC, C-UNWRAP, C-TRANSMUTE, C-BOOL, C-NEWTYPE, C-COMMON-TRAITS, C-CONVERT, C-SEALED, C-NON-EXHAUSTIVE). Use when reviewing Rust diffs, pull requests, libraries, unsafe boundaries, or production incidents; report actionable findings by severity before summaries, route automated formatting or lint policy to rust-style-clippy, and route API shape decisions (trait sealing, error taxonomy, newtype design, builder patterns) to rust-api-design.

rust-cargo-build

full-stack-skills/rust-skills

Open the skill to read its SKILL.md instructions.

Backend & APIs123 installs

Popular security skills

View category →

azure-compliance

microsoft/azure-skills

Run Azure compliance and security audits with azqr plus Key Vault expiration checks. Covers best-practice assessment, resource review, policy/compliance validation, and security posture checks. WHEN: compliance scan, security audit, BEFORE running azqr (compliance cli tool), Azure best practices, Key Vault expiration check, expired certificates, expiring secrets, orphaned resources, compliance assessment.

OfficialSecurity567K installs

minimal-run-and-audit

lllllllama/rigorpilot-skills

Rigor Run skill for README-first deep learning repo reproduction. Use when the task is specifically to capture or normalize evidence from the selected smoke test or documented inference or evaluation command and write standardized reprooutputs/ files, including patch notes when repository files changed. Do not use for training execution, initial repo intake, generic environment setup, paper lookup, target selection, hidden scientific-meaning changes, or end-to-end orchestration by itself.

Security477.4K installs

seo-audit

coreyhaines31/marketingskills

When the user wants to audit, review, or diagnose SEO issues on their site. Also use when the user mentions "SEO audit," "technical SEO," "why am I not ranking," "SEO issues," "on-page SEO," "meta tags review," "SEO health check," "my traffic dropped," "lost rankings," "not showing up in Google," "site isn't ranking," "Google update hit me," "page speed," "core web vitals," "crawl errors," "indexing issues," "stuck on page 2," "striking distance keywords," "title tag rewrite," "low CTR," "local SEO," "Google Business Profile," or "map pack." Use this even if the user just says something vague like "my SEO is bad" or "help with SEO" — start with an audit. For building pages at scale to target keywords, see programmatic-seo. For adding structured data, see schema. For AI search optimization, see ai-seo.

Security238.7K installs

firebase-security-rules-auditor

firebase/agent-skills

Audits Firebase (Firestore, Cloud Storage) security rules for vulnerabilities, privilege escalation, role bypasses, create vs update inconsistencies, resource exhaustion, type safety, size limits, and hasOnly ownership checks. Use when auditing/reviewing rules, running red-team rule assessments, or scoring against auditor checklists. Don't use for Firebase CLI (login, deploy), Auth, Crashlytics, Remote Config, or database queries.

OfficialSecurity139.1K installs

audit

pbakaus/impeccable

Run technical quality checks across accessibility, performance, theming, responsive design, and anti-patterns. Generates a scored report with P0-P3 severity ratings and actionable plan. Use when the user wants an accessibility check, performance audit, or technical quality review.

Security81.9K installs

competitors

coreyhaines31/marketingskills

When the user wants to create competitor comparison or alternative pages for SEO and buyer-facing use. Also use when the user mentions 'alternative page,' 'vs page,' 'competitor comparison,' 'comparison page,' '[Product] vs [Product],' '[Product] alternative,' 'competitive landing pages,' 'how do we compare to X,' 'competitor teardown,' 'audit our competitor pages,' 'are our comparison pages out of date,' or 'competitive asset audit.' Use this for any content that positions your product against competitors. Covers four formats: singular alternative, plural alternatives, you vs competitor, and competitor vs competitor. For auditing existing claims (not researching competitors from scratch, which is competitor-profiling; not technical SEO on these pages, which is seo-audit), use the asset audit here. For internal battle cards and sales-specific competitor docs, see sales-enablement.

Security79.3K installs