Implement request smuggling protection for duplicate Content-Length headers and add corresponding tests

This commit is contained in:
yhirose committed 2026-03-13 00:05:13 -04:00
1 parent d279eff4db
commit 1e97c28e36
2 files changed
+70

No files matched your search

+10
View File
@@ -6813,6 +6813,16 @@ inline bool read_headers(Stream &strm, Headers &headers) {
header_count++;
}
// RFC 9110 Section 8.6: Reject requests with multiple Content-Length
// headers that have different values to prevent request smuggling.
auto cl_range = headers.equal_range("Content-Length");
if (cl_range.first != cl_range.second) {
const auto &first_val = cl_range.first->second;
for (auto it = std::next(cl_range.first); it != cl_range.second; ++it) {
if (it->second != first_val) { return false; }
}
}
return true;
}