Skip to content

fix(cache): honor a Vary field named __proto__ - #6234

Open
mcollina wants to merge 1 commit into
mainfrom
fix/cache-vary-proto-header
Open

mcollina wants to merge 1 commit into
mainfrom
fix/cache-vary-proto-header

Conversation

@mcollina

Copy link
Copy Markdown
Member

parseVaryHeader writes the Vary map with a bare assignment, so a Vary field literally named __proto__ hits the Object.prototype.__proto__ setter instead of creating an own property. The parsed map ends up empty, and varyMatches then treats the stored entry as matching every request. In shared cache mode, an application that uses a __proto__ request header to vary per-tenant responses would have one tenant's cached body served to another.

Store the field via the setHeader util (already used by the cache key and deduplication builders) so it becomes an own property, and add a regression test that asserts the cache keeps two __proto__ variants separate.

parseVaryHeader wrote the Vary map with a bare assignment
(output[trimmedHeader] = ...). For a Vary field literally named
__proto__ this hits the Object.prototype __proto__ setter instead of
creating an own property, so no dimension is recorded and varyMatches
treats the stored entry as matching every request. A shared cache then
serves one tenant's cached response to another when the application
uses a __proto__ request header to vary responses.

Use the setHeader util, already imported and used by the cache key and
deduplication builders, so the field is stored as an own property.
@codecov-commenter

codecov-commenter commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.71%. Comparing base (011d947) to head (a411d1b).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6234      +/-   ##
==========================================
+ Coverage   91.67%   91.71%   +0.04%     
==========================================
  Files         113      113              
  Lines       44489    44816     +327     
==========================================
+ Hits        40786    41105     +319     
- Misses       3703     3711       +8     

☔ View full report in Codecov by Harness.
📢 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.

This branch has not been deployed

No deployments
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.

2 participants