agentleFS
zahidoverflowzahidoverflow/viperclaw/skills/viper-logging-pii-compliance/SKILL.md

viper-logging-pii-compliance

Skill22 starsChanged 16 days agoMITView on GitHub

Security Logging, PII Redaction & Error Sanitization Auditor (OWASP Logging Cheat Sheet & ASVS V7). Reviews audit trail coverage, log injection defenses, and secret scrubbing.

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 31
  2. Distinctive:

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

    line 62
  3. Distinctive:

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

    line 92
  4. Distinctive:

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

    line 93

≈ “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

Security Logging, PII Redaction & Audit Trail Compliance Auditor (viper-logging-pii-compliance)

1. Executive Scope, Standards & CWE/OWASP Mapping

  • Frameworks & Standards: OWASP Logging Cheat Sheet, OWASP Top 10:2025 A09 (Security Logging and Alerting Failures), OWASP ASVS V7, CWE-532, CWE-117
  • Primary CWE Mapping: CWE-532 (Insertion of Sensitive Information into Log File), CWE-117 (Improper Output Neutralization for Logs / Log Injection), CWE-778 (Insufficient Logging)
  • ViperClaw MCP Tools: viper_taint_scan, viper_verify_and_report
  • ViperClaw CLI Command: viperclaw taint ./src --db .viperclaw/graph.db

2. Threat Model & Root-Cause Architecture

flowchart LR
  Event["Security / App Event"] --> Scrub["PII & Secret Redaction Filter"] --> JSON["Structured JSON Formatter (No CRLF)"] --> SIEM[("Immutable Audit Log Sink")]

Root-Cause Analysis

Applications either log too much (dumping full req.headers or req.body containing plaintext passwords, Bearer JWTs, session cookies, and credit card numbers into Datadog/CloudWatch) or log too little (failing to record failed logins, privilege escalations, and cross-tenant 403 denials, or allowing log injection).


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 --db .viperclaw/graph.db

# 2. Rapid static pattern discovery (ripgrep)
rg -n "(logger\.(info|debug|error|warning)|console\.(log|error))\(.*(password|token|secret|authorization|cookie|ssn|card)" -i
rg -n "(print\(request\.|console\.log\(req\.(headers|body))"

4. Senior Security Engineer 8-Point Audit Checklist

Control IDAudit Verification TargetPass CriteriaFail / Vulnerability Indicator
LOG-01Automatic Credential & Token RedactionStructured log processors scrub password, secret, token, authorization, cookie, api_key, cvv, and ssn keys at the root logger level.logger.debug(f"Login body: {request.json}") writes plaintext passwords to log storage.
LOG-02Log Injection & CRLF Neutralization (CWE-117)Logs are emitted as single-line structured JSON (structlog / pino / zap) or strip \r, \n, and ANSI escape sequences (\x1b[) from user strings.Plaintext log logger.info(f"User {username} logged in") allows forging fake log lines via username="guest\n2026-11-18 INFO Admin privilege granted".
LOG-03Mandatory Security Event Coverage (CWE-778)Auth failures, password/MFA resets, role changes, API key creations, and 403 Forbidden authorization failures emit structured audit events.Administrative role elevation or repeated BOLA probes leave zero audit trail.
LOG-04Correlation / Request ID PropagationEvery incoming HTTP request generates or validates a UUID X-Request-ID propagated across all downstream logs and error responses.Impossible to trace a security incident across microservices.
LOG-05Exception Handler Secret ScrubbingCrash reporters (Sentry, Rollbar, Bugsnag) enable send_default_pii=False and scrub local stack variables containing secrets.Unhandled exception dumps local environment variables and DB connection strings to external crash tracker.
LOG-06HTTP Access Log Query-String HygieneSensitive values are never placed in URL query strings, and access logs redact ?token= / ?code= parameters.OAuth code or password-reset token logged in plaintext Nginx/ALB access logs.
LOG-07Tamper-Evident Append-Only Audit StorageCompliance audit trails (audit_logs table / S3 Object Lock) disallow UPDATE and DELETE by the application DB role.Compromised application role can DELETE FROM audit_logs to erase evidence.
LOG-08Log Level Hygiene in ProductionProduction environments run at INFO or WARN level, never DEBUG or TRACE.LOG_LEVEL=DEBUG in production dumps full SQL query parameters and HTTP bodies.

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
HIGH (7.5)CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:NPlaintext passwords, active session JWTs, or payment card data written to shared log management systems.
MEDIUM (5.3)CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:NUnescaped CRLF / ANSI log injection allowing audit log forgery or terminal escape injection.
LOW (3.3)CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:NMissing security audit events on privilege changes or failed authentication attempts.

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

# ❌ VULNERABLE: Logs raw headers/body (leaking Authorization & password) with newline injection risk
logger.info(f"Auth attempt for {request.form.get('username')} with headers {dict(request.headers)}")

# ✅ HARDENED: Structured JSON logging with automatic sensitive-key redaction & CRLF stripping
REDACTED_KEYS = {"authorization", "cookie", "password", "token", "secret", "api_key"}

def redact_dict(d: dict) -> dict:
    return {k: ("[REDACTED]" if k.lower() in REDACTED_KEYS else v) for k, v in d.items()}

safe_user = str(request.form.get("username", "")).replace("\r", "").replace("\n", "")[:64]
logger.info("auth_attempt", extra={"username": safe_user, "headers": redact_dict(dict(request.headers))})

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.