Skip to content

fix: add explicit size caps for config reads, cached notifications, and LSP errors - #330

Merged
bug-ops merged 2 commits into
mainfrom
309-missing-size-caps
Aug 5, 2026
Merged

fix: add explicit size caps for config reads, cached notifications, and LSP errors#330
bug-ops merged 2 commits into
mainfrom
309-missing-size-caps

Conversation

@bug-ops

@bug-ops bug-ops commented Aug 5, 2026

Copy link
Copy Markdown
Owner

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_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 (e.g. /dev/zero).
  • rename_symbol's new_name and get_completions's 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 (largest-fitting-prefix via binary search, not a lossy positional halve) 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

Test plan

  • cargo +nightly fmt --all -- --check
  • cargo clippy --all-targets --all-features --workspace -- -D warnings
  • cargo nextest run --workspace --all-features --lib --bins (691 passed, 1 skipped)
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • CHANGELOG.md updated under [Unreleased] > Security

bug-ops added 2 commits August 5, 2026 05:06
…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
bug-ops force-pushed the 309-missing-size-caps branch from 13a3922 to 70a1fec Compare August 5, 2026 03:06
@bug-ops
bug-ops merged commit 5a3743d into main Aug 5, 2026
28 checks passed
@bug-ops
bug-ops deleted the 309-missing-size-caps branch August 5, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation mcpls-core mcpls-core crate changes rust Rust code changes

Projects

None yet

1 participant