fix: strip CRLF from response header values - #14
Conversation
|
Error: [4014] |
Strip CR/LF from header values, validate header names against the HTTP token charset (RFC 7230), and sanitize cookie fields across all three backends (native, mongoose, JS). Native backend now passes cookies via the upstream cookies= parameter instead of manually joining with CRLF, eliminating the trusted response splitting pattern. Sanitization functions live in internal/header to avoid polluting the public API while sharing code between root and mongoose packages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d6a6c20 to
6a4a19e
Compare
Summary
Fix HTTP response header injection (CWE-113) across all three backends.
Changes per review feedback:
main— adapted to the unifieddispatch_httpflow; noexecute_middlewaresreferences remain.is_valid_header_name()that validates against the RFC 7230tokencharset. Headers with invalid names are silently dropped in all three backends.cookies.join("\r\nSet-Cookie: ")CRLF-join hack with the upstreamcookies=parameter onServerConnection::send_response. Addedcookie_item_to_http_cookieto convertCookieItem→@http.Cookie, sanitizing name/value/path/domain fields.sanitize_header_valueandis_valid_header_nametointernal/header, shared by root and mongoose packages. Rootpkg.generated.mbtino longer exposes implementation details.Verification
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com