chenBright commented on code in PR #3387:
URL: https://github.com/apache/brpc/pull/3387#discussion_r3594082261
##########
src/brpc/details/http_message.cpp:
##########
@@ -734,11 +761,22 @@ void MakeRawHttpResponse(butil::IOBuf* response,
}
}
if (!is_invalid_content && !h->content_type().empty()) {
- os << "Content-Type: " << h->content_type()
- << BRPC_CRLF;
+ if (HeaderHasCRLF(h->content_type())) {
+ LOG(WARNING) << "Skip Content-Type `"
+ << butil::ToPrintable(h->content_type())
+ << "' containing CR/LF to avoid injection";
+ } else {
+ os << "Content-Type: " << h->content_type()
+ << BRPC_CRLF;
+ }
}
for (HttpHeader::HeaderIterator it = h->HeaderBegin();
it != h->HeaderEnd(); ++it) {
+ if (HeaderHasCRLF(it->first) || HeaderHasCRLF(it->second)) {
+ LOG(WARNING) << "Skip header `" << butil::ToPrintable(it->first)
Review Comment:
`it->second` also need to be logged.
--
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]