Skip to content

Commit f605125

Browse files
amoussetseanmonstar
authored andcommitted
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 a115c30 commit f605125

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/proto/h1/role.rs

+11
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ impl Http1Transaction for Server {
170170
if headers::is_chunked_(&value) {
171171
is_te_chunked = true;
172172
decoder = DecodedLength::CHUNKED;
173+
} else {
174+
is_te_chunked = false;
173175
}
174176
},
175177
header::CONTENT_LENGTH => {
@@ -1226,6 +1228,15 @@ mod tests {
12261228
\r\n\
12271229
", "transfer-encoding doesn't end in chunked");
12281230

1231+
parse_err(
1232+
"\
1233+
POST / HTTP/1.1\r\n\
1234+
transfer-encoding: chunked\r\n\
1235+
transfer-encoding: afterlol\r\n\
1236+
\r\n\
1237+
",
1238+
"transfer-encoding multiple lines doesn't end in chunked",
1239+
);
12291240

12301241
// http/1.0
12311242

0 commit comments

Comments
 (0)