http: empty Host header closes the connection with no response

Đang mở Phù hợp với người mới
#12,657 0 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/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

Bắt đầu tại lib/monkey/mk_server/mk_http_parser.c, ở phần xử lý Host được hiển thị trong issue, rồi lần theo đường dẫn lỗi của parser đóng kết nối. Kiểm tra cách đường dẫn đó xử lý issue liên quan #12648 và tìm các bài kiểm thử HTTP server phù hợp. Công việc hoàn tất khi Host: trống nhận được phản hồi 400 trước khi kết nối đóng, đồng thời các trường hợp hiện có vẫn hoạt động như mô tả.

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

A request with an empty Host: value is rejected by closing the connection with no HTTP response at all —
not a 400, nothing. The client sees a bare EOF.

To Reproduce

POST / HTTP/1.1
Host:
Content-Type: application/json
Content-Length: 7

{"a":1}

Result: connection closed immediately, zero response bytes. Reproducible every run.

Contrast: no Host header at all → 201; duplicate Host headers → 201.

Root cause

lib/monkey/mk_server/mk_http_parser.c, in the Host handling:

if (i == MK_HEADER_HOST) {
    if (header->val.len == 0) {
        return -MK_CLIENT_BAD_REQUEST;
    }

That returns a parser error, and the error path closes the connection without writing a status line (the same
path as #12648). So an empty Host is treated as fatal-and-silent rather than as a 400.

Expected behavior

A 400 Bad Request response, then close. An empty Host is a client error, not a transport failure, and the
client currently cannot tell the difference.

Your Environment

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

Impact

Pre-auth. Clients that emit an empty Host: (some HTTP libraries do when the target has no hostname) get a
silent failure with no status code and nothing to log or retry on. Related to #12648, which is the same
silent-close path reached from a different trigger.

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.