An oversized LSP Content-Length can terminate the server with an OOM panic

オープン
#16,539 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
1〜2日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Lean
スター
10.3k
フォーク
1.1k
平均マージ
19時間 8分
マージ済み PR(30日)
421

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

leanprover/lean4 のほかの issue

leanprover/lean4 の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。