chenBright commented on code in PR #3758:
URL: https://github.com/apache/brpc/pull/3758#discussion_r4625243677
##########
test/brpc_http_message_unittest.cpp:
##########
@@ -630,6 +630,54 @@ TEST(HttpMessageTest, chunked_trailer_is_not_a_header) {
ASSERT_EQ("10.0.0.1", *xff);
}
+TEST(HttpMessageTest, ctl_in_chunk_extension) {
+ // A peer that ends the chunk-size line at the bare LF reads one request
+ // with chunks "xx" and 0x31 bytes. Skipping the LF as part of the
+ // extension read "31" as the chunk data instead, ended the request at
+ // "0\r\n\r\n" and parsed GET /smuggled as the next request.
+ const std::string smuggled =
+ "POST /a HTTP/1.1\r\n"
+ "Host: a.com\r\n"
+ "Transfer-Encoding: chunked\r\n\r\n"
+ "2;\nxx\r\n"
+ "31\r\n"
+ "0\r\n\r\n"
+ "GET /smuggled HTTP/1.1\r\nHost: a.com\r\nX: \r\n\r\n"
+ "0\r\n\r\n";
Review Comment:
The declared `0x31` bytes in the second chunk already include the trailing
newline. After reading all 49 bytes, the terminating chunk follows immediately,
with no `CRLF` after the chunk data. Even if the peer accepts the bare `LF` on
the first line, the chunked format cannot be fully read as the single request
described in the comment. Consider using a valid chunked message with a normal
body as a control, first asserting that it is fully consumed, then changing
only the extension bytes and asserting that bRPC rejects it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]