Skip to content

Bound LSP Content-Length and header line sizes #2825

Description

@Widthdom

Evidence

src/CodeIndex/Lsp/LspServer.cs parses Content-Length into an int and then rents exactly that size:

var buffer = ArrayPool<byte>.Shared.Rent(contentLength);

ReadAsciiLine also builds a List<byte> until newline without a header-line length cap.

Impact

A malformed or hostile LSP peer can advertise a very large Content-Length or send an unbounded header line. Even though LSP is normally local stdio, this can still cause excessive allocation or memory pressure in editor-launched processes.

Expected

Add maximum LSP frame size and header-line limits. Reject frames over the cap with a structured error or close the stream. Prefer clear constants and tests for boundary values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsecurity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions