http server: chunk extensions rejected, connection closed with no response

Abierto
#12,648 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
3-5 días
Aptitud para principiantes
56/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
c
Área
backend

Línea de trabajo

Start with lib/monkey/mk_server/mk_http_parser.c, especially http_parser_transfer_encoding_chunked() and the check at line 606 described in the report. Reproduce with the supplied chunked request and compare it with the 7 control case. Done means chunk extensions are accepted and the request receives the expected response; the related malformed-input response behavior may need separate scope.

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

Descripción

Bug Report

Describe the bug

The HTTP server rejects any chunked request that uses a chunk extension (RFC 9112 §7.1.1, formerly
RFC 7230 §4.1) and closes the connection without sending any HTTP response at all — not a 400, nothing.
The client sees a bare EOF and cannot distinguish it from a transport failure.

To Reproduce

Start an http input on port 9880, then send this raw request:

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

7;a=b\r\n{"a":1}\r\n0\r\n\r\n

Result: connection closed immediately (EOF at 0.00 s), no response bytes. The server itself stays healthy
and the next request returns 201.

All of these fail identically:

chunk-size line result
7;a=b EOF, no response
7; (empty extension) EOF, no response
7;a="b c" (quoted value) EOF, no response
0;a=b (terminator with extension) EOF, no response
7 (trailing space) EOF, no response
7 (control) 201

Chunked itself works fine otherwise: splitting the body across chunks, one byte per chunk, and uppercase hex
all return 201. Reproduces on the monitoring server (:2020) as well.

Root cause

lib/monkey/mk_server/mk_http_parser.c, http_parser_transfer_encoding_chunked():

memcpy(tmp, p->chunk_processed_start, len);   /* whole chunk-size line, up to CRLF */
tmp[len] = '\0';

chunk_len = strtol(tmp, &ptr, 16);
...
if (ptr == tmp || *ptr != '\0') {             /* line 606 */
    return MK_HTTP_PARSER_ERROR;
}

The parser copies the entire chunk-size line and then requires strtol to have consumed all of it.
strtol stops at the ;, so *ptr is ; and the request is treated as a parse error. The same check also
rejects a trailing space after the size.

Expected behavior

The extension should be ignored (or parsed) and the chunk length taken from the hex prefix, so the request
succeeds with 201.

Second, related issue

Every MK_HTTP_PARSER_ERROR closes the connection with no response, so malformed chunked input is
indistinguishable from a network drop (a plain ZZZ chunk size behaves the same way). A 400 would be the
expected behaviour.

Your Environment

  • Fluent Bit 5.1.5 (fluent/fluent-bit:latest), also present on current master — the lines above are
    unchanged there
  • Linux, aarch64, official container image
  • Input: http plugin, default settings

Impact

Any client, proxy or SDK that emits chunk extensions gets a silent failure with no status code and nothing
to log or retry on. 0;a=b means even a correctly terminated body fails.

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.