Remediate

From ShulkwiSEC/bb-huge · View interactive version

Remediate is an AI agent skill from the GitHub repository ShulkwiSEC/bb-huge. 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. Uses the reproduction command from each finding as the verification step: "run

How to use this skill

Skill file

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.

| Trigger | Chain | Mandatory? | Claude Code | opencode |

|---------|-------|-----------|-------------|---------|

| After all findings remediated | /gh-export | OPTIONAL — user request only | Skill(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

| Tool | Use 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

| Depth | What runs | Default limits |

|-------|-----------|----------------|

| quick | Summary fix + effort level for each finding | $0.10 · 10 min · 10 calls |

| thorough | Full diff + before/after code + references + verification for each finding | unlimited · 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:

Phase 2 — Generate Remediation

For each finding, starting with critical/high severity:

Step 1 — Classify the fix type:

| Finding pattern | Fix type | What to produce |

|----------------|----------|----------------|

| Injection (SQLi, XSS, CMDi, SSTI) | code_patch | Parameterized query, output encoding, subprocess list args |

| Missing authentication | code_patch | Add auth middleware/decorator to the route |

| Missing authorization | code_patch | Add permission check to the handler |

| Hardcoded secret | config_change | Move to environment variable |

| Weak crypto | code_patch | Replace algorithm (MD5→bcrypt, DES→AES-256) |

| Missing security header | config_change | Add header middleware or server config |

| Vulnerable dependency | dependency_update | Package update command with safe version |

| IaC misconfiguration | iac_fix | Terraform/K8s/Docker manifest diff |

| Weak password policy | config_change | Update auth config with stronger requirements |

| Missing CSRF protection | code_patch | Enable CSRF middleware |

| File upload vulnerability | code_patch | Add validation (extension, MIME, size, magic bytes) |

| Open port/service | config_change | Firewall 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:

XSS → Context-Aware Output Encoding

The fix depends on the output context:

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:

Missing Headers → Security Middleware

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

Secrets → Environment Variables

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

Dependencies → Update Command

Provide the exact update command and the safe version:


Chaining Other Skills

| Skill | When to invoke |

|-------|----------------|

| /gh-export | When user asks to file GitHub issues — findings now include a ## Remediation section|

| /codebase | If remediation needs source context but /codebase hasn't run yet |


Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.