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

Aperta
#12,648 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
56/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C
Stelle
8.2k
Fork
2k
Merge medio
3g 20h
PR unite (30g)
99

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di fluent/fluent-bit

Tutte le issue di fluent/fluent-bit

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.