Skip to content

fix(http): prevent duplicate search params in transfer cache key generation - #68424

Closed
kon72 wants to merge 1 commit into
angular:mainfrom
kon72:fix-transfer-cache-key
Closed

fix(http): prevent duplicate search params in transfer cache key generation#68424
kon72 wants to merge 1 commit into
angular:mainfrom
kon72:fix-transfer-cache-key

Conversation

@kon72

@kon72 kon72 commented Apr 28, 2026

Copy link
Copy Markdown

Updates sortAndConcatParams in TransferCache to deduplicate search param keys before sorting and concatenating them into a string.

Also adds tests for sortAndConcatParams to verify that it correctly normalizes both HttpParams and URLSearchParams.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Since URLSearchParams.prototype.keys() returns all keys including duplicates, the previous implementation could produce a string of length O(N^2) where N is the number of duplicate search param keys, potentially leading to OOM and excessive CPU usage when the request body is controllable by the user.
For example, the search params foo=1&bar=2&foo=3 would produce the string bar=2&foo=1,3&foo=1,3 instead of the expected bar=2&foo=1,3.

What is the new behavior?

sortAndConcatParams correctly handle duplicate search param key.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@pullapprove
pullapprove Bot requested a review from JeanMeche April 28, 2026 16:49
@google-cla

This comment was marked as outdated.

@angular-robot angular-robot Bot added the area: common/http Issues related to HTTP and HTTP Client label Apr 28, 2026
@ngbot ngbot Bot added this to the Backlog milestone Apr 28, 2026
Comment thread packages/common/http/src/transfer_cache.ts Outdated
@kon72
kon72 force-pushed the fix-transfer-cache-key branch from 06034dd to 4d30666 Compare April 28, 2026 16:52
@JeanMeche

Copy link
Copy Markdown
Member

Your commit was authored by co****t​@github.com which didn't signed the CLA.

…ration

Updates `sortAndConcatParams` in TransferCache to deduplicate search param keys before sorting and concatenating them into a string.

Since `URLSearchParams.prototype.keys()` returns all keys including duplicates, the previous implementation could produce a string of length `O(N^2)` where `N` is the number of duplicate search param keys, potentially leading to OOM and excessive CPU usage when the request body is controllable by the user.
For example, the search params `foo=1&bar=2&foo=3` would produce the string `bar=2&foo=1,3&foo=1,3` instead of the expected `bar=2&foo=1,3`.

Also adds tests for `sortAndConcatParams` to verify that it correctly normalizes both `HttpParams` and `URLSearchParams`.
@kon72
kon72 force-pushed the fix-transfer-cache-key branch from 4d30666 to d9825eb Compare April 28, 2026 16:56
@google-cla google-cla Bot added cla: yes and removed cla: no labels Apr 28, 2026
@kon72

kon72 commented Apr 28, 2026

Copy link
Copy Markdown
Author

Your commit was authored by co****t​@github.com which didn't signed the CLA.

Weird. It looks like VS Code Copilot extension silently added copilot@github.com as a co-author.
It should be fixed now.

@JeanMeche

Copy link
Copy Markdown
Member

We'll likely go with #68571 which is a broader fix.

@JeanMeche JeanMeche closed this May 5, 2026
@angular-automatic-lock-bot

Copy link
Copy Markdown

This pull request has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jun 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: common/http Issues related to HTTP and HTTP Client cla: yes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants