Repository navigation
feat(mcp): fingerprint tool schemas and report provider-binding overlaps - #315
raymondginger2018-sudo wants to merge 1 commit into
Conversation
|
Requesting a security review from @Zongwei9888. This touches the MCP tool-selection surface, so I want to be explicit about two process points before anyone wonders whether I skipped them:
So this comment is the review request. The security reasoning is in the PR body ("Security Considerations"): no new attack surface, the only new behaviour is a warning, the failure mode is fail-safe, and nothing here pretends to authenticate a provider — there is no PKI, so this makes misbinding observable rather than preventing it. The signed manifests the paper suggests were deliberately not stubbed. Scope of what changed, for review convenience: one new string field on |
MCP tool metadata is not bound to a provider: a second server can advertise a tool a model cannot tell from the real one (arXiv:2611.21577). Two servers exposing the same tool name, or the same input schema, are indistinguishable to the selector -- and schema compatibility is the paper's strongest amplifier (violation rate 0 -> ~0.78 in its C09/C10 contrast). - `McpToolIdentity.schema_digest`: a canonical sha256 of the normalised input schema, so providers can be compared on substance instead of on a name they both choose freely. Defaulted, so existing construction sites keep working. - `find_identity_collisions()`: name/schema overlap across *distinct* servers. One server repeating itself is a different bug and is not reported. - `McpSessionRuntime.identity_collisions`: the same signal as a property, so callers do not have to parse logs. Reported as a warning only. There is no client-side provider identity to reject on, and a legitimate deployment may expose the same capability twice -- refusing to register would turn observability into an outage. Tests: unit coverage for digest stability and the collision rules, plus an integration test that runs two real stdio servers and asserts both stay ready with all six tools registered.
1c016ab to
29b6148
Compare
Summary
Two properties the agent harness can currently only assume, made observable:
mcp__<server>__<tool>naming does not help — it deduplicates names, it does not establish origin. This adds a stable schema fingerprint and reports cross-server overlap (name or input shape). Warning only: there is no client-side provider identity to reject on, and refusing to register would break legitimate duplicate deployments.GoalVerdictalready rejected unsupported claims, but one boolean could not distinguish "no record backs this" from "a record contradicts this". The paper this comes from reports exactly that collapse as its detector's one false alarm.faithfulnessis now recorded next toresultas a separate axis; task success stays with the Goal's own state.Background: arXiv:2611.21577 (When Tool Names Are Not Identities) measures provider misbinding and finds schema compatibility is its strongest amplifier (violation rate 0 → ~0.78 in the C09/C10 contrast). arXiv:2611.25760 (Characterizing and Detecting Unfaithful Work Reports by Coding Agents) finds 37.24% of 435 sampled reports contain at least one unsupported claim (overstated task success 69.3%), and states the separation directly: task success and reporting faithfulness are distinct properties.
Changes
core/mcp/naming.pyschema_digest(schema)— canonical sha256 (12 chars) of the normalised input schema:sort_keys, compact separators, non-ASCII preserved. An absent schema digests to a fixed value rather than raising.IdentityCollision+find_identity_collisions(entries)— name/schema overlap across distinct servers. One server repeating itself is a different bug and is not reported; an empty digest never collides.core/mcp/models.pyMcpToolIdentity.schema_digest: str = ""— defaulted, so existing construction sites keep working.core/mcp/tools.pycore/mcp/runtime.py(server_id, raw_name, digest)per registration._publish_identity_collisions()warns once per new overlap;identity_collisionsexposes the same signal as a property so callers need not parse logs.core/agent_runtime/goal_verifier.pyGoalVerdict.conflict— a rejection now says whether a record contradicts the claim or merely fails to support it.GoalVerdict.faithfulness— derived from the two booleans (supported/unsupported/contradicted), never stored, so the three can never disagree.review_record()carriesfaithfulnessnext toresult; an unavailable review recordsunassessedinstead of guessing.Tests
tests/test_mcp_identity_binding.py(new, 11 cases): digest stability under key reordering, shape sensitivity, absent-schema handling; collision rules (two servers collide, one server does not, empty digest does not).tests/test_mcp_runtime.py(+1 integration case): runs two real stdio servers from the same fixture, asserts the overlap is reported and that both servers stayreadywith all six tools registered — the fail-safe property, not just the detection.tests/test_goal_report_faithfulness.py(new, 7 cases): the insufficient/contradiction split, the three derived states, and the record carrying both axes.29 passedon a clean worktree ofmainat80634442(the three files above).ruff format --checkclean on all 8 files.Compatibility / dependency note
McpToolIdentity.schema_digestandGoalVerdict.conflictboth default, so nothing that constructs them breaks.confirmedkeeps its exact meaning;faithfulnessis a derived view of it andconflict.Security Considerations
This touches the MCP tool-selection surface, so, explicitly:
find_identity_collisionswere wrong, the effect would be a missing or spurious warning — never a blocked or redirected tool call.logger.warningwhen two servers advertise an indistinguishable tool. Nothing else.I could not add the
securitylabel or request a reviewer from a fork (no write access) — flagging here instead as the repository's contributing guide asks.Results of the local CI replay for this revision are recorded in
.deepcode/verification.md(append-only) andlogs/verdicts/.