Skip to content

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

Merged
alan-agius4 merged 1 commit intoangular:mainfrom
alan-agius4:foreach-header
Mar 26, 2026
Merged

fix(@angular/ssr): patch Headers.forEach in cloneRequestAndPatchHeaders#32834
alan-agius4 merged 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
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 25, 2026
@alan-agius4 alan-agius4 merged commit bcd99f9 into angular:main Mar 26, 2026
39 checks passed
@alan-agius4 alan-agius4 deleted the foreach-header branch March 26, 2026 12:35
@alan-agius4
Copy link
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

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

Labels

action: merge The PR is ready for merge by the caretaker 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