Skip to content

Commit 8f93123

Browse files
committedFeb 5, 2021
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 4d2125c commit 8f93123

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎src/proto/h1/role.rs

+12
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ impl Http1Transaction for Server {
213213
if headers::is_chunked_(&value) {
214214
is_te_chunked = true;
215215
decoder = DecodedLength::CHUNKED;
216+
} else {
217+
is_te_chunked = false;
216218
}
217219
}
218220
header::CONTENT_LENGTH => {
@@ -1444,6 +1446,16 @@ mod tests {
14441446
"transfer-encoding doesn't end in chunked",
14451447
);
14461448

1449+
parse_err(
1450+
"\
1451+
POST / HTTP/1.1\r\n\
1452+
transfer-encoding: chunked\r\n\
1453+
transfer-encoding: afterlol\r\n\
1454+
\r\n\
1455+
",
1456+
"transfer-encoding multiple lines doesn't end in chunked",
1457+
);
1458+
14471459
// http/1.0
14481460

14491461
assert_eq!(

0 commit comments

Comments
 (0)
Please sign in to comment.