fix: validate header names/values and prevent CRLF injection (#1817) - #2442
fix: validate header names/values and prevent CRLF injection (#1817)#2442SaumyaT-21 wants to merge 8 commits into
Conversation
|
Hey @utksh1 ! Added the fix for CRLF injection and HTTP token validation. All green on CI checks. Please go ahead and review the changes! |
utksh1
left a comment
There was a problem hiding this comment.
Request changes: _HEADER_NAME_re.match() is not anchored, so a value such as X-Test@invalid can pass by matching only the valid prefix. Use a full match/anchors and add tests for trailing invalid characters. Also remove the unrelated frontend/package-lock.json update and add coverage for invalid field values through the actual header-building path.
|
Hey @utksh1 ! All requested backend header validation logic and unit test coverage have been updated and are passing locally. As requested, I've left package-lock.json untouched to keep this PR focused purely on backend changes but frontend checks are currently failing. Please review the latest commits and let me know how to proceed. |
Description
Validates HTTP header names and values in
crawler.pyto ensure they conform to HTTP specs.Specifically:
\r(Carriage Return) and\n(Line Feed) characters to prevent header injection (CRLF) vulnerabilities.ValueErrorwith clear messaging when an invalid header format or illegal character is detected.Related Issues
Closes #1817
Type of Change
How Has This Been Tested?
Tested manually via a local test block in
crawler.pyusing Python in the project's virtual environment:\ror\ncharacters in either the header name or the header value correctly raises aValueError.Checklist