Skip to content

Conversation

@jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Oct 31, 2025

Add ValidateHTTPHeaderName and ValidateHTTPHeaderValue functions to the validation package to prevent CRLF injection and other header-based attacks. These functions use golang.org/x/net/http/httpguts for RFC 7230 compliant validation, matching Go's own HTTP/2 implementation.

The validation checks for:

  • CRLF injection attempts (\r\n)
  • Control characters (null bytes, etc.)
  • RFC 7230 token compliance for header names
  • Length limits (256 bytes for names, 8KB for values)

Add ValidateHTTPHeaderName and ValidateHTTPHeaderValue functions to the
validation package to prevent CRLF injection and other header-based
attacks. These functions use golang.org/x/net/http/httpguts for RFC 7230
compliant validation, matching Go's own HTTP/2 implementation.

The validation checks for:
- CRLF injection attempts (\r\n)
- Control characters (null bytes, etc.)
- RFC 7230 token compliance for header names
- Length limits (256 bytes for names, 8KB for values)
@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.58%. Comparing base (e2c67bb) to head (6492611).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2411      +/-   ##
==========================================
+ Coverage   54.54%   54.58%   +0.03%     
==========================================
  Files         264      264              
  Lines       25351    25367      +16     
==========================================
+ Hits        13828    13846      +18     
+ Misses      10210    10208       -2     
  Partials     1313     1313              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jhrozek jhrozek merged commit 7792dba into main Oct 31, 2025
30 checks passed
@jhrozek jhrozek deleted the validate_headers branch October 31, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants