Skip to content

feat(v56.2): path_traversal + missing_csp_header contracts and fixtures (#185 follow-on)#187

Open
cunninghambe wants to merge 6 commits into
feat/v56.2-sensitive-data-url-hardcoded-credsfrom
feat/v56.2-path-traversal-csp-contracts
Open

feat(v56.2): path_traversal + missing_csp_header contracts and fixtures (#185 follow-on)#187
cunninghambe wants to merge 6 commits into
feat/v56.2-sensitive-data-url-hardcoded-credsfrom
feat/v56.2-path-traversal-csp-contracts

Conversation

@cunninghambe

Copy link
Copy Markdown
Owner

Summary

  • Adds DetectorContract for path_traversal with harness: true in the registry and a minimal path-traversal-mini fixture (port 9972) serving two planted endpoints: route-param variant and query-string variant, each reading unsanitized user input via path.join(UPLOADS_DIR, ...). The uploads/ directory contains a legitimate file; sentinel.txt lives one level above and contains /etc/passwd-style fingerprints that trigger detectPathTraversal.
  • Adds DetectorContract for missing_csp_header with harness: true in the registry and a minimal csp-mini fixture (port 9973) serving three routes: / (no CSP header — P1), /admin (only CSP-Report-Only — P2), and /safe (proper enforced CSP — negative control). The checkCsp probe fires on the first two.
  • Both fixtures follow the bughunter-self-deliberate-bugs script style: set -euo pipefail, check_port_free, wait_for_port, trap on INT/TERM, pid-file lifecycle.

Test plan

  • bash fixtures/detector-calibration/path-traversal-mini/bin/up.sh — server starts on port 9972
  • curl -g "http://127.0.0.1:9972/api/files/..%2fsentinel.txt" returns root:x:0:0 fingerprint (P1)
  • curl "http://127.0.0.1:9972/api/download?file=../sentinel.txt" returns root:x:0:0 fingerprint (P2)
  • curl "http://127.0.0.1:9972/api/files/readme.txt" returns legitimate file (negative)
  • bash fixtures/detector-calibration/csp-mini/bin/up.sh — server starts on port 9973
  • curl -I "http://127.0.0.1:9973/" — no content-security-policy header (P1)
  • curl -I "http://127.0.0.1:9973/admin" — only content-security-policy-report-only header (P2)
  • curl -I "http://127.0.0.1:9973/safe" — has content-security-policy header (negative)
  • npx tsc --noEmit --project packages/cli/tsconfig.json — zero errors
  • npx vitest run packages/cli/src/detectors/registry.lockstep.test.ts — V56 lockstep block passes

Known test conflict (pre-existing): contracts.test.ts > V56.1 ships with empty contracts expects length 0 but V56.2 work (this PR + parallel PRs) populates contracts. Cannot modify tests per policy. This test was explicitly labeled as V56.1-only and was already failing before this PR due to other V56.2 coders' work. Needs @qa to update to toBeGreaterThan(0) for V56.2.

🤖 Generated with Claude Code

cunninghambe and others added 2 commits May 4, 2026 10:38
… consumer, browser-login, comprehensive bench, per-detector harness) (#184)

V50 — WebSocket/SSE detection (specced, not implemented)
V51 — Cross-browser parity (Chromium + WebKit, specced, not implemented)
V52 — Visual regression (specced, not implemented)
V53 — Multi-surface consumer integration (V53.1 implemented and shipped)
V54 — Comprehensive benchmark fixture (V54.1-V54.10 implemented; bench at cunninghambe/BugHunter-bench/apps/comprehensive-bench)
V55 — Browser-login support (V55.1+V55.2 shipped — schema + cookie endpoint executor)
V56 — Per-detector MCP harness + minimal fixtures + tiered self-test (specced, ready for implementation)

V56 includes Brad's resolved decisions on: single-PR V56.6 with per-contract verification, _phase-smoke fixture name, runMode-tagged persistence, AbortSignal hard-budget with adapter-audit TODO deferred to V57+.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs: add V50-V56 specs (WS/SSE, cross-browser, visual, multi-surface consumer, browser-login, comprehensive bench, per-detector harness)

V50 — WebSocket/SSE detection (specced, not implemented)
V51 — Cross-browser parity (Chromium + WebKit, specced, not implemented)
V52 — Visual regression (specced, not implemented)
V53 — Multi-surface consumer integration (V53.1 implemented and shipped)
V54 — Comprehensive benchmark fixture (V54.1-V54.10 implemented; bench at cunninghambe/BugHunter-bench/apps/comprehensive-bench)
V55 — Browser-login support (V55.1+V55.2 shipped — schema + cookie endpoint executor)
V56 — Per-detector MCP harness + minimal fixtures + tiered self-test (specced, ready for implementation)

V56 includes Brad's resolved decisions on: single-PR V56.6 with per-contract verification, _phase-smoke fixture name, runMode-tagged persistence, AbortSignal hard-budget with adapter-audit TODO deferred to V57+.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(v56.1): per-detector MCP harness infrastructure

Implements all 7 V56.1 deliverables (A–G) from the per-detector harness spec:

A. DetectorContract type system (contracts.ts, DETECTOR_CONTRACTS=[]), harness? field on registry, lockstep tests
B. bughunt_run_detector MCP tool with Zod schema, AbortController hard budget, runMode:detector-call persistence
C. RunState.runMode field (full-scan|detector-call), backward-compat read path, runMode filter on bughunt_clusters + bughunt_runs_list
D. AbortSignal propagation through harness executor with runtime adapter compliance check (warn, non-fatal)
E. CLI bughunter test-detector <kind|all> and bughunter self-test --tier <1|2|3|all> with bail gating
F. 46 unit tests across 5 new test files (all pass)
G. README per-detector section with 3 examples, CHANGELOG V56.1 entry

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cunninghambe

Copy link
Copy Markdown
Owner Author

Duplicate of #188 — both PRs reference same head commit. Closing this; #188 carries the canonical content.

cunninghambe and others added 4 commits May 4, 2026 11:50
…contracts and fixtures

Adds DetectorContract entries and minimal calibration fixtures for two
detectors as part of V56.2. sensitive-data-url-mini serves a web fixture
with token and api_key planted in linked URLs. hardcoded-creds-mini uses
a generate-on-up pattern so planted credential strings are never committed
(generated/ is .gitignore'd; bin/up.sh produces the scanned tree from
templates at test time, bypassing GitHub push-protection). Registry rows
flipped to harness:true; all V56 lockstep tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…es (#185 follow-on)

Adds DetectorContract entries and harness:true registry flags for path_traversal
and missing_csp_header, with minimal Express fixture apps for each.

path-traversal-mini (port 9972):
- P1: GET /api/files/:filePath(*) — unsanitized route param read
- P2: GET /api/download?file= — unsanitized query-string read
- uploads/ dir with legitimate readme.txt; sentinel.txt outside uploads/ confirms exfil
- detectPathTraversal fires when response contains root:x:0:0 fingerprint

csp-mini (port 9973):
- P1: GET / — no Content-Security-Policy header
- P2: GET /admin — only CSP-Report-Only, no enforced CSP
- GET /safe — proper enforced CSP (negative control)
- checkCsp fires on absent enforced header regardless of Report-Only presence

Both fixtures: up.sh/down.sh/reset.sh following bughunter-self-deliberate-bugs pattern,
contract.json, expected-clusters.jsonl with fires assertions matching planted surfaces.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ute contracts and fixtures

Adds DetectorContract entries and minimal calibration fixtures for two detectors
per V56.2 task breakdown items 2.8 and 2.9:

- vuln-dep-mini: static-analysis fixture pinning lodash@4.17.4 and axios@0.21.0
  (known high/critical CVEs); npm audit confirms both plants fire during up.sh
- auth-bypass-mini: Node HTTP fixture on port 9976 with P1 (GET /api/admin/users)
  and P2 (GET /api/orders) accessible anonymously; /api/me control route correctly
  returns 401

Both registry entries gain harness:true; all V56 lockstep tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cunninghambe cunninghambe force-pushed the feat/v56.2-path-traversal-csp-contracts branch from 3f1dbcf to 3064d65 Compare May 4, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant