Skip to content

fix(hooks): stop reporting Claude built-in MCP servers as unknown; add ccd_turn - #465

Merged
zeus-12 merged 3 commits into
stagingfrom
vv/ccd-turn-builtin
Nov 30, 2026
Merged

zeus-12 merged 3 commits into
stagingfrom
vv/ccd-turn-builtin

Conversation

@zeus-12

@zeus-12 zeus-12 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Before: every call to a Claude built-in MCP tool (Claude_Browser, ccd_session_mgmt, and Claude Desktop's ccd_turn) made the Claude Code hook report "unknown mcp server with no resolvable config" to Sentry. That is the top ai-gateway issue: AI-GATEWAY-57Q (ccd_turn, 16k events), plus 37V and 19R.

After: the hook stays quiet for known Claude built-ins, and ccd_turn is a built-in. A server the hook really can't resolve, such as toolchain-agentcore (AI-GATEWAY-4Q4), still reports.

Built-ins are runtime-provided and never have a config, so a missing config is expected for them. The gateway already names them claude-builtin:<name> from the bare name.

How

  • claude-code/hooks/unbound.py: the miss report skips servers where claude_builtin_identity() is set.
  • Every hook's built-in map (claude-code, codex, copilot, augment, antigravity, cursor) gains ccd-turn.
  • Tests: test_pretool_mcp.py checks built-ins don't report and a custom unresolved server still does; the parity suite checks every hook maps ccd_turn to claude-builtin:ccd-turn.

Red, then green (new tests only)

  • Before the fix: 21 failed (each built-in reported a miss; 6 hooks x 3 spellings had no ccd-turn identity).
  • After: 3 passed, 21 subtests passed. Full suite: the only failures are folder-permission tests that also fail on staging when run as root.

Companion PRs (same branch name): ai-gateway, ai-gateway-data, coding-discovery-tool add ccd-turn to their built-in maps.


Generated by Claude Code

Unbound Review · Score 5/5 (no findings) · 3340b16

  • codex (own score 5/5): The PR adds ccd-turn to the built-in identity maps and suppresses unresolved-server diagnostics for recognized Claude built-ins. The changed paths and their tests did not reveal a substantive defect.
  • claude (own score 5/5): The PR stops the Claude Code hook from reporting 'unknown mcp server with no resolvable config' (to Sentry, plus a diagnostic dispatch) for Claude built-in MCP servers. It also adds ccd-turn to the built-in map in all six hooks. I found no problems. The skip uses the same claude_builtin_identity() the hooks already use to fingerprint built-ins, every copy of the map is updated, and the Claude Code hook is the only place that reports the miss,

findings: 0 P0 · 0 P1 · 0 P2 (top 5 P0/P1 inline) · engines: codex ✅ · claude ✅

…lt-ins as unknown MCP servers

Claude built-ins (Claude_Browser, ccd_session_mgmt, ccd_turn) are runtime-provided
and never have a config, so the PreToolUse hook reported every call to them as
'unknown mcp server with no resolvable config' (Sentry AI-GATEWAY-57Q, 37V, 19R).
Skip that report for known built-ins and add ccd-turn to every hook's built-in map.
@zeus-12
zeus-12 requested a review from a team November 30, 2026 13:29

@vigneshsubbiah16 vigneshsubbiah16 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Automated Security Review (consensus)

1 finding: 0 high-confidence, 1 to triage. Reviewers: Claude (lead), Semgrep, Gitleaks.

  • [LOW] A custom MCP server can claim the reserved ccd_turn name and be treated as a built-in 🟡 — claude-code/hooks/unbound.py:2396 (the same map entry exists in the antigravity, augment, codex, copilot and cursor hooks)
    • What: The hook decides a server is a built-in from its name alone. After this PR, any server named ccd_turn, ccd-turn or CCD Turn gets the identity claude-builtin:ccd-turn. A user or a project .mcp.json can register a server with that name. The new parity test confirms this: compute_mcp_cache_key(name, None, None, []) returns the built-in key without looking at any config.
    • Why: If org policy allows or does not fingerprint claude-builtin:* identities, a server registered under this name could get past MCP sanctioning. Its calls would be recorded under the trusted built-in identity. The change at claude-code/hooks/unbound.py:4372 also removes the "unknown mcp server with no resolvable config" report for these names, so the swap would be quieter. ⚠️ This is only shown for the config-less path. The diff does not show whether a server that has a real launch config (a command or URL) under this name still maps to the built-in key, or whether the gateway treats built-ins as allowed by default.
    • Fix: Give the claude-builtin: identity only when the server has no user-defined config (mcp_server_config is empty). A server with a resolved command or URL should keep its launch fingerprint even when its name matches a built-in. Add a parity test where ccd_turn has a stdio config and check that it does not return claude-builtin:ccd-turn.
    • Flagged by: Claude (lead)

Not raised as PR findings

  • None of the Semgrep hits are on lines this PR adds or changes. They are listed here only for completeness:
    • insecure-file-permissions on 0o700 (5 hook files): this is a false positive. 0o700 gives access to the owner only, which is stricter than the 0o644 the rule suggests.
    • python36-compatibility-Popen2 at claude-code/hooks/unbound.py:1683: this is a compatibility note, not a security issue.
    • sqlalchemy-execute-raw-query at cursor/unbound.py:1096: this code was already there and the PR does not touch it. ⚠️ It was not checked here, because that code is not in the diff.

🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 80b83e1e · 2026-11-30T13:35Z

zeus-12 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Re the LOW finding (a custom server named ccd_turn treated as a built-in): I traced both of the points it couldn't see from the diff.

  • A configured server keeps its launch fingerprint. compute_fingerprint gives the claude-builtin: identity only under if not command and not url and not safe_args, which is what the suggested fix asks for and is already there. Checked on this branch:
    • compute_mcp_cache_key('ccd_turn', None, None, []) gives claude-builtin:ccd-turn
    • compute_mcp_cache_key('ccd_turn', 'npx', None, ['-y', 'some-pkg']) gives npm:some-pkg
    • compute_mcp_cache_key('ccd_turn', None, 'https://evil.example/mcp', []) gives url:evil.example/mcp
    • with a local script and its hash, it gives script:<hash>
  • Built-ins are not allowed by default. In ai-gateway, claude-builtin:* only names the fingerprint (src/services/mcpFingerprint.ts). Sanctioning treats it like any other group, so under BLOCK ccd_turn is allowed only when its "Claude Code Turn" group is sanctioned (see the new test in websentry-ai/ai-gateway#1238).
  • The warning skip at unbound.py:4374 applies only when the hook resolved no config. That is the same case the gateway already names claude-builtin:<name>, and it matches how the existing built-ins (Claude_Browser, ccd_session_mgmt, ...) behave today.

What's left is a server that has a real config the hook fails to resolve. That gap already applies to every built-in name and isn't new here. I'm leaving this open for a human to decide rather than changing code.


Generated by Claude Code

zeus-12 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

/review


Generated by Claude Code

@vigneshsubbiah16 vigneshsubbiah16 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Automated Security Review (consensus)

1 finding: 0 high-confidence, 1 to triage. Reviewers: Claude (lead), Semgrep, Gitleaks.

  • [LOW] Built-in name ccd_turn can be claimed by a custom server whose config is not resolved 🟡: claude-code/hooks/unbound.py:4372
    • What: This PR adds ccd-turn to the built-in map in all six hooks. It also stops the "unknown mcp server with no resolvable config" report for any server name that claude_builtin_identity() recognizes. As a result, a server named ccd_turn that the hook cannot resolve is now silently labelled claude-builtin:ccd-turn.
    • Why: Say a real custom or malicious server is named ccd_turn (or CCD Turn, ccd-turn) and the hook fails to resolve its config. It then gets the built-in fingerprint. If an org has sanctioned the "Claude Code Turn" group, it inherits that decision. This PR also removes the Sentry miss report and the diagnostic dispatch, which were the only signal that a name-only match happened. The PR author argues three points: configured servers keep their launch fingerprint (npm:, url:, script:); built-ins are not allowed by default; and the same gap already exists for every other built-in name. That reduces the impact. ⚠️ The author's comment carries no maintainer authority, and this diff does not show the gateway side, so those points are not confirmed here.
    • Fix: Choose one of these:
      • Keep the suppression, but only after checking a runtime signal that the server really is the Claude Desktop built-in (for example, client/app identity in the event), not the name alone.
      • Or downgrade the miss to a low-volume or sampled breadcrumb instead of dropping it. That keeps a signal when a name matches a built-in but the source is unknown.
    • Flagged by: Claude

🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head ab9702d6 · 2026-11-30T13:46Z

zeus-12 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

/review


Generated by Claude Code

@vigneshsubbiah16 vigneshsubbiah16 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Automated Security Review (consensus)

1 finding: 0 high-confidence, 1 to triage. Reviewers: claude, semgrep, gitleaks.

  • [LOW] A custom server named ccd_turn with no resolved config is treated as the Claude built-in and stops reporting 🟡 (claude-code/hooks/unbound.py:4372, plus the ccd-turn entry added to the built-in map in all six hooks)
    • What: Adding ccd-turn to the built-in map does two things for any MCP server called ccd_turn / ccd-turn / CCD Turn whose config the hook can't resolve. The server gets the fingerprint claude-builtin:ccd-turn. And the new claude_builtin_identity() guard drops the "unknown mcp server with no resolvable config" log and diagnostic for it.
    • Why: An attacker-supplied server that copies this name could be grouped with the sanctioned "Claude Code Turn" built-in. It would also no longer show up in Sentry or the diagnostic dispatch, which is the signal that would expose a config-resolution gap. The PR author says a configured server keeps its launch fingerprint (npm: / url: / script:), and that built-ins are not allowed by default. That matches the compute_mcp_cache_key cases they list, but this diff doesn't show it. What's left is the case where a server has a real config the hook fails to resolve. That gap is not new (it already applies to Claude_Browser, ccd_session_mgmt, …), but this PR widens it to one more name.
    • Fix: Keep the miss report for built-in names when there is any sign of a user-defined server. Check whether the name appears in a config file or plugin dir that failed to parse, and report in that case. Or downgrade the report to a lower-severity log for built-ins instead of dropping it. A maintainer should decide whether the leftover risk is acceptable.
    • Flagged by: claude. The PR author's reply ([MEMBER] [PR AUTHOR]) disputes this, but the PR author's own reply can't suppress a finding, and it explicitly leaves the decision to a human.

Pre-existing (not introduced by this PR)

  • Semgrep insecure-file-permissions (0o700) in all six hooks, Semgrep python36-compatibility-Popen2 (claude-code/hooks/unbound.py:1683) and Semgrep sqlalchemy-execute-raw-query (cursor/unbound.py:1096): this diff doesn't touch any of these lines. 0o700 (owner-only access) is stricter than Semgrep's suggested 0o644, so that rule is a false positive.

🤖 consensus review · reviewers: Claude, Semgrep, Gitleaks · head 3340b163 · 2026-11-30T15:04Z

@zeus-12
zeus-12 merged commit a53ba6c into staging Nov 30, 2026
5 checks passed
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.

5 participants