Skip to content

fix(@angular/ssr): patch Headers.forEach in cloneRequestAndPatchHeaders#32834

Open
alan-agius4 wants to merge 1 commit intoangular:mainfrom
alan-agius4:foreach-header
Open

fix(@angular/ssr): patch Headers.forEach in cloneRequestAndPatchHeaders#32834
alan-agius4 wants to merge 1 commit intoangular:mainfrom
alan-agius4:foreach-header

Conversation

@alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Mar 25, 2026

This commit updates the cloneRequestAndPatchHeaders function to patch the Headers.forEach method. This ensures that host headers are validated when the application iterates over request headers using forEach, preventing potential host header injection attacks during header iteration.

A unit test has been added to validation_spec.ts to verify that forEach correctly triggers validation and throws an error for disallowed hosts.

This commit updates the cloneRequestAndPatchHeaders function to patch the Headers.forEach method. This ensures that host headers are validated when the application iterates over request headers using forEach, preventing potential host header injection attacks during header iteration.

A unit test has been added to validation_spec.ts to verify that forEach correctly triggers validation and throws an error for disallowed hosts.
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances header validation within the cloneRequestAndPatchHeaders utility by patching the forEach method of the Headers object. This ensures that validateHeader is called for each header when forEach is used, preventing invalid headers from being processed. A new test case has been added to specifically verify this behavior, confirming that iterating over headers with forEach triggers the validation and correctly handles disallowed header values. There are no review comments to address.

@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label Mar 25, 2026
@alan-agius4 alan-agius4 requested a review from dgp1130 March 25, 2026 08:39
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/ssr target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants