CommunityCodierung & Entwicklunggithub.com

threat-model-remediate

Implement idiomatic, defense-in-depth code and configuration fixes for security findings identified in a threat model (docs/THREAT-MODEL.md), add automated security regression tests, and update the threat model with verification evidence and residual risk. Use when fixing issues discovered during threat modeling.

Was ist threat-model-remediate?

threat-model-remediate is a Claude Code agent skill that implement idiomatic, defense-in-depth code and configuration fixes for security findings identified in a threat model (docs/THREAT-MODEL.md), add automated security regression tests, and update the threat model with verification evidence and residual risk. Use when fixing issues discovered during threat modeling.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/jusso-dev/threat-modeling-skills/tree/HEAD/skills/threat-model-remediate

Installed? Explore more Codierung & Entwicklung skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Threat Model Remediate (Question 3: What Are We Going to Do About It?)

Use this skill after threat-model-analyze (or whenever working through an existing docs/THREAT-MODEL.md) to safely fix confirmed vulnerabilities and harden design gaps without introducing regressions.

Core Principles

  1. Fix the bug class, not just one line: Whenever you fix a vulnerability (e.g., BOLA/IDOR, raw SQL, SSRF, mass assignment, missing authz), search sibling routes, handlers, and services for the same pattern and introduce a shared safe helper or guard.
  2. Fail closed, default deny (OWASP A01 / A10:2025): Auth checks, signature verifiers, SSRF validators, and error handlers must deny on error or ambiguity.
  3. Idiomatic & minimal changes: Use the repository's existing libraries, middleware patterns, validation schemas, and test framework. Avoid adding unnecessary dependencies.
  4. Prove every fix with a test: Write an automated security regression test that reproduces the attack vector and asserts it is blocked, while confirming legitimate calls continue to work.
  5. Never weaken security to make tests pass: Do not disable TLS verification, loosen CORS/CSP, bypass auth in production code, or swallow exceptions silently.

Workflow

Step 1: Triage & Order the Work

Read docs/THREAT-MODEL.md (and docs/threat-model.json if present) and load the matching stack-specific tm-* skills for idiomatic remediation patterns. Work strictly in priority order:

  1. Critical (confirmed first)
  2. High (confirmed first, then design-gap)
  3. Medium (when in scope or straightforward)
  4. Low (hygiene pass if requested)

For findings that cannot be fixed in code alone (e.g., external WAF/IdP/cloud console setting), document the exact infrastructure/operational control needed and mark status appropriately (accepted or transferred only with user sign-off).

Step 2: Implement Each Fix Systematically

For each finding TM-XXX (see references/remediation-patterns.md for OWASP Cheat Sheet patterns):

  1. Re-read the exact cited code (file:line) and all callers/siblings.
  2. Design the structural fix:
    • Access Control (BOLA/BFLA/Tenant Isolation): Enforce server-side policy + bind object queries to authenticated userId/tenantId; return 404 or 403 consistently without leaking existence across tenants.
    • Injection (SQL/NoSQL/Command/Template/XSS): Replace concatenation with parameterized queries, argv-array process execution (shell: false), strict allowlists, and context-aware output encoding.
    • SSRF: Parse URLs strictly, enforce https: (or allowlisted schemes), resolve DNS and reject private/loopback/link-local/metadata IP ranges (IPv4 + IPv6 + IPv4-mapped IPv6), disable/re-validate redirects, and prefer explicit host allowlists.
    • Auth/Session/Tokens: Pin JWT algorithms, validate iss/aud/exp/nbf, enforce PKCE + state/nonce, use HttpOnly; Secure; SameSite=Lax|Strict cookies, rotate sessions on login/privilege change, use constant-time secret comparison.
    • Mass Assignment / BOPLA: Bind inputs to explicit allowlisted schemas/DTOs and explicitly pick response fields.
    • Error Handling (A10:2025): Catch cleanly, return generic client messages with correlation IDs, log details internally without secrets/PII, ensure auth/policy checks fail closed.
    • AI / MCP: Separate system instructions from untrusted data, apply strict schema validation + least-privilege tool allowlists + human-in-the-loop approval for destructive/external side effects, scope RAG retrieval by caller tenant.
  3. Apply the fix cleanly and check formatting/types/linting.

Step 3: Write Security Regression Tests

For each mitigated finding, add or update an automated test in the project's test suite:

  • Negative test (attacker path): Send the cross-tenant ID, forged header, invalid signature, injection payload, SSRF loopback URL, or unauthorized role and assert 401/403/404/400 or safe sanitized output.
  • Positive test (legitimate path): Verify authorized users still succeed without regression.
  • Run the full relevant test suite, typechecker, and linter.

Step 4: Update the Threat Model

Update docs/THREAT-MODEL.md (and docs/threat-model.json if present):

  • Change finding status from open to mitigated (or in-progress / accepted with documented rationale).
  • Update the Executive Summary severity count table.
  • Record the changed files, regression test path, and remaining residual risk under Resolution Notes.
  • Recommend running threat-model-verify as the final verification gate.

Individual skills in this repo

This repo contains 2 individual skills — each has its own dedicated page.

Verwandte Skills