Description
LspClient::message_loop_inner (crates/mcpls-core/src/lsp/client.rs:563) now truncates a spawned LSP server's JSON-RPC error message before logging it (fixed in #294 — see truncate_error_message_for_log), but the full, untruncated error.message is still forwarded verbatim into Error::LspServerError and returned to the MCP caller:
let message = Self::truncate_error_message_for_log(&error.message);
error!("LSP error response: {} (code {})", message, error.code);
let _ = sender.send(Err(Error::LspServerError {
code: error.code,
message: error.message.clone(), // full, unbounded message
..
}));
Only the log line is bounded; the value propagated to the MCP client has no size limit.
Why
error.message originates from the spawned LSP server and is attacker-influenceable (a malicious/compromised LSP server, or one echoing back attacker-controlled workspace content such as a crafted file/symbol name). A hostile server can return an arbitrarily large error message, which mcpls forwards without bound to every MCP client waiting on that request — a memory/log amplification vector, distinct from the panic fixed in #294 (this does not panic, it just has no size cap).
Flagged during #294's independent code review (rust-code-reviewer + rust-critic adversarial critique) as pre-existing behavior, out of scope for that panic fix.
Expected Behavior
Bound the size of the error message forwarded to MCP callers (e.g. reuse or generalize the same truncation helper introduced in #294, on the caller-facing message rather than just the log line), while preserving useful diagnostic content.
Actual Behavior
The full, unbounded LSP server error message is forwarded to MCP callers with no size limit.
Environment
Description
LspClient::message_loop_inner(crates/mcpls-core/src/lsp/client.rs:563) now truncates a spawned LSP server's JSON-RPC errormessagebefore logging it (fixed in #294 — seetruncate_error_message_for_log), but the full, untruncatederror.messageis still forwarded verbatim intoError::LspServerErrorand returned to the MCP caller:Only the log line is bounded; the value propagated to the MCP client has no size limit.
Why
error.messageoriginates from the spawned LSP server and is attacker-influenceable (a malicious/compromised LSP server, or one echoing back attacker-controlled workspace content such as a crafted file/symbol name). A hostile server can return an arbitrarily large error message, which mcpls forwards without bound to every MCP client waiting on that request — a memory/log amplification vector, distinct from the panic fixed in #294 (this does not panic, it just has no size cap).Flagged during #294's independent code review (
rust-code-reviewer+rust-criticadversarial critique) as pre-existing behavior, out of scope for that panic fix.Expected Behavior
Bound the size of the error message forwarded to MCP callers (e.g. reuse or generalize the same truncation helper introduced in #294, on the caller-facing message rather than just the log line), while preserving useful diagnostic content.
Actual Behavior
The full, unbounded LSP server error message is forwarded to MCP callers with no size limit.
Environment
crates/mcpls-core/src/lsp/client.rs:563(Error::LspServerErrorconstruction inmessage_loop_inner)