Ignore illegal response header (#2439)#5
Conversation
* Ignore illegal response header
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||
User description
PR_055
PR Type
Bug fix
Description
Validate response headers against RFC specifications
Reject headers with illegal characters in keys and values
Block reserved header keys starting with "rack." and "status"
Enable previously skipped header validation tests
Diagram Walkthrough
File Walkthrough
const.rb
Add RFC-compliant header validation constantslib/puma/const.rb
HTTP_INJECTION_REGEXconstantILLEGAL_HEADER_KEY_REGEXto detect non-compliant header keysILLEGAL_HEADER_VALUE_REGEXto detect non-compliant header valuesBANNED_HEADER_KEYregex to block reserved "rack." and "status"keys
request.rb
Implement header validation and filtering logiclib/puma/request.rb
illegal_header_key?method to validate header key formatpossible_header_injection?toillegal_header_value?forclarity
str_early_hintsto filter illegal header keys and valuesstr_headersto filter illegal keys, values, and bannedreserved keys
test_response_header.rb
Enable header validation test casestest/test_response_header.rb
skipdirectives from 8 test casesscenarios
History.md
Document header validation bugfixHistory.md