agentleFS
mn-youssefmn-youssef/security-skills/skills/security-hardening/SKILL.md

security-hardening

Skill47 starsChanged 6 months agoMITView on GitHub

Use when you have a security finding (from code audit or pentest) and need to fix it correctly with secure-coding patterns, then verify the fix actually closes it. Covers fixes for injection, access control, XSS, auth, secrets, and config across the stack.

19 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use websocket-realtime, rust-systems and 5 more.

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.
  • rohitg00Skill

    websocket-realtime

    Real-time communication patterns with WebSocket, Socket.io, Server-Sent Events, and scaling strategies

    Also in 3 projects that use this

  • rohitg00Skill

    rust-systems

    Rust systems programming patterns including ownership, traits, async runtime, error handling, and unsafe guidelines

    Also in 3 projects that use this

  • dylantarreSkill

    performance-optimization

    Use when animation runs slow, janky, or causes frame drops

    Also in 5 projects that use this

  • MicrosoftSkill

    api-design

    Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.

    Also in 3 projects that use this

  • Microsoft AzureSkill

    git-workflow

    Squad branching model: dev-first workflow with insiders preview channel

    Also in 3 projects that use this

  • +2 more from rohitg00

The file

Files
SKILL.md

Security Hardening (FIX phase)

Overview

Turn findings into correct, verified fixes. Fix the root cause at the right layer, add defense in depth, then re-test to prove the hole is closed.

Core principle: A fix you didn't re-test is a hope, not a fix. Reproduce the original exploit and confirm it now fails.

Process per finding

  1. Root cause — why is untrusted data reaching the sink? Fix there, not by blocklisting symptoms.
  2. Apply the secure pattern — see table below.
  3. Defense in depth — add a second independent control (validation + parameterization, etc.).
  4. Re-test — rerun the exact PoC from active-pentest/the audit; confirm it fails now.
  5. Regression — add a test so it can't silently come back.

Secure-pattern quick reference

VulnerabilityRoot-cause fixDefense in depth
SQL/NoSQL injectionParameterized queries / ORM bindings; allowlist dynamic identifiersLeast-privilege DB user; input validation
Command injectionAvoid shell; use exec arrays / safe APIs; no shell interpolationAllowlist args; drop privileges
XSSContext-aware output encoding; framework auto-escape; textContentCSP; sanitize HTML (DOMPurify); HttpOnly cookies
Broken access control / IDOREnforce authz server-side on every action; scope queries to the userDeny-by-default; centralized policy checks
Mass assignmentExplicit allowlist of bindable fields (DTO/schema)Separate read/write models
Broken authbcrypt/argon2; CSPRNG tokens; rotate session on loginMFA; rate limit; short token TTL + revocation
Crypto failuresVetted libs; AES-GCM; TLS everywhere; no homemade cryptoKey management/rotation; HSTS
SSRFAllowlist destinations; resolve+validate; block metadata/internal IPsEgress firewall; no raw URL fetch
Insecure deserializationSafe formats (JSON); yaml.safe_load; signed payloadsType allowlists; isolation
Secrets in codeMove to env/secret manager; rotate the exposed secretSecret scanning in CI; short-lived tokens
Security misconfigDisable debug; least-priv CORS; remove default credsHardened baseline; config review in CI
Mobile insecure storageKeychain/Keystore + encryptionPinning; no secrets in binary

Validation rules of thumb

  • Validate on the server — client validation is UX, not security.
  • Allowlist > blocklist — define what's permitted, reject the rest.
  • Encode for the sink, not the source — same data needs different encoding per context.
  • Fail closed — deny by default; an error should not grant access.

Re-test gate (don't skip)

[ ] Re-ran the original PoC → it now fails / is blocked
[ ] Added an automated regression test
[ ] Checked the fix didn't just move the sink elsewhere
[ ] Verified no similar instances exist (grep the pattern across the codebase)

Output

For each finding: root cause · the fix (diff/pattern) · re-test result (PoC now fails) · regression test added. Update the findings register status → Closed.

Common mistakes

  • Patching the one reported line while identical sinks remain elsewhere — grep for siblings.
  • Blocklist filters (e.g. stripping <script>) that attackers trivially bypass.
  • Client-side-only fixes for server-side problems.
  • Marking "fixed" without rerunning the exploit.

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.