http: Transfer-Encoding chunked plus Content-Length hangs forever (CL branch shadows the chunked path)
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- c
- 领域
- backend, networking, security
调研方向
从 lib/monkey/mk_server/mk_http_parser.c 中的 REQ_LEVEL_BODY 分支开始,跟踪 mk_http_parser_is_content_chunked() 和 http_parser_transfer_encoding_chunked() 的调用路径。使用两个请求头重现提供的请求,并将其与不含 Content-Length 的 chunked 请求进行比较。请求被解析为 chunked 并返回 201,而不是挂起,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Bug Report
Describe the bug
A request carrying both Transfer-Encoding: chunked and Content-Length never completes. The server reads the
whole chunked body, then waits forever for Content-Length bytes that will never arrive, and the request is never
processed or answered.
This is the classic request-smuggling header pair, so it matters beyond a simple hang.
To Reproduce
POST / HTTP/1.1
Host: x
Content-Type: application/json
Transfer-Encoding: chunked
Content-Length: 100
7\r\n{"a":1}\r\n0\r\n\r\n
Result: no response (hangs to the 10 s timeout), and no record is emitted. Reproducible every time. The same
request with Content-Length: 2 instead of 100 also hangs, so it is not about the value — merely having the
header is enough.
Without Content-Length the identical chunked request returns 201.
Root cause
lib/monkey/mk_server/mk_http_parser.c, in the main parse loop at REQ_LEVEL_BODY:
else if (p->level == REQ_LEVEL_BODY) {
if (p->header_content_length > 0) {
p->body_received = len - p->start;
if ((len - p->start) < p->header_content_length) {
return MK_HTTP_PARSER_PENDING; /* <- never gets past here */
}
...
}
return mk_http_parser_ok(req, p, buffer, buf_len, server);
}
The chunked handling lives in mk_http_parser_ok(), which is only reached after this branch. So when
Content-Length is present the CL path is taken first and returns PENDING, and mk_http_parser_ok() — which
would have dispatched to http_parser_transfer_encoding_chunked() — is never called.
The branch should be if (p->header_content_length > 0 && !mk_http_parser_is_content_chunked(p)), or the chunked
case should be checked first.
Expected behavior
Transfer-Encoding: chunked takes precedence over Content-Length (RFC 9112 §6.3), so the request should be
parsed as chunked and answered with 201.
Your Environment
- Fluent Bit 5.1.5 (
fluent/fluent-bit:latest) - Linux, aarch64, official container image
- Input:
httpplugin, default settings
Impact
Pre-auth. Any client or proxy that sends both headers — common, since many stacks add Content-Length alongside
chunked encoding — gets a hang and a lost record. Because the two headers are interpreted differently from what
RFC 9112 requires, it is also a request-smuggling candidate when Fluent Bit sits behind a proxy that prefers
Content-Length.
- 主要语言
- C
- 星标
- 8.2k
- 派生
- 2k
- 平均合并
- 3 天 20 小时
- 30 天内合并 PR
- 99
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fluent/fluent-bit 的其他 Issue
-
in_tail: files falsely detected as rotated on macOS with threaded inputs, causing duplicate records可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
fluent/fluent-bit#12780 ·
维护者通常 1 天内回复
-
status: waiting-for-triage
难度 2/5 1-3 小时 新手友好度 72/100
fluent/fluent-bit#12683 · 2 条评论 · 6 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
fluent/fluent-bit#12657 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
fluent/fluent-bit#12649 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 79/100
fluent/fluent-bit#12636 ·
维护者通常 1 天内回复
查看 fluent/fluent-bit 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
micropython/micropython#19942 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
-
难度 1/5 1 小时以内 新手友好度 84/100
-
-disable-symbolserver is ignored on macOS/Linux: PDBs are still downloaded from msdl.microsoft.com未关闭
难度 2/5 1-3 小时 新手友好度 77/100