http: Transfer-Encoding chunked plus Content-Length hangs forever (CL branch shadows the chunked path)

Abierto Apto para principiantes
#12,656 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@sarankumar1325 ya está trabajando en esto.

Desde el 29/10/2026.

  • #12692 de @sarankumar1325 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
c

Línea de trabajo

Empieza por la rama REQ_LEVEL_BODY en lib/monkey/mk_server/mk_http_parser.c y sigue cómo se llega a mk_http_parser_is_content_chunked() y http_parser_transfer_encoding_chunked(). Reproduce la solicitud proporcionada con ambas cabeceras y compárala con la solicitud chunked sin Content-Length. La tarea estará terminada cuando la solicitud se analice como chunked y devuelva 201 en lugar de quedarse bloqueada.

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

Descripción

Bug Report

Describe the bug

A request carrying both Transfer-Encoding: chunked and Content-Length never completes. The server reads the
whole chunked body, then waits forever for Content-Length bytes that will never arrive, and the request is never
processed or answered.

This is the classic request-smuggling header pair, so it matters beyond a simple hang.

To Reproduce

POST / HTTP/1.1
Host: x
Content-Type: application/json
Transfer-Encoding: chunked
Content-Length: 100

7\r\n{"a":1}\r\n0\r\n\r\n

Result: no response (hangs to the 10 s timeout), and no record is emitted. Reproducible every time. The same
request with Content-Length: 2 instead of 100 also hangs, so it is not about the value — merely having the
header is enough.

Without Content-Length the identical chunked request returns 201.

Root cause

lib/monkey/mk_server/mk_http_parser.c, in the main parse loop at REQ_LEVEL_BODY:

else if (p->level == REQ_LEVEL_BODY) {
    if (p->header_content_length > 0) {
        p->body_received = len - p->start;
        if ((len - p->start) < p->header_content_length) {
            return MK_HTTP_PARSER_PENDING;      /* <- never gets past here */
        }
        ...
    }
    return mk_http_parser_ok(req, p, buffer, buf_len, server);
}

The chunked handling lives in mk_http_parser_ok(), which is only reached after this branch. So when
Content-Length is present the CL path is taken first and returns PENDING, and mk_http_parser_ok() — which
would have dispatched to http_parser_transfer_encoding_chunked() — is never called.

The branch should be if (p->header_content_length > 0 && !mk_http_parser_is_content_chunked(p)), or the chunked
case should be checked first.

Expected behavior

Transfer-Encoding: chunked takes precedence over Content-Length (RFC 9112 §6.3), so the request should be
parsed as chunked and answered with 201.

Your Environment

  • Fluent Bit 5.1.5 (fluent/fluent-bit:latest)
  • Linux, aarch64, official container image
  • Input: http plugin, default settings

Impact

Pre-auth. Any client or proxy that sends both headers — common, since many stacks add Content-Length alongside
chunked encoding — gets a hang and a lost record. Because the two headers are interpreted differently from what
RFC 9112 requires, it is also a request-smuggling candidate when Fluent Bit sits behind a proxy that prefers
Content-Length.

Lenguaje dominante
C
Estrellas
8.2k
Forks
2k
Merge medio
3 d 20 h
PR fusionados (30 d)
99

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

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 fluent/fluent-bit

Todos los issues de fluent/fluent-bit

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.