Repository navigation
feat(discovery): report skipped scans and hook policy [WEB-6392] - #440
Conversation
…files and hash churn [WEB-6392]
… deadline [WEB-6392]
…budget [WEB-6392]
…ing our hook [WEB-6392]
…s our hook [WEB-6392]
…ecides [WEB-6392]
|
/review |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
🛡️ Automated Security Review (consensus)
1 finding — 0 high-confidence, 1 to triage. Reviewers: Claude, Semgrep, Gitleaks.
- [LOW]
has_our_hookcan be faked from files the user controls 🟡 —scripts/coding_discovery_tools/hook_policy.py:262- What:
_runs_our_hookcounts~/.claude/hooks/unbound.pyas a hook target whenever any file exists at that path. The top-ranked "console" source is also read from~/.claude/remote-settings.json, which is in the user's own home folder. So a non-admin user can produceoverriding_policy: "console"withoverriding_policy_has_our_hook: trueandhooks_disabled: false. - Why: The PR exists to catch broken or missing hooks. A user who swaps in a no-op
unbound.pyand writes a cached console policy that points at it gets reported as protected. The backend would then show a working Unbound hook on a device where none really runs.⚠️ Whether Claude Code itself trusts a hand-editedremote-settings.jsoncan't be seen from this diff. The script-swap case holds either way. - Fix: Report where the evidence came from (for example
source_writable_by_user: true), so the backend can weigh user-writable sources lower. Also consider requiring the per-userunbound.pyto be owned by root or to match a known hash before it counts.hooks_extractor.root_ownedis already imported elsewhere in this PR. - Flagged by: Claude
- What:
Pre-existing (not introduced by this PR)
- Semgrep
python-logger-credential-disclosureatutils.py:2348andutils.py:2357. This PR does not touch these lines. They log the credentials file path and the parse error, not the credential value. Not raised as a finding.
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 9c2eca63 · 2026-11-26T11:38Z
…fake the os only in hook_policy tests [WEB-6392]
|
/review code |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
✅ Security consensus: no issues found. (reviewers: claude, semgrep, gitleaks)
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 85dc0e09 · 2026-11-26T12:05Z
…at the scan ended, fix windows test fakes [WEB-6392]
|
/review code |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
🛡️ Automated Security Review (consensus)
1 finding — 0 high-confidence, 1 to triage. Reviewers: claude, semgrep, gitleaks.
- [LOW] "Console" hook policy is read from a file the user can write 🟡 —
scripts/coding_discovery_tools/hook_policy.py:106- What:
_claude_code_policyranks~/.claude/remote-settings.jsonas the top admin source ("console"). It reads that file from the user's own home folder. The values it produces (overriding_policy,overriding_policy_has_our_hook,merge_sources_enabled,hooks_disabled) are then reported as admin-policy facts. - Why: A local user without admin rights can write or edit that cache. They could make the backend show
overriding_policy: "console"withhas_our_hook: true, which hides the broken-hook case this PR is meant to surface. They could also invent a console override. The MDM sources (/Library/Managed Preferences, HKLM) and the managed-settings directory are owned by root or admin, so they don't have this problem.⚠️ How much this matters depends on whether Claude Code itself trusts a cache the user edited. That can't be seen from this diff. - Fix: Mark values that come from the user-writable cache as user-controlled. One option is a separate label such as
"console_cache"plus a flag saying who owns the file. Another is to check that the file is not writable by the user before treating it as authoritative. In the backend, don't treathas_our_hook: truefrom this source as proof that the hook is enforced. - Flagged by: claude
- What:
Pre-existing (not introduced by this PR)
- semgrep
python-logger-credential-disclosureatscripts/coding_discovery_tools/utils.py:2348and:2357: this PR does not touch these lines. The log calls record a file path and an exception message, not the contents of the credential, so this is very likely a false positive.
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 57ef787f · 2026-11-26T12:23Z
…vice id [WEB-6392]
|
/review code |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
✅ Security consensus: no issues found. (reviewers: Claude (lead), Semgrep, Gitleaks)
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 4d805439 · 2026-11-26T12:42Z
|
/review code |
…n that interpreter can run [WEB-6392]
|
/review code |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
✅ Security consensus: no issues found. (reviewers: claude, semgrep, gitleaks)
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 0d4688f5 · 2026-11-26T15:43Z
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
✅ Security consensus: no issues found. (reviewers: claude, semgrep, gitleaks)
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 9e9cafb9 · 2026-11-26T16:03Z
… with nested values [WEB-6392]
|
/review code |
…ple quote [WEB-6392]
|
/review code |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
✅ Security consensus: no issues found. (reviewers: claude, semgrep, gitleaks)
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 381cab56 · 2026-11-26T16:34Z
|
/review code |
|
/review code |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
🛡️ Automated Security Review (consensus)
1 finding: 0 high-confidence, 1 to triage. Reviewers: Claude, Semgrep, Gitleaks.
- [MEDIUM] Quadratic-time TOML fallback parser lets a local user stall the root-run scan 🟡 —
scripts/coding_discovery_tools/hook_policy.py:428- What: On Python versions before 3.11,
_multiline_string_left_opencounts backslashes withline[:end]andline[:end].rstrip("\\")on every escaped"""it finds. Each of those calls copies the line up to that point, so one long line full of escaped"""takes quadratic time. - Why:
~/.codex/config.tomlis user-writable, and discovery reads it as root through_toml_hooks_feature_by_line. That parser is the main path on macOS, where the systempython3is 3.9. The 2 MB size cap still allows one line of about 500k\"""repeats, which works out to roughly 10^11–10^12 byte copies. That blocks the per-user loop for hours. Meanwhile the new 120-secondin_progressheartbeat keeps the scan looking alive. So any user can blind device-wide discovery on every run until the run's self-timeout.⚠️ TestHostileFileshas a one-second limit, but it is cut off in this diff. I could not check whether it covers this input.
- Fix:
- Count the backslashes by walking back from
end(j = end - 1; while j >= 0 and line[j] == "\\": j -= 1) rather than slicing the line. - Also cap the line length or the total parse work in the line parser, and return
_UNREADABLEwhen the cap is hit. - Add a hostile-file test with
'x = """' + '\\"""' * 500_000on the line parser.
- Count the backslashes by walking back from
- Flagged by: Claude
- What: On Python versions before 3.11,
Previously acknowledged (not re-flagged)
- Telemetry is read from lower-priority managed sources (
hook_policy.py:183). The thread was opened by @vigneshsubbiah16 [MEMBER]. Only the PR author answered, and that reply is not a maintainer decision. I am still not re-flagging it, because the reply points to Claude Code's documented per-variable merge ofenvacross admin sources. I could not see the docs it cites. Either way, this is about report accuracy, not a security issue.
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 11262028 · 2026-11-26T16:52Z
… a root scan [WEB-6392]
|
/review code |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
🛡️ Automated Security Review (consensus)
1 finding: 0 high-confidence, 1 to triage. Reviewers: claude, semgrep, gitleaks.
- [LOW] Quadratic-time TOML fallback parser lets a user stall the scan 🟡 —
scripts/coding_discovery_tools/hook_policy.py:470- What: The pre-3.11 line parser can take quadratic time on one long line. On every
"""found inside an open multi-line string,_multiline_string_left_opencopies the line up to that point (line[:end]) and strips it. A line full of\"""sequences makes the parser do this copy once per sequence. - Why: The input is
~/.codex/config.toml, which the user controls. It is read withfollow_symlinks=Trueand capped at_MAX_POLICY_SIZE(2 MB). On Python 3.9/3.10 this fallback is the main path (macOS system python3 is 3.9). A single 2 MB line holds hundreds of thousands of\""", and each one triggers a copy of up to 2 MB. That pins the CPU until the run's self-timeout fires. The parser runs inside the per-tool loop, so the run is marked failed. On a multi-user device, reports for other users and tools after that point are never sent. One unprivileged user can therefore keep blocking discovery reports for the whole device, even when discovery runs as root. - Fix: Count the backslashes before
endby walking backward fromend - 1, without slicing. Also skip or reject any line longer than a sane limit (for example 64 KB) before scanning it, and treat it as_UNREADABLE. - Flagged by: claude
- What: The pre-3.11 line parser can take quadratic time on one long line. On every
Pre-existing (not introduced by this PR)
- The two Semgrep
python-logger-credential-disclosurehits atscripts/coding_discovery_tools/utils.py:2349and:2358are on lines this diff does not touch. They log a file path and a parse error, not the credential value. Not raised as PR findings.
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 83f43d60 · 2026-11-26T17:13Z
… is missing [WEB-6392]
|
/review code |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
✅ Security consensus: no issues found. (reviewers: claude, semgrep, gitleaks)
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 164cc46c · 2026-11-26T19:51Z
… send_scan_event [WEB-6392]
|
/review |
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
✅ Security consensus: no issues found. (reviewers: Claude, Semgrep, Gitleaks)
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head f372e1e0 · 2026-11-27T17:19Z
…vents in tests [WEB-6392]
vigneshsubbiah16
left a comment
There was a problem hiding this comment.
✅ Security consensus: no issues found. (reviewers: Claude (lead), Semgrep, Gitleaks)
🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head ada160ef · 2026-11-30T11:12Z
* feat(discovery): report skipped scans and hook policy [WEB-6392] (#440) * Group discovery errors in GlitchTip by code path, not scan folder (WEB-6914) (#449) * Group discovery errors in GlitchTip by code path, not scan folder (WEB-6914) The GlitchTip copy gets a fingerprint of error type, agent frames and HTTP code, so the per-scan temp folder no longer opens a new issue each scan. The Sentry copy is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Split GlitchTip network-failure issues by curl exit code (WEB-6914) DNS, refused and TLS failures each get their own GlitchTip issue instead of one shared one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Iyad Zargar <dev@iyadzargar.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Refs WEB-6392
What
skippedreport with a reason. Before, it sent nothing and the backend later marked the scan as timed out.in_progressheartbeat every 120 seconds.hook_policyobject for each tool, withhas_our_hooktrue only when a working Unbound hook is on the device.skippedwith a reasonhas_our_hook: falseWhy
How
hook_policy.pyreads each tool's settings, merges managed-settings drop-ins the way Claude Code does and resolves the hook program. It nulls only the keys that an unreadable file decides.ai_tools_discovery.pysends heartbeats on their own send budget. A failed heartbeat never uses the final report's budget and never goes to Sentry.Testing
python3 -m pytest tests/: 3,805 passed, 30 skipped, 0 failedinstall.ps1on a Windows Server 2022 Azure VM as SYSTEM: hook policymdmwith our hook, a skipped scan while another scan ran, and a heartbeat at 120 secondsProof
3805 passed, 30 skipped, 610 subtests passed in 237.19son this branch, rebased ontostaging.Risk and rollout
skippedscan with 400 and dropshook_policy.Unbound Review · Score 4/5 (P2s only) ·
f372e1eskippedscan event; on Linux it does this without creating a device id. A daemon thread re-sendsin_progressevery 120 s and is stopped before the completed, failed or abort report. A newhook_policyobject, built from the Claude Code, Codex and VS Code settings files, is added to each tool's report. I traced the heartbeat's start and stop points in main(), how itfindings: 0 P0 · 0 P1 · 2 P2 (top 5 P0/P1 inline) · engines: codex ✅ · claude ✅
Findings not posted inline
tests/test_scan_outcomes.py:291Use localhost servers for transport tests — The heartbeat failure test mocks the subprocess used to invoke curl instead of exercising a real local HTTP server. (codex)tests/test_scan_outcomes.py:206Mock sleeps in the new tests — The new heartbeat tests use real sleeps, including repeated waits for background activity. (codex)rules applied: CLAUDE.md