Repository navigation
security(lsp): bound transport framing, payloads, concurrency, and slow readers (#2034) - #2185
Conversation
…ow readers (#2034) ripr lsp --stdio had no explicit ingress/concurrency/egress policy: tower-lsp's codec trusts Content-Length with no message cap, handlers accepted unbounded initialization options, previousResultIds, and executeCommand arguments, and a stopped reader could wedge the process forever. A byte-transparent BoundedStdinReader now trips above an 8 KiB header block or a 16 MiB declared message before the codec waits for the body (one bounded -32700 then clean exit, per tokio-util's fused-error semantics); typed validators reject oversized payloads with bounded -32602 errors that echo no attacker input and mutate no state; concurrency is explicit at the transport's own default of 4 (keeps cancelRequest serviceable); and a 120 s write-stall deadline errors the write half and wakes the stdin adapter so a stopped reader ends the session cleanly instead of wedging. Adversarial coverage rides the existing real-binary lsp_lifecycle harness: oversized/overflowing/ negative Content-Length, header flood, 5000-deep nesting, 5000-entry duplicate previousResultIds, oversized executeCommand args and initialization options, a 96-frame coalesced burst, cancel under load, and EOF during overload. Residuals are documented in docs/LSP_TRANSPORT_BOUNDS.md (no wire-level frame recovery, internal queue constant, no per-message write deadline without forking).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Summary by CodeRabbit
WalkthroughAdds bounded LSP stdio framing, request concurrency, stdout stall handling, and typed payload validation. The change wires these controls into the server, adds adversarial lifecycle and unit tests, and documents the limits and claim boundaries. ChangesLSP transport bounds
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant LspClient
participant BoundedTransport
participant LspServer
participant PayloadBounds
LspClient->>BoundedTransport: Send framed request
BoundedTransport->>LspServer: Admit bounded stream
LspServer->>PayloadBounds: Validate typed arguments
PayloadBounds-->>LspServer: Accept or InvalidParams
LspServer-->>BoundedTransport: Send response
BoundedTransport-->>LspClient: Response or bounded shutdown
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f58ae098d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Review (codex P2): a trip that landed between a reader's is_tripped check and its waker registration stranded the new waker — trip had already drained the queue. Registration now checks the flag under the same lock: already-tripped wakes by ref immediately; otherwise the pending trip drains the registration next. Both orderings are pinned by tests.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…headline entries (#3591) * docs(changelog): consolidate Unreleased headings and add the missing headline entries The Unreleased section carried duplicate Added/Fixed headings and omitted the release's headline features. Consolidate to one Added / Changed / Fixed sequence (0.10.0 convention) and add verified entries for: - ripr mcp --stdio server and startup routing (#3088, #3525, #3587) - ripr rerun changed-test targeted analysis (#1520) - the binary-first evidence/gate surface: ripr plus, pr-summary, pr-evidence, annotations, impacted-evidence (#1476/#1460/#1468/#1467/#1474) - --suppression-policy and --exception-policy policy flags (#1475/#1477) - the cache management surface: status, clear, atomic writes (#1822/#2865/#2738) - the LSP capability wave: pull diagnostics, listActionableItems, transport bounds (#1669/#3012/#2185) - analysis performance: per-file fact cache, rayon parallel parse, artifact reuse (#2039/#2322/#2250) Every cited PR verified MERGED via the GitHub API. Also corrects the stale 0.10.0 release-date line (crates.io publication 2026-06-15; GitHub release draft remains unfinalized). * docs(changelog): drop the superseded duplicate MCP entry (#3591 review) The pre-existing Added block already carried an MCP entry from the #3525 merge; keep the expanded consolidated entry (startup routing, verbose handling, review fixes) and remove the older shorter one.
Summary
Implements #2034's transport/resource policy for
ripr lsp --stdio. Investigation of vendored tower-lsp-server 0.23.0 established the real seams: the codec has no max-payload knob and none can be installed via public API, butServer::new(stdin, stdout, socket)is generic over AsyncRead/AsyncWrite — the sanctioned interception seam — andServer::concurrency_levelis public.Enforced bounds (chosen limits justified in
docs/LSP_TRANSPORT_BOUNDS.md):BoundedStdinReader— 8 KiB header block, 16 MiB declared message cap (largest legit ingress is didOpen/didSave full text; egress is already budget-capped, so ingress dominates). Trips before the codec waits for a declared body; tokio-util's fused-error semantics then emit one bounded-32700and the process exits cleanly. Integer-overflow/negative/malformed headers fail deterministically.payload_bounds.rs, at handler entry before any state mutation): initialization_options ≤ 64 KiB; previousResultIds ≤ 4096 entries / 4096 B URI / 1024 B value (was O(n²) find + unbounded clone); executeCommand args ≤ 8 entries / 64 KiB. Rejection is a bounded-32602with a static message — no attacker echo.$/cancelRequestserviceable; internal queue 100 noted as residual.Documented residuals (with reasons, in the doc): no wire-level frame recovery (transport fuses by design), internal queue constant not configurable without forking, no per-message write deadlines without forking, riprAgent bounds deferred until handlers exist, processId monitoring is #2030's scope.
Closes #2034
Adversarial coverage (real-binary, reusing the #1930 harness)
11 real-binary tests: oversized declared Content-Length with no body, oversized header block, integer-overflow and negative Content-Length, 5000-deep nesting, 5000 duplicate previousResultIds (then a legit set + hover succeeds), oversized result-id value, oversized executeCommand args, oversized initialization options, a 96-request coalesced burst (>header cap across one read), cancel under load, EOF during overload. Two in-process end-to-end tests over the real
serve_streamscomposition pin the one-bounded-error-then-clean-stop and stopped-reader behavior.A self-found bug is fixed with regressions: the first
observe()desynced on coalesced frames (burst_of_small_frames_in_one_read_passes,body_bytes_that_look_like_headers_do_not_desync).Verification (independent of builder)
cargo test -p ripr— 3647 passed, 0 failedcargo test -p ripr --test lsp_lifecycle— 25 passedcargo clippy -p ripr --all-targets -- -D warnings— cleancargo fmt --check— cleancargo xtask precommit/goldens check/dogfood— all exit 0Notes
serve_stdio_call_presence_observer(structural source observer) updated to pin the new bounded composition..allow/spec-system/slices/lsp-transport-bounds.v1.toml) + doc carry the evidence trail.