Repo Forensics v2

SkillSecurity

Security forensics for git repos, AI skills, and MCP servers. Audits dependencies, detects prompt injection, credential theft, runtime dynamism, manifest drift, known CVEs, CISA KEV (actively exploited) vulns, and 2026 attack patterns. Not for fixing vulnerabilities or pentesting.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Repo Forensics v2 skill

What this skill tells your AI

The instructions your AI receives, as published by alexgreensh/repo-forensics in skills/repo-forensics/SKILL.md and read by ahel’s review.

Deep security auditing for repositories, AI agent skills, and MCP servers.

Highlights

  • Rules-as-data (v2.10): ~545 behavioral detection patterns live in versioned JSON rule packs (data/rulepacks/*.json), not compiled into source. Each rule carries a stable id, severity, confidence score, explanation, and embedded self-tests. Pack-driven scanners: secrets, SAST, skill threats, MCP security, runtime dynamism, and shared patterns. Algorithmic scanners (entropy, AST, DAST, git forensics, integrity, manifest drift, binary, lifecycle, dependencies, infra, devcontainer, post-incident, dataflow, entrypoint) remain code-driven; they do not receive feed updates.
  • Signed daily rule-pack feed (v2.10): New detection rules reach installed users without a code release. An Ed25519-signed bundle is fetched by the daily refresh_threat_dbs.py pipeline. Shipped packs always work offline; the feed only overlays when verified, schema-valid, and strictly newer than the last accepted version. The same signing now covers the IOC feed for symmetric trust.
  • Confidence tiers + verdict levels (v2.10): Findings carry a confidence score. Four verdict tiers shape output and agent routing: BLOCK (>= 0.92), WARN (>= 0.60), INFO (>= 0.30), SUPPRESSED (< 0.30 or user-suppressed). Severity still drives exit codes (0/1/2/99) unchanged.
  • Separated trust signals: JSON reports expose core_verdict, coverage_status, and enrichment_status. core_verdict is the deterministic install gate. Coverage and enrichment report what could not be checked and may add warnings or context, but they cannot remove findings, reduce severity, or lower the deterministic exit code.
  • Local scan attestations: --history stores content-addressed attestations in a private local SQLite database. Storage and deferred retries stay off the verdict path; storage failure does not change scan output or exit behavior.
  • Offline benign-corpus FP gate (v2.10): A committed corpus of tricky-but-clean content (emoji-rich markdown, legitimate postinstall scripts, .env.example, OAuth docs, clean SKILL.md) runs in pytest. Any rule change that raises new false positives on the corpus fails the test before it can ship.
  • Advisory adjudication (v2.10): WARN-tier findings include an injection-safe adjudication block. Snippets are prefixed with > SNIPPET: (not in code fences), metadata appears before content, the block is capped at 5 findings sorted by confidence descending. Verdict choices: confirm / downgrade / escalate. See "Adjudication Protocol" section for the full protocol. Confirm and refute responses are annotations only. Disagreement, invalid output, containment failure, or unavailable service remains unresolved and never gates the verdict.
  • Auto-scan hook (v2): PostToolUse hook auto-triggers on git clone, git pull, pip install, npm install/update, uv add/sync, bun install/add, pnpm install/add, gem install/update, brew install/upgrade, etc. Zero-overhead for non-matching commands.
  • Pre-execution gate (v2.6): PreToolUse hook blocks known-malicious packages and pipe-to-shell commands BEFORE execution. IOC-only, <10ms latency, no subprocess calls.
  • Session security scanner (v2.6.3): SessionStart hook detects updated plugins/skills/MCP servers, refreshes threat databases daily, runs fast IOC check + full 27-scanner deep scan on changed items. Sub-1ms when nothing changed.
  • .pth file injection detection (v2): Detects liteLLM-style Python startup injection attacks (exec/eval/base64/known IOC filenames)
  • Transitive dependency scanning (v2): Deep-parses package-lock.json, yarn.lock, poetry.lock, Pipfile.lock for supply chain IOCs
  • DAST scanner (scan_dast.py): Dynamic analysis of Claude Code hooks with 8 malicious payload types, sandboxed execution
  • File integrity monitor (scan_integrity.py): SHA256 baselines for critical config files, drift detection with --watch
  • IOC auto-update (--update-iocs): Pull latest indicators of compromise from remote feed
  • Installation verification (--verify-install): Verify repo-forensics itself hasn't been tampered with
  • GitHub Actions (action.yml): CI/CD integration for automated security gating
  • Runtime behavior prediction (scan_runtime_dynamism.py): Detects code that changes behavior after install: dynamic imports, fetch-then-execute, self-modification, time bombs, dynamic tool descriptions
  • Manifest drift detection (scan_manifest_drift.py): Compares declared vs actual dependencies, catches phantom deps, runtime installs, conditional import+install fallbacks
  • MCP rug pull detection: Tool descriptions sourced from database, network, env vars, or conditional logic
  • Enhanced AST analysis: 12 patterns including marshal.loads, types.CodeType, sys.addaudithook, bytes decode obfuscation, self-modification
  • Test suite: 1,800+ pytest tests covering all scanners
  • OpenClaw/ClawHub scanning: Auto-detects OpenClaw skills, validates frontmatter, tools.json, SOUL.md, .clawhubignore
  • Anti-forensics detection (v2): Self-deleting installers, package.json overwrite, version mismatch (Axios supply chain pattern)
  • Compromised version detection (v2): Flags known-bad versions of legitimate packages (Axios, liteLLM, vpmdhaj OpenSearch typosquats, Miasma/Red Hat Cloud Services)
  • Suspicious npm scope detection (v2): Flags systematic MCP server forking campaigns (iflow-mcp)
  • Host IOC scanning (v2): Known RAT binary paths, C2 domains, malicious file hashes
  • CVE-2026-33068 detection (v2): Workspace trust bypass via bypassPermissions in Claude Code settings
  • Post-incident forensics (v2.2): npm cache/log artifacts, RAT binary detection, C2 persistence, node_modules traces that survive dropper self-cleanup
  • Supply chain hardening (v2.2): .npmrc scanning, missing lockfile detection, git/HTTP dep flagging, hostname bypass fix, unbounded Python range detection, install script severity elevation
  • Devcontainer security scanning (v2.6.5): JSON-based analysis of devcontainer.json for host secret mounts, container escape vectors, localEnv interpolation, lifecycle command risks, and untrusted features
  • Framework env prefix leak detection (v2.6.5): Catches secrets exposed to browser bundles via NEXT_PUBLIC_, REACT_APP_, VITE_, EXPO_PUBLIC_, GATSBY_, NX_PUBLIC_ prefixes
  • process.env exposure detection (v2.6.5): Flags console.log(process.env), JSON.stringify(process.env), and crash report env dumps
  • Docker ARG secret detection (v2.6.5): Catches secrets passed via ARG directives (permanently visible in docker history)
  • 1Password/Vault token detection (v2.6.5): OP_CONNECT_TOKEN, ops_ service account tokens, hvs. Vault tokens
  • Content-based archive detection (v2.11.2): archives are identified by magic bytes (PK/ustar/gzip) and is_zipfile, not extension, so a zip renamed to dodge gating (e.g. a .docx.txt) or a polyglot/self-extracting zip is still opened and scanned. Scripts/executables smuggled inside an OOXML (Office) document are flagged HIGH on structure alone.
  • Bytecode poisoning detection (v2.11.2): a benign .py source shipping a malicious compiled .pyc (Python loads the cache over source) is caught by diffing raw .pyc danger markers against the sibling source — no unmarshalling, no execution, cross-version-safe, so the verdict never runs attacker bytecode. Best-effort multi-interpreter decode enriches the report; obfuscated getattr+char-built-name gadgets are also detected.
  • Registry-hijack / dependency-confusion detection (v2.11.2): npm/yarn/pip/bun registry or index-url redirected to a non-canonical host is flagged (MEDIUM — corporate mirrors are legitimate), escalating to HIGH only when the redirect co-occurs with reviewer-disarming assurance prose. Resolves ${VAR} indirection; runs in the install-time hook too.
  • 27 scanners with 41 correlation rules

How Detection Stays Fresh

Short answer: no, these are not static rules you maintain by hand.

Detection runs in layers, each with its own update cadence:

  1. Shipped rule packs (offline-first, always available): ~545 behavioral patterns in data/rulepacks/*.json ship with every release. They work on an air-gapped machine with no network access. Pack-driven surfaces: secrets, SAST, skill threats, MCP security, runtime dynamism, and shared patterns.

  2. Signed daily rule-pack feed: Every 24 hours, refresh_threat_dbs.py fetches iocs/rulepacks.json and verifies the Ed25519 signature before accepting it. A verified bundle with a strictly newer pack_version overlays the shipped packs in ~/.cache/repo-forensics/rulepacks/. New behavioral detections land on every installed instance without requiring a release. Tampered, invalid, or replayed bundles are rejected and the shipped packs stay authoritative.

  3. IOC / KEV / OSV feeds (existing, also now signed): IP/domain/package indicators (iocs/latest.json), CISA KEV catalog, and OSV vulnerability queries update continuously via the same daily pipeline. The IOC feed now carries an Ed25519 signature for parity with the rule-pack channel.

  4. LLM adjudication: For WARN-tier findings the host agent applies judgment to ambiguous cases, effectively providing a zero-latency "update" for novel patterns that haven't been formalized into rules yet.

  5. Code releases (for algorithmic surfaces): Scanners whose detection is algorithmic rather than pattern-based (entropy math, Python AST walking, DAST sandbox execution, git forensics logic, integrity hashing, manifest diffing, binary detection, lifecycle hook parsing, dependency resolution, infra config analysis, devcontainer parsing, post-incident artifact hunting, dataflow taint, entrypoint analysis) update only with code releases. These surfaces are explicitly not pack-driven and do not receive feed updates between releases.

When to Use

  • Auditing a new repo or dependency before adding it to your project
  • Vetting AI skills/plugins before installation (prompt injection, credential theft, backdoors)
  • Auditing MCP servers for tool poisoning, SQL injection, config risks
  • Security review when someone asks "is this code secure?"
  • Forensic investigation of a suspected compromise
  • CI/CD gating with machine-readable output and exit codes
  • Hook security testing to verify Claude Code hooks handle malicious input safely

Quick Start

Full audit (all 27 scanners):

./scripts/run_forensics.sh /path/to/repo

Focused AI skill scan (17 scanners, faster):

./scripts/run_forensics.sh /path/to/repo --skill-scan

With IOC update and integrity monitoring:

./scripts/run_forensics.sh /path/to/repo --update-iocs --watch

Verify your installation:

./scripts/run_forensics.sh /path/to/repo --verify-install

JSON output for automation:

./scripts/run_forensics.sh /path/to/repo --format json

Severity System

LevelScoreMeaningExit Code
CRITICAL4Active threat, immediate action required2
HIGH3Significant risk, investigate promptly1
MEDIUM2Potential issue, review recommended1
LOW1Informational, may be false positive0

Scanners

ScannerWhat It DetectsMode
runtime_dynamismDynamic imports, fetch-then-execute, self-modification, time bombs, dynamic tool descriptionsskill + full
manifest_driftPhantom dependencies, runtime package installs, conditional import+install, declared-but-unused depsskill + full
skill_threatsPrompt injection, unicode smuggling, prerequisite attacks, ClickFix, MCP tool injectionskill + full
agent_skillsSKILL.md frontmatter abuse, tools.json FSP, agent config injection (SOUL.md/AGENTS.md/CLAUDE.md), .clawhubignore bypass, ClawHavoc IOCs. Covers Claude Code, OpenClaw, Codex, Cursor, MCP.skill + full
mcp_securitySQL injection to prompt escalation, tool poisoning, rug pull enablers, config CVEsskill + full
dataflowSource-to-sink taint tracking (env vars to network calls), cross-file import taintskill + full
secrets50+ patterns: API keys, tokens, private keys, database URIs, JWTs, framework env prefix leaks, 1Password/Vault tokens, .env variant filesskill + full
sastDangerous functions, injection, shell execution across 8 languages, process.env exposure, path traversalskill + full
lifecycleNPM hooks + Python setup.py/pyproject.toml cmdclass overrides + anti-forensics (self-deleting installers, package.json overwrite)skill + full
integritySHA256 baselines for .claude/settings.json, CLAUDE.md, hook scripts. Drift detection with --watchfull
dastDynamic hook testing: 8 payload types (injection, traversal, amplification, env leak) in sandboxfull
entropyPer-string Shannon entropy, base64 blocks, hex strings (combo detection)full
infraDocker (ENV/ARG secrets, .env COPY), K8s, GitHub Actions, Claude Code config (CVE-2025-59536, CVE-2026-21852, CVE-2026-33068)full
devcontainerJSON-based devcontainer.json analysis: host mounts, privileged mode, docker.sock, remoteEnv localEnv interpolation, lifecycle commands, untrusted featuresskill + full
dependenciesNPM + Python typosquatting, l33t normalization, IOC packages (SANDWORM_MODE 2026), 190+ package IOCs, compromised version detection (Axios, liteLLM, vpmdhaj, Miasma), suspicious scope detection (iflow-mcp)full
ast_analysisPython AST: obfuscated exec chains, __reduce__ backdoors, marshal/types bytecode, audit hook abuse, self-modificationfull
binaryExecutables hidden as images/text filesfull
git_forensicsTime anomalies, GPG signature issues, identity inconsistenciesfull
oversizeFiles padded past the 10 MB scan cap (head+tail window scan) and whitespace-inflation padding that hides a payload after a long whitespace runskill + full
bytecodePython .pyc bytecode: dangerous-call primitives (os.system/subprocess/exec), embedded URLs / credential paths, orphan bytecode, and bytecode poisoning (benign source + malicious .pyc) detected by a raw-marker source diff with no unmarshalling or execution (cross-version-safe). Disassembly is unmarshalled in an isolated subprocess so hostile bytecode cannot crash the scan, and is enrichment only — never load-bearing for the verdictskill + full
archivePayloads hidden inside .zip/.docx/.xlsx/.pptx/.jar/.whl/.tar.* and other archives, including archives renamed/forged to dodge extension gating (detected by magic bytes + is_zipfile) and scripts/executables smuggled inside an OOXML document (HIGH structural flag). Members are read in memory (never written to disk) and run through the SAST / trifecta / secret / skill-threat detectors; bomb-, fan-out-, and tar-link-safeskill + full
dead_anchorsExternal-anchor claimability: repojackable GitHub owner/repo, phantom/removed npm & PyPI packages named in prose install commands, unregistered/expired domains (RDAP), and dangling free-tier cloud subdomains (Vercel/Railway/GitHub Pages/… via DNS + provider fingerprint). Closes the Skilljacking gap AIR's research says "tripped nothing at all" — the reference is dead and claimable by an attacker while the file content never changed. Network-touching but never-hard-fail: emits only on a confirmed-claimable anchor; live-and-owned and couldn't-check are silent. --offline degrades every anchor to silent.skill + full
yaraCurated YARA signature scanner for malware, webshells, cryptominers, and hacktools. 11 hand-authored rules across 4 families (data/yara/{webshells,malware,cryptominers,hacktools}.yar) with multi-string conjunctive conditions + filesize bounds so a match is a confirmed family indicator, not a single-token guess. Each rule carries a meta: block (id/severity/category/confidence/title) mirrored in data/yara/manifest.json with per-file sha256 integrity checks. yara-python is an optional dependency: when absent the scanner degrades to a missing-tool capability gap (one stderr line, exit-neutral, stdout []), so the core product stays zero-non-stdlib-deps and offline. Webshells and reverse-shell stagers are CRITICAL/HIGH; hacktools start at MEDIUM (conservative initial severities).skill + full

Dead-anchor coverage and known scope (Skilljacking / repojacking)

dead_anchors (motivated by AIR's Skilljacking research, plus the Circus of Skills free-tier-suffix study, Snyk's ToxicSkills IOCs, and the SkillSieve dataset — logged in references/research_sources.md) is precise, not total. Known limits, surfaced honestly rather than implied as covered:

  • Rate-limit budget: unauthenticated GitHub API is 60 req/hr/IP, so GH calls are hard-capped (~20/scan, ~40 if GITHUB_TOKEN is set — read, never required, never prompted) and a total per-scan probe ceiling (~50) plus a wall-clock deadline bound the whole pass. Over-budget anchors degrade to couldn't-check (silent, safe-by-design), never a false clear.
  • RDAP ccTLD gaps: rdap.org's bootstrap covers gTLDs well; some ccTLDs degrade to couldn't-check rather than a verdict.
  • Multi-part-TLD heuristic: a small vendored compound-TLD list (not a full Public Suffix List, to stay zero-non-stdlib-dep), so some obscure ccTLD domain reductions are imprecise.
  • Fingerprint rot: cloud-provider "deleted app" page strings change over time; the fingerprint list is pack-driven (data/rulepacks/dead_anchors.json, refreshed by the signed refresh_threat_dbs.py overlay) so it can be updated without a code change. Netlify/Render/Surge deleted-app pages are generic 404 copy and are deliberately NOT fingerprinted (stay live-and-owned, never guessed).
  • Deferred: verdict-decay / time-based recheck (a link live today can go claimable later with zero file change) needs new persistent per-anchor state and is a Phase-2 item, not built here.

Bypass coverage and known scope (archive / oversize / bytecode)

These three scanners close the "hide the payload where the text reader never looks" bypass class (CSA / Trail of Bits, June 2026). Their coverage is precise, not total — what they do not yet reach is surfaced as a loud INFO finding (unsupported-archive-type, opaque-archive, archive-scan-incomplete, unanalyzable-bytecode) rather than implied as covered:

  • Archives: the listed zip- and tar-family formats only. .7z .xz .zst .rar .cab and encrypted/password-protected members are reported as unsupported/ opaque, not inspected. Nested archives are opened to depth 2. A base64- or otherwise-encoded payload inside an archive member is not decoded here (encoded-blob rescan is deferred follow-up work).
  • Bytecode: Python .pyc only. Java .class, Node .jsc, and .wasm carry compiled logic the source scanners also miss, but are out of scope for this scanner.
  • Oversize: files over 10 MB are scanned by head+tail window (first + last 1 MB), so a payload buried in the exact middle of a multi-hundred-MB file may be sampled rather than fully read.

Dynamic Analysis (DAST)

The scan_dast.py scanner executes hook scripts with malicious payloads in a sandboxed subprocess:

8 payload types:

  1. Prompt injection in tool input
  2. Path traversal in file arguments
  3. Command injection via backticks/subshell
  4. Oversized input (amplification test)
  5. Unicode smuggling in arguments
  6. Environment variable exfiltration attempt
  7. Shell metacharacter injection
  8. Null byte injection

Safety: All execution uses subprocess with 5s timeout, stdout/stderr capture, scrubbed environment, temp directory isolation, no shell=True.

File Integrity Monitor

The scan_integrity.py scanner protects critical configuration files:

  • SHA256 baselines for .claude/settings.json, CLAUDE.md, .mcp.json, hook scripts
  • --watch mode: Creates baseline on first run, alerts on drift on subsequent runs
  • Detects dangerous hook commands (curl, wget, eval, base64, /dev/tcp)
  • Flags executable config files (unusual permission bits)

CVE + CISA KEV Auto-Enrichment (v2.6)

The dependency scanner automatically enriches findings with live vulnerability data:

  • OSV (Open Source Vulnerabilities): Every pinned (ecosystem, package, version) found in a manifest or lockfile is queried against api.osv.dev. Matches emit a cve finding with CVSS-mapped severity and suggested fix versions.
  • CISA KEV (Known Exploited Vulnerabilities): CVE aliases are cross-referenced against the CISA KEV catalog — CVEs confirmed actively exploited in the wild. Any match is escalated to CRITICAL severity (category cve-kev) regardless of CVSS, because exploitation in the wild is the strongest prioritization signal.
  • Caches: KEV catalog is cached 24h (~/.cache/repo-forensics/kev.json). OSV per-package queries cache 24h (~/.cache/repo-forensics/osv-queries.json, LRU-capped at 4000 entries). Both files are written atomically with mode 0o600.
  • Security: Feed URLs are hardcoded constants. No user-overridable URL at the public API (SSRF guardrail). Response size caps, HTTPS-only fetch, fail-closed CVE ID validation, and oversized-response rejection. A malformed or hostile feed returns an empty result rather than crashing the scanner.
  • Offline mode: --offline uses cached data only; --no-vulns disables the feature entirely.
  • CLI: --update-vulns refreshes the KEV catalog before scanning. Standalone tool: python3 scripts/vuln_feed.py --query npm lodash 4.17.20.

IOC Auto-Update

The --update-iocs flag pulls latest indicators of compromise from a hosted JSON feed:

  • C2 IP addresses, malicious domains, known-bad packages
  • Cached locally in .forensics-iocs.json (24h TTL)
  • Falls back to hardcoded IOCs when offline
  • Managed by ioc_manager.py (--show to inspect, --update to pull)

Installation Verification

The --verify-install flag checks that repo-forensics itself hasn't been tampered with:

  • Compares all skill files against checksums.json (SHA256)
  • Detects modified, missing, or unexpected files
  • Run verify_install.py --generate at release time to create checksums

AI Skill Threat Detection

The scan_skill_threats.py scanner detects 10 categories of AI agent skill attacks:

  1. Prompt injection directives ("ignore previous instructions", persona reassignment)
  2. Invisible unicode smuggling (zero-width chars, RTL override, Cyrillic + Greek homoglyphs)
  3. Prerequisite red flags (curl-pipe-bash, password-protected archives, xattr -c)
  4. Credential exfiltration (bulk env access + network calls, webhook services)
  5. Persistence mechanisms (LaunchAgents, crontab, shell RC modifications)
  6. Scope escalation (accessing ~/.ssh, browser data, Keychain, other skills)
  7. Stealth directives ("do not log", output suppression with background exec)
  8. Known campaign IOCs (C2 IPs from ClawHavoc, SANDWORM_MODE, Telegram/Discord exfil)
  9. ClickFix / sleeper malware (curl|base64-d|bash delivery, glot.io pastebins, SKILL.md prereqs)
  10. MCP tool description injection (Invariant Labs <IMPORTANT> tag, "note to the AI", hidden instructions in JSON description fields)

MCP Attack Surface

The scan_mcp_security.py scanner covers MCP-specific attack vectors discovered in 2025-2026:

Shortened here. Read the whole file on GitHub.

Signals

GitHub stars
173
Forks
27
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
repo-forensics
Source
github.com/alexgreensh/repo-forensics