Add CRLF injection protection for header values

Implement security validation to prevent HTTP header injection attacks:
- Reject header values containing \r or \n characters
- Add comprehensive test coverage for CRLF protection
- Replace multiline YAML test with proper rejection test

Security improvements:
- Validates header values to prevent header injection
- Clear warning messages when values are rejected
- Four new test cases covering LF, CR, CRLF, and multiline scenarios

This addresses a critical security concern where malicious headers
could be injected via newline characters in header values.

All 84 tests passing.
This commit is contained in:
Yonatan Golick
2026-01-18 12:19:43 +02:00
parent f77380037b
commit 15ae50ae2f
4 changed files with 63 additions and 5 deletions
Generated Vendored
+5
View File
@@ -61361,6 +61361,11 @@ function validateAndMaskHeaders(headers) {
}
// Convert value to string
const stringValue = String(value);
// Validate header value to prevent CRLF/header injection
if (stringValue.includes('\r') || stringValue.includes('\n')) {
coreExports.warning(`Skipping header "${name}" because its value contains newline characters, which are not allowed in HTTP header values.`);
continue;
}
validHeaders[name] = stringValue;
// Mask sensitive headers in logs
const lowerName = name.toLowerCase();
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long