Skip to content

security(headers): validate response header/cookie values against CRLF - #82

Merged
ZhuchkaTriplesix merged 2 commits into
devfrom
issue-72-header-validation-crlf
Apr 27, 2026
Merged

ZhuchkaTriplesix merged 2 commits into
devfrom
issue-72-header-validation-crlf

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Summary

  • add framework-side sanitization that rejects response header names/values containing CR/LF
  • reject unsafe Set-Cookie lines containing control characters instead of forwarding them downstream
  • add regression tests for malicious Response/HTTPException header and cookie payloads

Test plan

  • uv run maturin develop --uv
  • uv run pytest tests/test_header_sanitization.py tests/test_http_exception.py tests/test_asgi.py

Closes #72

Validate structured response headers and Set-Cookie lines at the framework boundary and fail safely instead of forwarding potentially injected header content.
Add regression tests that assert malicious header and cookie payloads are rejected with safe 500 responses, including HTTPException header payloads.

@ZhuchkaTriplesix ZhuchkaTriplesix left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

123

@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit dde85da into dev Apr 27, 2026
16 checks passed
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.

security(headers): validate response header names/values and Set-Cookie lines against CRLF injection

1 participant