Skip to content

A Claude Code skill bundle for bug hunting and external red-team work - 82 skills, 15 slash commands, 681 disclosed-report patterns curated across 24 core vulnerability classes, plus enterprise identity + infrastructure attack matrices.

security: repo-wide client-identifier leak guard (fail-closed) + pre-commit hook (#65)

Sachin Sharmad37233e0c3f0
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
new file mode 100755
index 0000000..855ac50
--- /dev/null
+++ b/.githooks/pre-commit
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+# Block commits that contain client/engagement identifiers (hashed denylist).
+# Enable once per clone: git config core.hooksPath .githooks
+# Mechanism: scripts/scan_identifiers.py (fails closed if the denylist is missing).
+python3 scripts/scan_identifiers.py || {
+ echo ""
+ echo "pre-commit: client-identifier scan failed — commit blocked."
+ echo "Remove the flagged identifier(s), or add a NEW banned term via scripts/.identifier-denylist.local (gitignored)."
+ exit 1
+}
diff --git a/.github/workflows/leak-guard.yml b/.github/workflows/leak-guard.yml
new file mode 100644
index 0000000..651153c
--- /dev/null
+++ b/.github/workflows/leak-guard.yml
@@ -0,0 +1,29 @@
+name: leak-guard
+
+# Repo-wide client/engagement-identifier leak guard. Unlike skill-lint.yml (which
+# only watches skills/**), this runs on EVERY push and PR with no path filter —
+# because the real leak that motivated it landed in README.md and tests/, not skills.
+# scan_identifiers.py fails CLOSED if the denylist is missing.
+
+on:
+ pull_request:
+ push:
+ branches: [main]
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+jobs:
+ scan:
+ name: Client-identifier scan
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
+ with:
+ python-version: "3.12"
+ - name: Self-test the scanner
+ run: python3 scripts/test_scan_identifiers.py
+ - name: Scan repo for client identifiers
+ run: python3 scripts/scan_identifiers.py
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5eb835e..513f98b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -54,6 +54,27 @@ There's no automated test suite. Manual smoke tests:
4. Verify Claude triggers the skill and uses its content correctly
5. For `hunt-*` skills, also verify the auto-trigger works without explicitly naming the skill
+## Leak guard (client/engagement identifiers)
+
+The repo's hard rule: **no real client/engagement identifier ever lands in the public tree.** Two automated gates enforce it — both stdlib-only, no pip install:
+
+- `scripts/lint_skills.py` — scans `skills/**` (structure + secrets + the identifier denylist).
+- `scripts/scan_identifiers.py` — scans **every tracked text file** (README, docs, tests, CHANGELOG, SVGs — the places a name actually leaked once). Runs in CI via `.github/workflows/leak-guard.yml` on every push and PR, and **fails closed** if the denylist is missing.
+
+Enable the local pre-commit hook once per clone so you catch it before pushing:
+
+```bash
+git config core.hooksPath .githooks
+```
+
+To ban a **new** identifier without committing the plaintext name, either add its hash to `scripts/.identifier-denylist.sha256`:
+
+```bash
+printf '%s' "the name" | tr '[:upper:]' '[:lower:]' | shasum -a 256 # paste the hash
+```
+
+or drop the plaintext (one per line) in `scripts/.identifier-denylist.local` — it's gitignored and hashed at runtime, so the name never enters the repo.
+
## Code of conduct
- Be respectful in PRs and issues
diff --git a/scripts/.identifier-denylist.sha256 b/scripts/.identifier-denylist.sha256
index 3c16ea7..3ab3d0e 100644
--- a/scripts/.identifier-denylist.sha256
+++ b/scripts/.identifier-denylist.sha256
@@ -20,3 +20,4 @@ a672b3be0c15a2af015886aef804d485704c37a56cfa8a564c973ccd944a2ee1
80537d65d479a2f986a78e859cc2bcaaf6a62f6df7a6ba2c5dd192cfcb2ff790
ae95921ebc9d9f3e72d883f217ff023fc5555d111ca0bf3b18c5b8cd0c5d7580
e7dcc519de2734ed30de133910fd3289c9afc89aef272f7239d17fac804b24a0
+73f8498998e03139a3d183d11d82d4590a3d228d0f6ca34c604e3945369f17bc
diff --git a/scripts/scan_identifiers.py b/scripts/scan_identifiers.py
new file mode 100755
index 0000000..1bb879c
--- /dev/null
+++ b/scripts/scan_identifiers.py
@@ -0,0 +1,140 @@
+#!/usr/bin/env python3
+"""
+scan_identifiers.py — repo-wide client/engagement-identifier leak guard.
+
+The skill linter (scripts/lint_skills.py) only scans skills/. A real client name
+once leaked through README.md and tests/ — files that linter never saw. This
+scanner closes that gap: it hashes every 1- and 2-word shingle of EVERY
+tracked text file and compares against scripts/.identifier-denylist.sha256 (plus an
+optional gitignored scripts/.identifier-denylist.local), the same mechanism and
+same denylist file lint_skills.py uses. Plaintext names never live in the repo.
+
+FAILS CLOSED: a missing or empty denylist is an error (exit 2), not a silent pass —
+unlike lint_skills.py, which prints a NOTE and exits 0 when the denylist is absent.
+
+Exit codes:
+ 0 clean
+ 1 one or more banned identifiers found
+ 2 fail-closed: no denylist loaded (missing/empty)
+
+Stdlib only — no pip install needed in CI.
+
+Usage:
+ python3 scripts/scan_identifiers.py # scan all tracked text files
+ python3 scripts/scan_identifiers.py a.md b.md # scan specific files (pre-commit hook)
+"""
+import hashlib
+import os
+import re
+import subprocess
+import sys
+
+REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+SCRIPTS_DIR = os.path.join(REPO, "scripts")
+WORD_RE = re.compile(r"[a-z0-9]+")
+
+# Binary / non-text extensions we never scan (denylist shingles are text-only).
+BINARY_EXT = {
+ ".png", ".jpg", ".jpeg", ".gif", ".webp", ".ico", ".bmp", ".pdf",
+ ".zip", ".gz", ".tar", ".tgz", ".woff", ".woff2", ".ttf", ".eot", ".otf",
+ ".mp4", ".mov", ".mp3", ".wav", ".jar", ".class", ".so", ".dylib", ".exe",
+}
+
+
+def load_denylist():
+ """Return a set of sha256 hex digests of banned identifiers.
+
+ Mirrors lint_skills.load_denylist(): hex hashes from the committed .sha256 file,
+ plus runtime hashes of any plaintext in the gitignored .local override.
+ """
+ hashes = set()
+ sha_file = os.path.join(SCRIPTS_DIR, ".identifier-denylist.sha256")
+ if os.path.exists(sha_file):
+ with open(sha_file, encoding="utf-8") as fh:
+ for line in fh:
+ line = line.strip()
+ if line and not line.startswith("#"):
+ hashes.add(line.lower())
+ local = os.path.join(SCRIPTS_DIR, ".identifier-denylist.local")
+ if os.path.exists(local):
+ with open(local, encoding="utf-8") as fh:
+ for line in fh:
+ name = " ".join(line.strip().lower().split())
+ if name and not name.startswith("#"):
+ hashes.add(hashlib.sha256(name.encode()).hexdigest())
+ return hashes
+
+
+def shingles(text):
+ """Yield normalized 1- and 2-word shingles from text (matches lint_skills)."""
+ words = WORD_RE.findall(text.lower())
+ for i, w in enumerate(words):
+ yield w
+ if i + 1 < len(words):
+ yield w + " " + words[i + 1]
+
+
+def tracked_text_files():
+ """Yield repo-relative paths of tracked, likely-text files."""
+ out = subprocess.run(
+ ["git", "-C", REPO, "ls-files"], capture_output=True, text=True
+ )
+ if out.returncode != 0:
+ sys.exit(f"error: `git ls-files` failed: {out.stderr.strip()}")
+ for rel in out.stdout.splitlines():
+ if not rel.strip():
+ continue
+ ext = os.path.splitext(rel)[1].lower()
+ if ext in BINARY_EXT:
+ continue
+ # Never scan the denylist itself (it holds hashes, not names — but skip anyway).
+ if rel.endswith(".identifier-denylist.sha256"):
+ continue
+ yield rel
+
+
+def scan_file(rel, denylist):
+ """Return list of (lineno, shingle) hits. Per-line so we can report locations;
+ real client names always sit on a single line."""
+ hits = []
+ path = os.path.join(REPO, rel)
+ try:
+ with open(path, encoding="utf-8", errors="ignore") as fh:
+ for lineno, line in enumerate(fh, 1):
+ for sh in shingles(line):
+ if hashlib.sha256(sh.encode()).hexdigest() in denylist:
+ hits.append((lineno, sh))
+ except (OSError, UnicodeError):
+ pass
+ return hits
+
+
+def main(argv):
+ denylist = load_denylist()
+ if not denylist:
+ msg = ("scan_identifiers: FAIL-CLOSED — no denylist loaded "
+ "(scripts/.identifier-denylist.sha256 missing or empty). "
+ "Refusing to pass without a guard.")
+ print(f"::error:: {msg}" if os.environ.get("GITHUB_ACTIONS") else f"ERROR {msg}")
+ return 2
+
+ if argv:
+ files = [a[len(REPO) + 1:] if a.startswith(REPO + os.sep) else a for a in argv]
+ else:
+ files = list(tracked_text_files())
+
+ total = 0
+ for rel in files:
+ for lineno, sh in scan_file(rel, denylist):
+ total += 1
+ m = (f"{rel}:{lineno}: CLIENT-IDENTIFIER MATCH — banned shingle "
+ f"(hash matched). Remove client/engagement identifiers before committing.")
+ print(f"::error:: {m}" if os.environ.get("GITHUB_ACTIONS") else f"ERROR {m}")
+
+ print(f"\nscan_identifiers: scanned {len(files)} file(s), {total} match(es), "
+ f"{len(denylist)} denylist entr(ies).")
+ return 1 if total else 0
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv[1:]))
diff --git a/scripts/test_scan_identifiers.py b/scripts/test_scan_identifiers.py
new file mode 100755
index 0000000..017d5dd
--- /dev/null
+++ b/scripts/test_scan_identifiers.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python3
+"""Self-check for scan_identifiers.py. Stdlib only, no network, no git.
+
+Run: python3 scripts/test_scan_identifiers.py (exit 0 = pass)
+
+Loads the scanner as a module, points its denylist path at a temp dir, and
+asserts the three behaviors that matter:
+ 1. a planted identifier is caught -> main() returns 1
+ 2. a clean file is not caught -> main() returns 0
+ 3. an empty/missing denylist fails CLOSED -> main() returns 2
+"""
+import hashlib
+import importlib.util
+import os
+import sys
+import tempfile
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+
+
+def load_module():
+ spec = importlib.util.spec_from_file_location(
+ "scan_identifiers", os.path.join(HERE, "scan_identifiers.py"))
+ mod = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(mod)
+ return mod
+
+
+def main():
+ mod = load_module()
+ with tempfile.TemporaryDirectory() as tmp:
+ scripts = os.path.join(tmp, "scripts")
+ os.makedirs(scripts)
+ mod.SCRIPTS_DIR = scripts # redirect denylist lookup
+ mod.REPO = tmp
+ deny = os.path.join(scripts, ".identifier-denylist.sha256")
+
+ # Denylist with the hash of a fake identifier "acmecorp".
+ banned = hashlib.sha256("acmecorp".encode()).hexdigest()
+ with open(deny, "w") as fh:
+ fh.write("# test denylist\n" + banned + "\n")
+
+ leak = os.path.join(tmp, "leak.md")
+ with open(leak, "w") as fh:
+ fh.write("The target was AcmeCorp Ltd, an internal engagement.\n")
+ clean = os.path.join(tmp, "clean.md")
+ with open(clean, "w") as fh:
+ fh.write("Generic methodology, no client names here.\n")
+
+ # 1. planted identifier caught
+ assert mod.main([leak]) == 1, "expected hit (exit 1) on planted identifier"
+ # 2. clean file passes
+ assert mod.main([clean]) == 0, "expected clean (exit 0) on benign file"
+ # 3. case-insensitive: "ACMECORP" also caught
+ loud = os.path.join(tmp, "loud.md")
+ with open(loud, "w") as fh:
+ fh.write("ACMECORP everywhere\n")
+ assert mod.main([loud]) == 1, "expected case-insensitive hit"
+
+ # 4. fail-closed on empty denylist
+ with open(deny, "w") as fh:
+ fh.write("# comments only, no hashes\n")
+ assert mod.main([clean]) == 2, "expected FAIL-CLOSED (exit 2) on empty denylist"
+ # 5. fail-closed on missing denylist
+ os.remove(deny)
+ assert mod.main([clean]) == 2, "expected FAIL-CLOSED (exit 2) on missing denylist"
+
+ print("PASS: scan_identifiers self-check (catch, clean, case-insensitive, fail-closed)")
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())