LSP invalid-params responses can spend seconds formatting a short JSON exponent
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- backend-api-design, security
Direzione di ricerca
Start with the exponent parsing and number formatting paths in src/Lean/Data/Json/Parser.lean and src/Lean/Data/Json/Basic.lean, then trace how malformed request parameters are serialized in src/Lean/Server/Requests.lean and src/Lean/Server/Watchdog.lean. Add an LSP regression test using the supplied request with 1e100000; done means the error response is prompt and bounded.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
LSP invalid-params responses can spend seconds formatting a short JSON exponent
Summary
On Lean 4 master, a malformed LSP request can force expensive formatting of a large JSON exponent when the server serializes the invalid parameters into its error response. The input token is only eight bytes, but 1e100000 is accepted at the current exponent limit and expands to a 100,001-digit natural number.
Steps to reproduce
Run lean --server, complete the LSP initialize handshake, then send the following JSON-RPC request as a normal LSP frame. Set Content-Length to the UTF-8 byte length of the JSON body.
{"jsonrpc":"2.0","id":7,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///tmp/Probe.lean"},"position":{"line":"invalid","character":0},"probe":1e100000}}
Expected behavior
The server should reject the malformed parameters promptly and return a bounded error response. Error formatting should not materialize or print a 100,001-digit integer.
Actual behavior
On the reviewed 4.37.0-pre build, the request takes approximately 7–8 seconds to produce an invalid-parameters response of about 100 KB. Relevant source files were unchanged between the reviewed commit 427023483cddad04689cf959e3e23589811c867a and master a2a6b48ad40269ecf6a27e7790c7e611e7bb55d4.
Impact assessment
A client with access to the LSP process can repeatedly occupy a file worker for several seconds and cause large error responses to be built and sent. Concurrent requests can increase CPU and response-buffer/transport memory use. This demonstrates denial of service under the stated access condition; it does not demonstrate information disclosure or code execution.
Root cause
The JSON parser accepts the exponent at its 100000 limit and eagerly expands it into a large natural number. When request parameter validation fails, the LSP error path serializes the original parameters, triggering costly decimal formatting. Relevant paths include src/Lean/Data/Json/Parser.lean, src/Lean/Data/Json/Basic.lean, and the invalid-parameter response path in src/Lean/Server/Requests.lean / src/Lean/Server/Watchdog.lean.
This is related to #13987, which concerns panics for exponents beyond the parser's limit. This report concerns the expensive accepted boundary value when it is echoed by LSP error handling.
Suggested fix
Avoid eagerly expanding positive exponents when the value only needs to be echoed, for example by preserving the coefficient/exponent representation and emitting bounded scientific notation. Independently bound the size and cost of invalid-parameter details before formatting or sending them. Add an LSP regression test with a malformed request containing 1e100000 and assert that the error response remains bounded and prompt.
- 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
-
External sources always come back in English: `lc` isn't passed to `/api/v3/external_sources`Forse già presa @Anurag1428 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
openfoodfacts/openfoodfacts-explorer#2264 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
EverMind-AI/Raven#1413 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
cloudflare/workers-sdk#17139 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
symposium-dev/symposium#530 ·
I maintainer di solito rispondono entro 5 giorni
-
low-priority plugin:abstract source:discussion
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
athola/claude-night-market#1306 ·
I maintainer di solito rispondono entro 3 giorni