Skip to content

fix(mcp): reject duplicate envelope members - #76

Open
Kathircpe wants to merge 1 commit into
prooflinedev:mainfrom
Kathircpe:fix/mcp-duplicate-envelope-fields
Open

Kathircpe wants to merge 1 commit into
prooflinedev:mainfrom
Kathircpe:fix/mcp-duplicate-envelope-fields

Conversation

@Kathircpe

Copy link
Copy Markdown

Problem

The MCP bridge rejected duplicate jsonrpc, id, result, and error members, but not method or params. Duplicates were silently last-wins:

{"jsonrpc":"2.0","id":1,"method":"initialize","method":"ping"}

parsed as ping. The bridge answered it locally and never forwarded the frame, returning success for a request that was never sent.

Regression tests before the fix
Screenshot from 2026-11-21 15-41-38

Fix

Extended the duplicate check in EnvelopeVisitor::visit_map to method and params. The list now covers every member the adapter interprets: the four request keys Message::parse accepts, plus result/error on responses.

Alternate fix considered:
rejecting every duplicate top-level key would also
reject repeated unknown members in server responses. The bridge never reads
those members, so I kept the existing tolerance and scoped this change to the
fields the adapter interprets.

Regression tests after the fix
Screenshot from 2026-11-21 15-42-08

Verification

  • Added duplicate method and params cases to tests/mcp.rs; both expect -32600, no forwarded request, nonzero exit.
  • The duplicate-method case fails on main (Number(1) vs Null) and passes with the fix.
  • cargo test --locked, cargo fmt --check, and cargo clippy --locked --all-targets -- -D warnings pass.
  • Reproduce: cargo test --locked --test mcp bounded_frames

Proofline review

  • Review: completed with no findings (exit 0).
  • Because an empty result is not proof, I verified independently:
    • duplicate method ending in ping → -32600, zero forwarded requests
    • duplicate params, jsonrpc, id, result, error → rejected
    • a valid initialize frame still forwards

This branch has not been deployed

No deployments
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