Skip to content

fix(security): identical tool definitions across servers are not a shadowing clone - #1838

Merged
Dumbris merged 2 commits into
mainfrom
fix/shadowing-identical-duplicates
Nov 7, 2026
Merged

Dumbris merged 2 commits into
mainfrom
fix/shadowing-identical-duplicates

Conversation

@Dumbris

@Dumbris Dumbris commented Nov 7, 2026

Copy link
Copy Markdown
Member

Why

v0.73.0-rc.1's QA gate went red (run 42352688067): matrix cells stdio/http/docker failed call-mcp with TOOL_QUARANTINED / new_unapproved_tool, and the Web UI sweep saw Not callable · Needs review instead of Callable.

Root cause (reproduced locally on the RC binary): R2-1 (#1714) scan-gates a trusted server's first-discovery baseline, and detect.shadowing.cross_server fires HARD on "same name + near-identical description" — which three instances of the same fixture produce. It is symmetric, so every instance is held, held_verdict: dangerous. The same thing happens to a user who adds one MCP server twice (two filesystem roots, two GitHub orgs) on 0.73; existing servers are unaffected (they already have a baseline marker).

What

A same-named peer whose raw description and input/output schemas are equal (JSON compared structurally, so key order does not matter) is a second instance of the same software, not a clone: identicalDefinition skips it for both the HARD clone shape and the SOFT name-squat shape. Any edit at all — one word, one schema property — is judged by cloneDescriptions exactly as before.

  • Tests: identical ×3 → no signal; schema key order irrelevant; identical description + widened schema → still HARD; an identical pair next to a near-clone → the near-clone still flags and the pair is still flagged by it. The two existing tests whose premise was "byte-identical is the HARD clone" now use a cosmetic edit.
  • Corpus: hard negative hn_shadowing_identical_instance in detect_corpus_v1.json + the bundled self-check copy. scan-eval --gate and --review-gate pass at recall 1.0 / fp 0.0.
  • Docs: docs/features/tool-scanner.md clone paragraph.

Verified

go test -race ./internal/security/..., ./internal/runtime baseline tests, golangci-lint v2 (CI config) clean. Live: fixed core + 3 trusted servers with an identical 2-tool set → all approved, review queue 0 (the RC held all 6 as dangerous).

Unblocks v0.73.0-rc.2.

…adowing clone

Two instances of one MCP server (two filesystem roots, two GitHub orgs, the
release gate's mcpfixture x3) expose byte-identical tool definitions. Since
R2-1 (#1714) scan-gates the first-discovery baseline, shadowing.cross_server
held every one of those tools as "dangerous - possible impersonation" on
trusted servers, which turned the v0.73.0-rc.1 QA gate red (matrix cells
stdio/http/docker, Web UI sweep) and would do the same to users on 0.73.

The clone shape exists to catch a copy with injected or rewritten prose; an
identical copy has none, and server:tool namespacing keeps the two reachable
apart. A same-named peer whose raw description and input/output schemas are
equal (JSON compared structurally) is now skipped by both the HARD clone and
the SOFT name-squat shape. Any edit at all - one word, one schema property -
is judged by cloneDescriptions exactly as before (pinned by tests, including
the identical-description/widened-schema and identical-pair-plus-near-clone
cases).

Corpus: hard negative hn_shadowing_identical_instance (master + bundled
self-check copy); both scan-eval gates pass at recall 1.0 / fp 0.0. The two
tests whose premise was "byte-identical is the HARD clone" now use a
cosmetic edit.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

@Dumbris
Dumbris enabled auto-merge (squash) November 7, 2026 14:59
…es, not byte-identical

TestAttackerStageOneTriggersEveryEngineCheck expected shadowing.cross_server
on the attacker's filesystem_read, which copied the victim's description
byte-for-byte - exactly the second-instance shape the detector now exempts.
The vector keeps its purpose with one cosmetic edit (trailing punctuation),
which cloneDescriptions does not let launder the copy; the README row and
the simulated-call note say so. Same edit for cmd/tpa-redteam's shadow-clone
vector so its BaselineWant stays honest.
@Dumbris
Dumbris merged commit f8b3c59 into main Nov 7, 2026
50 checks passed
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 76.19048% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/tpa-redteam/main.go 0.00% 2 Missing ⚠️
internal/security/detect/checks/shadowing.go 88.88% 1 Missing and 1 partial ⚠️
tests/tpa-attack-lab/catalog.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

2 participants