mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-11-24 00:47:21 +08:00
fix(security): 防止HTTP响应头注入漏洞
This commit is contained in:
@@ -814,7 +814,13 @@ void HttpSession::sendResponse(int code,
|
||||
for (auto &pr : header) {
|
||||
str += pr.first;
|
||||
str += ": ";
|
||||
str += pr.second;
|
||||
// Strip CR and LF from header values to prevent HTTP response splitting (CWE-113).
|
||||
// Any injected \r or \n is silently removed; other characters pass through unchanged.
|
||||
for (char c : pr.second) {
|
||||
if (c != '\r' && c != '\n') {
|
||||
str += c;
|
||||
}
|
||||
}
|
||||
str += "\r\n";
|
||||
}
|
||||
str += "\r\n";
|
||||
|
||||
Reference in New Issue
Block a user