Skip to content

Commit 6d9e5f9

Browse files
committed
fix(http1): fix server misinterpretting multiple Transfer-Encoding headers
When a request arrived with multiple `Transfer-Encoding` headers, hyper would check each if they ended with `chunked`. It should have only checked if the *last* header ended with `chunked`. See GHSA-6hfq-h8hq-87mf
1 parent 42560c7 commit 6d9e5f9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/proto/h1/role.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ impl Http1Transaction for Server {
204204
if headers::is_chunked_(&value) {
205205
is_te_chunked = true;
206206
decoder = DecodedLength::CHUNKED;
207+
} else {
208+
is_te_chunked = false;
207209
}
208210
}
209211
header::CONTENT_LENGTH => {
@@ -1334,6 +1336,16 @@ mod tests {
13341336
"transfer-encoding doesn't end in chunked",
13351337
);
13361338

1339+
parse_err(
1340+
"\
1341+
POST / HTTP/1.1\r\n\
1342+
transfer-encoding: chunked\r\n\
1343+
transfer-encoding: afterlol\r\n\
1344+
\r\n\
1345+
",
1346+
"transfer-encoding multiple lines doesn't end in chunked",
1347+
);
1348+
13371349
// http/1.0
13381350

13391351
assert_eq!(

0 commit comments

Comments
 (0)