An oversized LSP Content-Length can terminate the server with an OOM panic
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 58/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend-api-design
Direzione di ricerca
Start with src/Lean/Data/Lsp/Communication.lean, where the issue says Content-Length is parsed and passed to the JSON stream reader. Trace that read path and check how the length is represented and validated before allocation. Done means oversized and unrepresentable lengths are rejected safely; the issue also calls for boundary and truncated-body tests.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
An oversized LSP Content-Length can terminate the server with an OOM panic
Summary
The LSP frame reader accepts an attacker-controlled Content-Length without a protocol-level maximum before reading the body. A short header declaring an enormous body causes the server to panic with out-of-memory and exit.
Steps to reproduce
On a POSIX shell, pipe this header with no body to the reviewed lean executable:
printf 'Content-Length: 1000000000000000\r\n\r\n' | lean --server
Expected behavior
The server should reject an oversized frame as a protocol error and close the input cleanly. It should not attempt an effectively unbounded allocation or terminate with an OOM panic.
Actual behavior
On the reviewed 4.37.0-pre build, this 36-byte header triggered INTERNAL PANIC: out of memory and a non-zero exit in approximately 0.13 seconds. The same input path is present in master a2a6b48ad40269ecf6a27e7790c7e611e7bb55d4; relevant source files were unchanged since the reviewed commit.
Impact assessment
A peer that can write frames to lean --server can terminate the affected language-server process, interrupting editor services handled by that process. This demonstrates a process-availability failure; no data disclosure or code execution was observed. Exploitation requires access to the process input, such as through an exposed language-service proxy.
Root cause
src/Lean/Data/Lsp/Communication.lean parses the declared length and passes it to the JSON stream reader without enforcing a protocol-level maximum. The subsequent read path attempts to consume the declared amount and panics on resource exhaustion.
Suggested fix
Validate Content-Length before allocation or body reads. Reject values above a documented configurable limit and values that cannot be safely represented by the platform size type, using checked conversions and arithmetic. Return a protocol error where possible and close only the offending client connection. Add tests for oversized values, integer boundaries, and truncated bodies.
- Lingua principale
- Lean
- Stelle
- 10.3k
- Fork
- 1.1k
- Merge medio
- 19h 8m
- PR unite (30g)
- 421
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di leanprover/lean4
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16681 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
leanprover/lean4#16305 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
leanprover/lean4#16299 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16257 ·
I maintainer di solito rispondono entro 1 giorno
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
leanprover/lean4#15683 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di leanprover/lean4
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
vetro-protocol/vetro-monorepo#1262 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ProyectoRespira/respira-webapp#334 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100