agentleFS
zahidoverflowzahidoverflow/viperclaw/skills/viper-crypto-tls-audit/SKILL.md

viper-crypto-tls-audit

Skill22 starsChanged 15 days agoMITView on GitHub

Cryptography, Key Management & Password Hashing Auditor (modeled on Trail of Bits & OWASP Cryptographic Storage). Reviews algorithms, IV/nonce handling, CSPRNG usage, and Argon2/bcrypt.

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

Cryptography, Key Management & Password Hashing Auditor (viper-crypto-tls-audit)

1. Executive Scope, Standards & CWE/OWASP Mapping

  • Frameworks & Standards: OWASP Cryptographic Storage Cheat Sheet, OWASP Password Storage Cheat Sheet, NIST SP 800-57 / SP 800-63B, Trail of Bits Crypto Rules
  • Primary CWE Mapping: CWE-327 (Use of a Broken or Risky Cryptographic Algorithm), CWE-323 (Reusing a Nonce, Key Pair in Encryption), CWE-338 (Use of Cryptographically Weak PRNG), CWE-916 (Weak Password Hashing)
  • 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
  Secret["Plaintext Password / PII / Token"] --> CSPRNG["CSPRNG (secrets / crypto.randomBytes)"] --> Algo["Argon2id / AES-256-GCM / Ed25519"] --> Store[("Authenticated Ciphertext / Hash")]

Root-Cause Analysis

Cryptographic failures occur when developers use fast general-purpose hashes (SHA-256, MD5) for passwords, unauthenticated encryption modes (AES-ECB, AES-CBC without HMAC—vulnerable to padding oracle decryption), static or reused IVs/nonces in AES-GCM, or non-cryptographic PRNGs (random, Math.random()) for security tokens.


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 "(hashlib\.(md5|sha1)|MD5\.Create|MessageDigest\.getInstance\(.(MD5|SHA-1).\))"
rg -n "(AES\.MODE_ECB|AES\.MODE_CBC|DES|RC4|Blowfish)"
rg -n "(random\.(randint|choice|random)|Math\.random\(|math/rand)"

4. Senior Security Engineer 8-Point Audit Checklist

Control IDAudit Verification TargetPass CriteriaFail / Vulnerability Indicator
CRYP-01Memory-Hard Password Hashing (Argon2id)User passwords hashed with Argon2id (m>=19MiB, t>=2, p=1), bcrypt (cost >= 12), or scrypt.Passwords hashed with MD5, SHA-1, unsalted SHA-256, or low-iteration PBKDF2.
CRYP-02Authenticated Encryption (AEAD) OnlySymmetric encryption uses AES-256-GCM, ChaCha20-Poly1305, or Fernet / libsodium secretbox.Unauthenticated AES-ECB (leaks patterns) or raw AES-CBC (vulnerable to PKCS#7 padding oracle).
CRYP-03Unique CSPRNG Nonce / IV Per EncryptionEvery AES-GCM or ChaCha20 encryption generates a fresh CSPRNG nonce (os.urandom(12)) prepended to the ciphertext.Hardcoded/static IV (b'\x00'*12) or counter reuse under the same key (catastrophic key/plaintext recovery in GCM).
CRYP-04CSPRNG for All Security TokensReset tokens, OTPs, salts, and session IDs use secrets (Python), crypto.randomBytes (Node), or crypto/rand (Go).random.choice(), uuid.uuid1() (MAC + timestamp), or Math.random() used for tokens.
CRYP-05Constant-Time Secret ComparisonMACs, webhook signatures, and API tokens compared via hmac.compare_digest() / crypto.timingSafeEqual().Standard == string comparison leaking signature bytes via timing side channels.
CRYP-06Asymmetric Key Lengths & Curve SafetyEd25519, ECDSA P-256/P-384, or RSA >= 2048-bit with RSA-OAEP (encryption) and RSA-PSS (signatures).RSA-1024 or legacy PKCS#1 v1.5 encryption padding (Bleichenbacher oracle).
CRYP-07Key Separation & KMS Envelope EncryptionSigning keys and encryption keys are strictly separated (HKDF subkey derivation); master keys reside in KMS/HSM.The same raw secret key is used for both JWT signing (HS256) and database field encryption.
CRYP-08TLS 1.2+ & Certificate VerificationOutbound TLS clients verify hostname + certificate chain (CERT_REQUIRED) and enforce TLS 1.2/1.3.verify=False, NODE_TLS_REJECT_UNAUTHORIZED=0, or InsecureSkipVerify: true enabled.

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 (9.1)CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:NPredictable PRNG reset tokens, static AES-GCM nonce reuse, or AES-CBC padding oracle compromising confidentiality.
HIGH (7.5)CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:NDisabled TLS certificate verification (verify=False) or fast unsalted password hashes (MD5/SHA1).
MEDIUM (5.3)CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:NNon-constant-time HMAC comparison or shared key material across signing and encryption.

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

# ❌ VULNERABLE: Uses random.choices (Mersenne Twister) for OTP & fast SHA-256 for password
otp = "".join(random.choices("0123456789", k=6))
pw_hash = hashlib.sha256(password.encode()).hexdigest()

# ✅ HARDENED: CSPRNG secrets module for OTP & Argon2id for password hashing
import secrets
from argon2 import PasswordHasher

ph = PasswordHasher(time_cost=3, memory_cost=65536, parallelism=4)
otp = f"{secrets.randbelow(1_000_000):06d}"
pw_hash = ph.hash(password)

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.