in_http: urlencoded parser ignores body length, absorbs pipelined requests

Đang mở
#12,650 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c
Lĩnh vực
backend, networking

Hướng nghiên cứu

Start with parse_payload_urlencoded() in plugins/in_http/http_prot.c and trace how the caller passes the payload and its length. Check the HTTP input tests for urlencoded bodies and pipelined requests, then add coverage showing parsing stops at Content-Length. Done means trailing bytes stay out of the parsed value and a following request is processed.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug Report

Describe the bug

The application/x-www-form-urlencoded parser in the http input ignores the request body length and consumes
everything up to the NUL terminator of the body buffer. Bytes after Content-Length — including a following
pipelined request — are absorbed into the last field's value, and the pipelined request is then never
processed.

To Reproduce

Start an http input on port 9880, then send one connection with a body shorter than the bytes that follow:

POST /one HTTP/1.1
Host: x
Content-Type: application/x-www-form-urlencoded
Content-Length: 3

a=1POST /two HTTP/1.1
Host: x
Content-Type: application/x-www-form-urlencoded
Content-Length: 3

b=2

Observed on stdout:

[0] one: [[..., {}], {"a"=>"1POST /two HTTP/1.1
Host: x
Content-Type: application/x-www-form-urlencoded
Content-Length: 3

b=2"}]

Only one record is produced, tagged one. The second request is swallowed entirely, and the connection
then times out instead of answering it.

Even without pipelining it is wrong — Content-Length: 3 with body a=1 followed by ZZZ=9 yields
{"a"=>"1ZZZ=9"}.

Root cause

plugins/in_http/http_prot.c, parse_payload_urlencoded():

kvs = flb_utils_split(payload, '&', -1 );

flb_utils_split() takes no length and is NUL-terminated-string based, so it runs to the end of the body
buffer rather than to size. The function receives size from its caller —

ret = parse_payload_urlencoded(ctx, &encoder, tag, payload,
                               cfl_sds_len(payload), request);

— but never uses it.

Expected behavior

Parsing should stop at size (e.g. a length-aware split, or a temporary NUL at payload[size]), so trailing
bytes and pipelined requests are not absorbed.

Your Environment

  • Fluent Bit 5.1.5 (fluent/fluent-bit:latest); the function is byte-identical on current master
  • Linux, aarch64, official container image
  • Input: http plugin, default settings, Content-Type: application/x-www-form-urlencoded

Impact

Pre-auth record corruption, and any pipelined request following a urlencoded POST is silently dropped. Also
makes the declared Content-Length meaningless for this content type.

Ngôn ngữ chính
C
Star
8.2k
Fork
2k
Merge trung bình
3 ngày 20 giờ
Pull request đã merge (30 ngày)
99

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fluent/fluent-bit

Tất cả issue của fluent/fluent-bit

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.