Skip to content

fix: avoid deduplication key collisions#5017

Closed
mcollina wants to merge 1 commit intomainfrom
fix-5012-dedup-key-collision
Closed

fix: avoid deduplication key collisions#5017
mcollina wants to merge 1 commit intomainfrom
fix-5012-dedup-key-collision

Conversation

@mcollina
Copy link
Copy Markdown
Member

Description

Fix deduplication key collisions in the deduplicate interceptor.

The old key builder concatenated headers with : and = delimiters without escaping them, so distinct header sets could produce the same in-flight deduplication key.

This change switches makeDeduplicationKey() to a structured JSON serialization of:

  • origin
  • method
  • path
  • sorted header entries

That preserves deterministic ordering while avoiding delimiter-based collisions.

Changes

  • replace delimiter-based deduplication key construction with structured serialization
  • add a unit test covering the reported header collision
  • add an interceptor test proving those requests no longer deduplicate incorrectly

Testing

  • node --test test/cache-interceptor/cache-utils.js
  • ./node_modules/.bin/borp -p "test/interceptors/deduplicate.js"
  • ./node_modules/.bin/eslint lib/util/cache.js test/cache-interceptor/cache-utils.js test/interceptors/deduplicate.js

Closes: #5012

Signed-off-by: Matteo Collina <hello@matteocollina.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.93%. Comparing base (4f4bf4f) to head (2f76703).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5017      +/-   ##
==========================================
+ Coverage   92.86%   92.93%   +0.06%     
==========================================
  Files         110      110              
  Lines       35788    35743      -45     
==========================================
- Hits        33235    33217      -18     
+ Misses       2553     2526      -27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina closed this Apr 10, 2026
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] Cache deduplication key collision via unescaped delimiters

2 participants