agentleFS
zahidoverflowzahidoverflow/viperclaw/skills/viper-remediation-patch-verifier/SKILL.md

viper-remediation-patch-verifier

Skill22 starsChanged 15 days agoMITView on GitHub

Security Patch Synthesizer & Regression Test Generator. Produces minimal root-cause code fixes for CWE findings and writes automated pytest/jest unit tests to verify the fix.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run the following discovery commands across the target repository before manual code review:

    line 30
  2. Distinctive:

    Verify whether an upstream API Gateway, global middleware, or ORM hook already enforces the control before flagging a controller.

    line 61
  3. Distinctive:

    Write a Positive Unit Test confirming authorized, schema-valid requests succeed.

    line 96
  4. Distinctive:

    Write a Negative Security Regression Test confirming unauthorized, cross-tenant, or malformed inputs are deterministically rejected.

    line 97

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

Root-Cause Security Patch Synthesizer & Regression Test Verifier (viper-remediation-patch-verifier)

1. Executive Scope, Standards & CWE/OWASP Mapping

  • Frameworks & Standards: OWASP ASVS, NIST SSDF (Secure Software Development Framework), SARIF v2.1.0 Verification
  • Primary CWE Mapping: CWE-693 (Protection Mechanism Failure / Incomplete Fix), CWE-184 (Incomplete List of Disallowed Inputs)
  • ViperClaw MCP Tools: viper_taint_scan, viper_verify_and_report
  • ViperClaw CLI Command: viperclaw taint ./src && pytest -v

2. Threat Model & Root-Cause Architecture

flowchart LR
  Finding["Verified CWE Finding"] --> Patch["Minimal Root-Cause Code Fix"] --> Tests["Positive + Negative Unit Tests"] --> Gate["viperclaw taint (0 Flows) + CI Pass"]

Root-Cause Analysis

Many security patches fail verification testing because developers patch the symptom (adding a naive blacklist like .replace("'", "") or .replace("../", "")) instead of fixing the structural root cause (using parameterized SQL statements, canonical path resolution with .is_relative_to(), or query-level tenant scoping).


3. Deterministic Discovery & Grep/AST Audit Commands

Run the following discovery commands across the target repository before manual code review:

# 1. Automated ViperClaw analysis
viperclaw taint ./src && pytest -v

# 2. Rapid static pattern discovery (ripgrep)
viperclaw taint ./src
pytest -v

4. Senior Security Engineer 8-Point Audit Checklist

Control IDAudit Verification TargetPass CriteriaFail / Vulnerability Indicator
FIX-01Eliminate Blacklists in Favor of Structural ControlsFixes use parameterization, strict type/enum allowlists, or canonicalization—never substring blacklists.Patch adds input.replace('../', '') (trivially circumvented by ....//).
FIX-02Minimal Diff & Backward CompatibilityPatch modifies only the necessary security boundary without breaking existing API contracts or valid inputs.Overly broad patch breaks legitimate unicode names, special characters in passwords, or API response schemas.
FIX-03Variant Analysis Across Entire CodebaseWhen fixing a bug in one controller, all sibling controllers/services are scanned for the same pattern.BOLA or SQLi fixed on GET /invoices/{id} while DELETE /invoices/{id} and GET /quotes/{id} remain vulnerable.
FIX-04Positive Functional Regression TestAutomated test confirms authorized users with valid inputs still receive the expected 200 OK result.Security patch accidentally blocks all users (403 for everyone) and goes unnoticed without a positive test.
FIX-05Negative Security Regression TestAutomated test sends the previously problematic input (cross-tenant ID, unparameterized metacharacters, expired token) and asserts rejection (400/403/404).No regression test added; a future refactor re-introduces the exact same vulnerability.
FIX-06Zero Remaining Taint Flows (viperclaw taint)Re-running viperclaw taint on the patched file confirms total_flows == 0 for the remediated sink.Taint flow still reaches a secondary sink in the same function.
FIX-07Fail-Closed Exception HandlingAny validation or authorization error raises an explicit exception / 403 rather than logging a warning and continuing.except Exception: pass swallows the security check failure and proceeds to execute the sink.
FIX-08Update Graph Node Status to verified / remediatedThe corresponding finding node in .viperclaw/graph.db is updated and documented.Audit ledger left out of sync with remediated codebase.

5. False-Positive Elimination & CVSS v3.1 Triage Rubric

False-Positive Gate

  1. Verify whether an upstream API Gateway, global middleware, or ORM hook already enforces the control before flagging a controller.
  2. Confirm the code path is reachable from an external entrypoint (not dead code, CLI-only admin script, or unit-test fixture).
Severity TierBaseline CVSS v3.1 VectorQualifying Security Impact
CRITICAL -> 0.0Remediated (CVSS 0.0)Root-cause parameterization / isolation applied + verified by automated negative regression test.
INCOMPLETE FIXCVSS UnchangedBlacklist or client-side-only fix that remains avoidable via encoding or direct API calls.

6. Production Remediation Patterns (Vulnerable vs. Hardened Code)

# ❌ INCOMPLETE SYMPTOM PATCH: Non-recursive string replace('..', '') is circumvented by '....//'
def get_template_file(name: str) -> str:
    clean_name = name.replace("../", "")
    return Path(f"/app/templates/{clean_name}").read_text()

# ✅ ROOT-CAUSE PATCH + REGRESSION TEST: Canonical path confinement + negative unit test
TEMPLATE_ROOT = Path("/app/templates").resolve()

def get_template_file(name: str) -> str:
    target = (TEMPLATE_ROOT / name).resolve()
    if not target.is_relative_to(TEMPLATE_ROOT) or not target.is_file():
        raise PermissionError("Unauthorized template path")
    return target.read_text(encoding="utf-8")

def test_get_template_file_blocks_traversal():
    with pytest.raises(PermissionError):
        get_template_file("....//....//etc/passwd")

7. Regression Testing & Continuous Verification

  1. Write a Positive Unit Test confirming authorized, schema-valid requests succeed.
  2. Write a Negative Security Regression Test confirming unauthorized, cross-tenant, or malformed inputs are deterministically rejected.
  3. Re-run viperclaw taint and viperclaw verify to confirm zero remaining unmitigated flows in .viperclaw/graph.db.

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.