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

Abierto
#16,539 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
1-2 días
Aptitud para principiantes
58/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Lean
Estrellas
10.3k
Forks
1.1k
Merge medio
19 h 8 min
PR fusionados (30 d)
421

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de leanprover/lean4

Todos los issues de leanprover/lean4

Issues similares

Más issues de Backend & API Design

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.