http: heap out-of-bounds read in chunked parser on a split read
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 74/100
Línea de trabajo
Lee lib/monkey/mk_server/mk_http_parser.c, especialmente http_parser_transfer_encoding_chunked() en torno al cálculo de content_start y available_bytes. Reproduce el problema con las dos lecturas fragmentadas descritas en el issue y ejecuta el parser bajo ASAN. Se considera terminado cuando la solicitud incompleta devuelve PENDING sin una lectura fuera de los límites, mientras las solicitudes chunked válidas siguen analizándose.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug Report
Describe the bug
http_parser_transfer_encoding_chunked() can compute content_start past the end of the request buffer and
then read out of bounds. The "do we have all the data?" test passes spuriously because available_bytes is an
unsigned subtraction that wraps when content_start overshoots.
Root cause
lib/monkey/mk_server/mk_http_parser.c:
content_start = p->chunk_processed_start + pos + 2; /* just past the CRLF */
available_bytes = buf_request_len - (content_start - buf_request);
if (available_bytes >= p->chunk_expected_size + 2) { /* "do we have all the data?" */
p->chunk_processed_end = content_start + p->chunk_expected_size;
if (p->chunk_processed_end[0] != '\r' || p->chunk_processed_end[1] != '\n') { /* line 644 */
pos comes from mk_string_search_n(..., "\r\n", ..., len), which is bounded by the logical length. But the
caller NUL-terminates at buf_data[buf_len] and the search compares two bytes, so a \r at the last logical
byte followed by a \n in the heap slack matches with pos at the edge. content_start then lands past
buf_request + buf_request_len.
available_bytes is a size_t subtraction with no guard for that, so it wraps to a huge value, the test
passes, and chunk_processed_end is derived from a pointer past the buffer — the delimiter read at line 644
then reads out of bounds.
To Reproduce
Drive mk_http_parser() directly and deliver the input in two reads, the first ending mid chunk-size line
(split at 1 + (size-1)/2):
POST / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n77\r\nu\n d\r\r\n...
Under ASAN:
==ERROR: AddressSanitizer: heap-buffer-overflow
READ of size 1
#0 http_parser_transfer_encoding_chunked mk_http_parser.c:644:17
0x... is located 81 bytes after 87-byte region
Reproduces every run.
Against a real http input on :9880, two writes where the first ends with a lone \r at the buffer edge and
the declared chunk length exceeds the data present makes the server close the connection with no HTTP response
instead of answering.
Expected behavior
content_start should be clamped/validated against buf_request + buf_request_len before the subtraction, so
the request is treated as incomplete (PENDING) rather than reading past the buffer.
Your Environment
- Fluent Bit 5.1.5 (
fluent/fluent-bit:latest), also present on currentmaster— the function is
byte-identical there - Linux, aarch64, official container image
- Input:
httpplugin, default settings
Impact
Out-of-bounds read of up to chunk_expected_size bytes past the request buffer, reachable pre-auth by any
client that splits a chunked upload across TCP segments. Read-only, so crash/info-leak class rather than direct
RCE, but a genuine memory-safety defect.
- Lenguaje dominante
- C
- Estrellas
- 8.2k
- Forks
- 2k
- Merge medio
- 3 d 20 h
- PR fusionados (30 d)
- 99
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de fluent/fluent-bit
-
in_tail: files falsely detected as rotated on macOS with threaded inputs, causing duplicate recordsPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
fluent/fluent-bit#12780 ·
Los mantenedores suelen responder en 1 día
-
status: waiting-for-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
fluent/fluent-bit#12683 · 2 comentarios · 6 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
fluent/fluent-bit#12657 ·
Los mantenedores suelen responder en 1 día
-
http: Transfer-Encoding chunked plus Content-Length hangs forever (CL branch shadows the chunked path)Posiblemente ocupada @sarankumar1325 la tomó hace 14 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
fluent/fluent-bit#12656 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
fluent/fluent-bit#12636 ·
Los mantenedores suelen responder en 1 día
Todos los issues de fluent/fluent-bit
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
micropython/micropython#19942 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 3 días
-
快速入门那里会不会对新手不太友好,提出优化方案Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
-
-disable-symbolserver is ignored on macOS/Linux: PDBs are still downloaded from msdl.microsoft.comAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100