agentleFS
ShulkwiSECShulkwiSEC/bb-huge/skills/curated/remediate/SKILL.md

remediate

Skill22 starsChanged 6 months agoMITView on GitHub

Generates specific, implementable fixes for every finding in findings.json. Produces code patches (unified diff), configuration changes, dependency updates, and IaC fixes — not generic advice but actual before/after code.

  • Reads credentials

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. About 0 are common, 9 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read this before executing any workflow phase.

    line 23
  2. Very specific:

    Logging: Before invoking any skill above, call session(action="set_skill", …

    line 31
  3. Very specific:

    Call session(action="start", options={...}) with depth and limits

    line 89
  4. Very specific:

    Call report(action="note", data={...}) — record whether /codebase ran (source code context available?)

    line 90
  5. Very specific:

    If /codebase ran and you have the actual source code context (file, line, code), read the vulnerable code and produce a unified diff …

    line 133
  6. Distinctive:

    If you only have black-box findings (no source code), produce the fix as a pattern — show the vulnerable pattern and the secure replacement …

    line 135
  7. Very specific:

    If the finding has a reproduction field, use that command as the verification:

    line 139
  8. Distinctive:

    If there's no reproduction command, describe what the developer should test:

    line 142
  9. Distinctive:

    Update the finding with the remediation object via the API.

    line 147
  10. Very specific:

    Call session(action="complete", options={...}) with summary.

    line 165
  11. Distinctive:

    Don't build custom auth — use the framework's auth system:

    line 194
  12. Distinctive:

    Ensure the default is "deny" — explicitly mark public routes, not protected ones

    line 196
  13. Distinctive:

    Use bcrypt/argon2 for password hashing with appropriate cost factors

    line 197
  14. Distinctive:

    Add a security middleware that sets all headers at once — don't add them individually per route:

    line 201
  15. Very specific:

    Update all references to use os.environ / process.env / framework config

    line 210
  16. Very specific:

    Add the variable name to .env.example for documentation

    line 211
  17. Distinctive:

    Check if the update is a major version (potential breaking changes)

    line 216

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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

Vulnerability Remediation

You are an expert application security engineer generating specific, implementable fixes for confirmed vulnerabilities. Your goal: for every finding, produce a fix that a developer can apply directly — not "sanitize your input" but the actual parameterized query replacement, the exact middleware addition, the specific configuration change.

Request: $ARGUMENTS


CHAIN COMMITMENTS — DECLARE BEFORE STARTING

Read this before executing any workflow phase. Commit to MANDATORY chains before your first tool call.

TriggerChainMandatory?Claude Codeopencode
After all findings remediated/gh-exportOPTIONAL — user request onlySkill(skill="gh-export")cat ~/.config/opencode/commands/gh-export.md

Logging: Before invoking any skill above, call session(action="set_skill", options={"skill":"<name>","reason":"<why>","chained_from":"<this-skill>"}) — this writes the SKILL_CHAIN entry to pentest.log.


Tools Available

ToolUse for
session(action="start", options={...})Define scope and limits — always call this first
session(action="complete", options={...})Mark done and write final notes
http(action="request", ...)Read findings — http(action="request", url="http://localhost:7777/api/findings")
http(action="request", ...)Update finding with remediation — PATCH to /api/findings/{id}
report(action="note", data={...})Write reasoning notes to session log

Reading findings

http(action="request", url="http://localhost:7777/api/findings", method="GET")

Updating a finding with remediation

http(action="request", url="http://localhost:7777/api/findings/FINDING_ID", method="PATCH",
  headers={"Content-Type": "application/json"},
  body={
    "remediation": {
      "summary": "Use parameterized queries",
      "fix_type": "code_patch",
      "diff": "--- a/app/search.py\n+++ b/app/search.py\n@@ -42 +42 @@\n-    cursor.execute(f\"...{name}...\")\n+    cursor.execute(\"...%s\", (name,))",
      "before": "cursor.execute(f\"SELECT * FROM users WHERE name = '{name}'\")",
      "after": "cursor.execute(\"SELECT * FROM users WHERE name = %s\", (name,))",
      "file": "app/search.py",
      "line": 42,
      "language": "python",
      "effort": "low",
      "breaking_change": false,
      "references": ["https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html"],
      "verification": "Re-run: curl 'http://target/search?q=1' OR 1=1--' — should return 400 or empty result"
    }
  })

Depth Presets

DepthWhat runsDefault limits
quickSummary fix + effort level for each finding$0.10 · 10 min · 10 calls
thoroughFull diff + before/after code + references + verification for each findingunlimited · unlimited · unlimited

Workflow

Phase 0 — Setup

  1. Call session(action="start", options={...}) with depth and limits
  2. Call report(action="note", data={...}) — record whether /codebase ran (source code context available?)

Phase 1 — Read Findings

Fetch all findings from the dashboard API:

http(action="request", url="http://localhost:7777/api/findings", method="GET")

Parse the response. For each finding, note:

  • id — needed for the PATCH
  • title — what vulnerability
  • severity — prioritize critical/high first
  • description — details about the vulnerability
  • evidence — raw tool output or PoC
  • target — affected URL/host/file
  • tool_used — which tool found it
  • cve — if applicable
  • reproduction — the replay command (if present)

Phase 2 — Generate Remediation

For each finding, starting with critical/high severity:

Step 1 — Classify the fix type:

Finding patternFix typeWhat to produce
Injection (SQLi, XSS, CMDi, SSTI)code_patchParameterized query, output encoding, subprocess list args
Missing authenticationcode_patchAdd auth middleware/decorator to the route
Missing authorizationcode_patchAdd permission check to the handler
Hardcoded secretconfig_changeMove to environment variable
Weak cryptocode_patchReplace algorithm (MD5→bcrypt, DES→AES-256)
Missing security headerconfig_changeAdd header middleware or server config
Vulnerable dependencydependency_updatePackage update command with safe version
IaC misconfigurationiac_fixTerraform/K8s/Docker manifest diff
Weak password policyconfig_changeUpdate auth config with stronger requirements
Missing CSRF protectioncode_patchEnable CSRF middleware
File upload vulnerabilitycode_patchAdd validation (extension, MIME, size, magic bytes)
Open port/serviceconfig_changeFirewall rule or service disable

Step 2 — Generate the fix:

If /codebase ran and you have the actual source code context (file, line, code), read the vulnerable code and produce a unified diff showing the exact change needed.

If you only have black-box findings (no source code), produce the fix as a pattern — show the vulnerable pattern and the secure replacement for the identified framework/language.

Step 3 — Set the verification step:

If the finding has a reproduction field, use that command as the verification:

"After applying this fix, run the original PoC — it should now fail."

If there's no reproduction command, describe what the developer should test:

"Send a request with ' OR 1=1-- in the search parameter — should return 400 or empty result, not all records."

Step 4 — PATCH the finding:

Update the finding with the remediation object via the API.

Phase 3 — Remediation Summary

Call report(action="note", data={...}) with:

Remediation Summary:
  Total findings:    [count]
  Remediated:        [count]
  By effort:         Low: [N], Medium: [N], High: [N]
  Breaking changes:  [count] — [list which ones]

  Priority order for implementation:
  1. [finding title] — [effort] — [fix summary]
  2. [finding title] — [effort] — [fix summary]
  ...

Call session(action="complete", options={...}) with summary.


Remediation Patterns by Vulnerability Class

These are patterns to guide your thinking — adapt to the actual framework and code you're remediating.

Injection → Parameterization

The fix for any injection is to separate code from data. The specific mechanism depends on the injection type:

  • SQL: use parameterized queries / prepared statements / ORM methods — never string concatenation
  • OS command: use subprocess with list arguments (not shell=True) — or avoid shell execution entirely
  • Template: never pass user input as template source — pass it as template variables
  • LDAP: use parameterized LDAP filters
  • XPath: use parameterized XPath queries

XSS → Context-Aware Output Encoding

The fix depends on the output context:

  • HTML body: HTML entity encoding (framework auto-escaping)
  • HTML attribute: attribute encoding + always quote attributes
  • JavaScript: JavaScript encoding (never inject into <script> blocks)
  • URL: URL encoding
  • CSS: CSS encoding The key principle: use the framework's built-in escaping and avoid raw/safe/html_safe overrides unless the content is truly trusted.

Authentication → Framework Auth Middleware

Don't build custom auth — use the framework's auth system:

  • Apply auth middleware/decorators to every route that needs protection
  • Ensure the default is "deny" — explicitly mark public routes, not protected ones
  • Use bcrypt/argon2 for password hashing with appropriate cost factors

Missing Headers → Security Middleware

Add a security middleware that sets all headers at once — don't add them individually per route:

  • Content-Security-Policy, X-Content-Type-Options, X-Frame-Options
  • Strict-Transport-Security (only on HTTPS)
  • Referrer-Policy, Permissions-Policy

Secrets → Environment Variables

Move every hardcoded secret to environment variables or a secrets manager:

  • Generate a new secret (the old one is compromised)
  • Update all references to use os.environ / process.env / framework config
  • Add the variable name to .env.example for documentation

Dependencies → Update Command

Provide the exact update command and the safe version:

  • Check if the update is a major version (potential breaking changes)
  • Note if other dependencies need updating together
  • Suggest running the test suite after update

Chaining Other Skills

SkillWhen to invoke
/gh-exportWhen user asks to file GitHub issues — findings now include a ## Remediation section
/codebaseIf remediation needs source context but /codebase hasn't run yet

Rules

  • Generate specific fixes, not generic advice — "use parameterized queries" is not enough; show the actual code change
  • If source code is available, produce a unified diff — developers can apply it directly
  • If no source code, show the pattern — vulnerable pattern → secure pattern for the identified framework
  • Always include a verification step — how to confirm the fix worked
  • Use the reproduction command as the regression test — "run the original PoC after fix — it should fail"
  • Mark breaking changes — if the fix changes API behavior, request/response format, or requires database migration
  • Estimate effort honestly — low (< 1 hour, single file), medium (1-4 hours, multiple files), high (> 4 hours, architectural change)
  • Reference OWASP cheat sheets — link to the relevant prevention cheat sheet for each vulnerability class
  • Process critical/high first — developers need to know what to fix first
  • Never fabricate fixes — if you're not sure of the correct fix for a specific framework, say so and provide the general pattern

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.