Skip to content

security: validate header names and values to prevent CRLF injection - #2184

Open
insaf021 wants to merge 1 commit into
googleapis:mainfrom
insaf021:security/crlf-header-validation
Open

security: validate header names and values to prevent CRLF injection#2184
insaf021 wants to merge 1 commit into
googleapis:mainfrom
insaf021:security/crlf-header-validation

Conversation

@insaf021

Copy link
Copy Markdown

HttpHeaders#addHeader now rejects header names/values containing CR (\r) or LF (\n),
throwing IllegalArgumentException on CRLF injection attempts — prevents HTTP Header
Injection and Response Splitting.

Changes

  • HttpHeaders.java: added CRLF validation in addHeader() after computing stringValue.

  • HttpHeadersTest.java: added testSerializeHeaders_crlfInjectionInName and
    testSerializeHeaders_crlfInjectionInValue.

  • Opened an issue before writing code — Core: Validate header names and values to prevent CRLF injection #2180

  • Tests and linter pass

  • Code coverage does not decrease (2 new tests added)

  • Docs updated

Fixes #2180 ☕️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core: Validate header names and values to prevent CRLF injection

1 participant