fix: add explicit size caps for config reads, cached notifications, and LSP errors - #330
Merged
Conversation
This was
linked to
issues
Aug 5, 2026
bug-ops
enabled auto-merge (squash)
August 5, 2026 03:00
…nd LSP errors Several inputs were previously bounded only by an outer transport or protocol limit, or not bounded at all -- each a defense-in-depth gap found during a security audit (CWE-400). - ServerConfig::load_from now reads the config file through a bounded Read::take instead of an unbounded read_to_string, rejecting files over 8 MiB. A metadata() size pre-check alone is insufficient since it reports 0 for character devices and FIFOs. - rename_symbol's new_name and get_completions' trigger MCP params are now length-capped, matching the existing cap on workspace_symbol_search's query. - NotificationCache::store_log/store_message/store_diagnostics now truncate cached text and bound each diagnostics entry's total serialized size, instead of capping entry count only. Diagnostics truncation prefers keeping higher-severity entries and logs a warning when content is dropped. - LspClient now forwards a bounded error message to MCP callers instead of the full, unbounded LSP server error text. Fixes #309, #311, #313
Rebasing onto main picked up #293's get_logs/get_messages -> logs/messages rename; the auto-merge did not catch the now-stale call sites this branch's own new tests introduced.
bug-ops
force-pushed
the
309-missing-size-caps
branch
from
August 5, 2026 03:06
13a3922 to
70a1fec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several inputs were previously bounded only by an outer transport or protocol limit, or not bounded at all — each a defense-in-depth gap found during a security audit (CWE-400).
ServerConfig::load_fromnow reads the config file through a boundedRead::takeinstead of an unboundedread_to_string, rejecting files over 8 MiB. Ametadata()size pre-check alone is insufficient since it reports 0 for character devices and FIFOs (e.g./dev/zero).rename_symbol'snew_nameandget_completions'striggerMCP params are now length-capped, matching the existing cap onworkspace_symbol_search'squery.NotificationCache::store_log/store_message/store_diagnosticsnow truncate cached text and bound each diagnostics entry's total serialized size, instead of capping entry count only. Diagnostics truncation prefers keeping higher-severity entries (largest-fitting-prefix via binary search, not a lossy positional halve) and logs a warning when content is dropped.LspClientnow forwards a bounded error message to MCP callers instead of the full, unbounded LSP server error text.Fixes #309, #311, #313
Test plan
cargo +nightly fmt --all -- --checkcargo clippy --all-targets --all-features --workspace -- -D warningscargo nextest run --workspace --all-features --lib --bins(691 passed, 1 skipped)RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features[Unreleased] > Security