Skip to content

fix(mcp): reject request ids over 16 KiB without ending the session - #8681

Merged
EffortlessSteven merged 4 commits into
mainfrom
claude/project-thread-180z5c
Oct 21, 2026
Merged

EffortlessSteven merged 4 commits into
mainfrom
claude/project-thread-180z5c

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Requested by Steven · project thread

Summary

Before: a valid request carrying a string id of 131,072+ characters (under the 256 KiB inbound limit) made the server exit with code 2 and no reply, because the echoed response exceeded the 128 KiB response cap and the writer's output-limit failure is fatal to the transport. Later requests were never answered.

After: ids whose JSON-serialized form exceeds 16 KiB (16384 bytes) are rejected at receive with a bounded -32600 frame carrying "id": null (the id is never echoed), and the session keeps serving. The cap is deliberately well above the existing near-cap inventory contract (#7463), which uses a ~12 KB escaped id and still works.

How: new MAX_REQUEST_ID_BYTES in mcp/mod.rs, checked in BoundedTransport::receive before admission, using the existing pending_protocol_error path. Spec, interop doc, traceability and a changelog entry updated.

Tests: new transport unit test and stdio test (128 KiB id and a just-over-cap id rejected; boundary id and a following ping answered). Three older stdio tests were removed because their stimulus (ids near the response cap) is now rejected at receive; the id-aware envelope budget stays covered by the unit tests in server_tests.rs and protocol.rs and by the near-cap inventory test with a 12 KB id. An earlier head used a 1 KiB cap and broke that inventory test in hosted CI; this head raises the cap and passes it locally.

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm

Source-of-truth Links

Spec: RIPR-SPEC-0211
ADR: 0022
Governing issue or accepted claim: #5254 (MCP transport and bound edges; this covers the oversized-id fatal-limit case only, found by client-driven probing)
Acceptance delta (one sentence): A request id too large to echo is rejected with a bounded -32600 and the MCP session stays alive.

Candidate Relationships

No stack, replacement or competing candidate known.

Verification

cargo xtask precommit exit 0 on this head; agentic_bench_mcp near-cap inventory, mcp_stdio oversized-id and mcp::transport unit tests pass locally. Independent review found nothing blocking on the earlier head.


Generated by Claude Code

🤖 Generated with Claude Code

…on (#7768)

An id near the response cap could not be echoed, so the writer's fatal
output-limit ended the transport. Reject at receive with a bounded -32600
frame carrying a null id and keep serving.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177XcqQYAvaNnSX736dXsye
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@EffortlessSteven EffortlessSteven self-assigned this Oct 18, 2026
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 79 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 66d67c1f-02cc-4bce-a6c5-3e38b76a2cba
📥 Commits

Reviewing files that changed from the base of the PR and between ef5d9d2 and f37db51.

📒 Files selected for processing: 8
  • .ripr/traceability.toml
  • changelog.d/7768-oversized-request-id.md
  • crates/ripr/src/mcp/mod.rs
  • crates/ripr/src/mcp/transport.rs
  • crates/ripr/src/mcp/transport_tests.rs
  • crates/ripr/tests/mcp_stdio.rs
  • docs/interop/mcp.md
  • docs/specs/RIPR-SPEC-0211-mcp-workspace-session-evidence.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 18, 2026 02:42
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

… working

The 1 KiB cap broke the #7463 near-cap inventory contract, which
deliberately uses a 12 KB escaped id.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177XcqQYAvaNnSX736dXsye
@EffortlessSteven
EffortlessSteven marked this pull request as draft October 18, 2026 03:25
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 18, 2026 03:25
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Confirmed findings

  • PR body prose says 'exceeds 1024 bytes' but the committed constant is 16384 (16 KiB). All code, changelog, spec, and interop doc are internally consistent at 16384; only the author description in the PR body is wrong. Worth flagging for the author to correct the body to avoid reviewer confusion, but not a code defect.
  • Changelog says 1024-byte id limit but code and spec mark 16384 bytes; client/operator-facing docs diverge from the actual constant.
  • ub-worker-handoff scope (JS-backed worker handoff, async/GC/detach/transfer boundaries, SharedArrayBuffer, postMessage, transferable streams, OffscreenCanvas) is not touched by this Rust-only MCP stdio receive patch; no new JS runtime, spawned Web Worker, or transferable boundary is introduced. The lane therefore has no public issue to surface on this diff.

Verification questions

  • Confirm plan/lane posture mismatch: ripr sensor status is 'failed', so the bounded-id and the giant-id stimuli in transport_tests.rs are only locally validated; an independent miri/cargo-test witness is scheduled-late and not yet landed before this gate. Not an oracle defect; flag for human to recheck when cargo-test receipt arrives.
  • Confirm sibling call sites that produce a JSON-RPC reply frame: BoundedTransport writer path uses protocol_error_frame(-32600, ...) which already exists and is used by the existing pending_protocol_error path; no new writer code path introduced.

Refuted

  • serde_json::to_vec(&request.id) allocation failure on a large id would yield an empty Vec and incorrectly route an oversized id through the admission path.; refuted because: unwrap_or(true) treats Err as oversized and feeds the existing pending_protocol_error writer; the failing allocation is never dereferenced, so this is a false premise on memory-safety grounds.
  • The oversized-id branch could share backing storage with the read frame's BytesMut and observe a stale length after a subsequent resize.; refuted because: serde_json::to_vec(&request.id) allocates a fresh Vec; the original BytesMut is not resized, re-sliced, or transferred, and request.id is moved by reference into a local call that does not retain a view into the read buffer.
  • Box::from(slice) allocation-failure analysis on the new id-guard path; refuted because: objection not raised by PR diff, seeded thread, or any candidate; per calibration this is a false-premise refutation, not a finding.
  • A sibling id-echo path outside transport.rs::receive could still emit an oversized id (notifications or server→client responses).; refuted because: transport.rs::receive is the only decoding site for ClientJsonRpcMessage::Request and writers always construct Response/Error ids themselves, so no second inbound echo exists.
  • The diff introduces or alters a JS-backed worker handoff / async transfer / GC boundary that could leak objects, listeners, or detached buffers across worker realms.; refuted because: Constrained file inventory is 8 .rs/.md/.toml files; the Rust source delta is a single receive-path branch wrapping protocol_error_frame and stashing a bounded JSON error in pending_protocol_error. There is no JS engine integration, no Worker ctor, no transferable handle, no SharedArrayBuffer, and no postMessage/Detach path in scope.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

Parked follow-ups

  • Removed long_request_ids_refuse_typed_before_the_wire_cap and window_sized_envelope_refuses_typed_instead_of_dropping_structured_content stdio tests shipped ids near the 128 KiB response cap; PR confirms their stimulus is now rejected at receive, but those tests were the only stdio coverage for the id-aware envelope budget and typed refusals.

@EffortlessSteven EffortlessSteven changed the title fix(mcp): reject request ids over 1024 bytes without ending the session fix(mcp): reject request ids over 16 KiB without ending the session Oct 18, 2026

Copy link
Copy Markdown
Member Author

Hosted Ripr Rust Small Result is red on this head only because of lsp::tests::generic_client_analysis_failure_is_shown_once_and_only_to_generic_clients (two window/showMessages). That is the inherited combined-tree break from #8636 + #8642 on main (issue #8690), reproduced locally on this branch and on origin/main; this PR does not touch LSP code. Its fix is #8693, still open. My own earlier failure (a 1 KiB id cap breaking the #7463 near-cap inventory test) is fixed in this head: agentic_bench_mcp near-cap, mcp_stdio oversized-id and mcp::transport pass locally. I will merge main and re-toggle Ready once #8693 lands, then merge on a green required check.


Generated by Claude Code

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

Devin Review

Comment thread crates/ripr/src/mcp/transport.rs Resolved
Comment thread crates/ripr/tests/mcp_stdio.rs Resolved
…ction

recoverable_request_id echoed any string id, so an over-limit id on a
request with malformed params bypassed the admission bound.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177XcqQYAvaNnSX736dXsye
@EffortlessSteven
EffortlessSteven marked this pull request as draft October 21, 2026 09:58
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 21, 2026 09:58

Copy link
Copy Markdown
Member Author

Addressed Devin's findings on head f37db51:

  • Malformed-params bypass (transport.rs): valid. recoverable_request_id now refuses to echo an id over MAX_REQUEST_ID_BYTES, so a shape-invalid request with an oversized id gets the bounded "id": null -32600 frame. New test oversized_id_on_a_shape_invalid_request_is_not_echoed (also checks an in-bound id on the same shape is still echoed). cargo xtask precommit exit 0.
  • Envelope coverage narrowing (mcp_stdio.rs): accepted trade, as the PR body states. The id-aware envelope budget stays covered by server_tests.rs/protocol.rs and by the near-cap inventory test, which drives a 12 KB escaped id through the real stdio path. Not adding a new wire-level window test here.

Generated by Claude Code

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Confirmed findings

  • PR body summary still describes the new cap as 'exceeds 1024 bytes' while code, spec, interop, and changelog all use 16384 bytes; harmless but should be corrected to match the committed constant.
  • PR body prose still claims 'exceeds 1024 bytes' for the id cap, while changelog, transport.rs constant, interop.md, and spec all consistently use 16384. Document drift between PR description and shipped artifact; not a code defect, but reviewers will be confused. Author should update the summary text to match the committed constant.
  • The PR body/changelog discrepancy reported earlier should remain corrected to 16384 bytes everywhere; the current committed changelog and specification are consistent.
  • Reader-side recheck: with MAX_REQUEST_ID_BYTES=16384 and recoverable_request_id serializing any RequestId variant (string, integer, or null echo path), a malicious client could still spike CPU via serde_json::to_vec on every frame. Bound is small but checked on the hot receive path; consider whether a length-bounded pre-scan on the raw frame would be cheaper than serializing the parsed id.

Verification questions

  • Confirm two stdio windows now test only the new id-bound refusal; the id-aware envelope budget on the public wire is no longer exercised by a tests/mcp_stdio.rs case, relying on server_tests.rs/protocol.rs and the 12 KB near-cap inventory test for coverage.
  • Confirm pR body summary text says 'exceeds 1024 bytes' for the cap but the committed constant, changelog, spec, and interop doc all use 16384 bytes. Only the human PR body is stale.
  • Confirm removing real-stdio near-response-cap envelope tests narrows integration evidence, although retained lower-level tests still pin the id-aware budget.
  • Confirm pR body prose diverges from code/spec/docs by stating 'exceeds 1024 bytes' while every committed artifact and the changelog cite 16384 bytes; only the author summary is stale and should be corrected to avoid reviewer confusion.

Evidence gaps

  • Cargo-test receipt is scheduled-late, not yet landed; locally validated only. Not an oracle defect, but the bounded-id/giant-id stimuli in transport_tests.rs lack an independent witness before gate.
  • ripr sensor status is failed (exit 2); the new bounded-id stimuli on this diff are only locally validated so far. cargo-test is scheduled-late and its receipt is not yet present before this gate. Flagged for a human to recheck when the scheduled receipt lands; not a code defect on this lane.
  • Final independent executable confirmation is incomplete in the supplied packet: cargo-test is receipt-absent and ripr failed with exit code 2.
  • Model proof intent was rejected by deterministic validation.

@EffortlessSteven
EffortlessSteven merged commit 25475c0 into main Oct 21, 2026
53 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/project-thread-180z5c branch October 21, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants