Skip to content

Harden Response/Output cache - #68517

Merged
Youssef1313 merged 3 commits into
mainfrom
dev/ygerges/harden-cache
Aug 14, 2026
Merged

Youssef1313 merged 3 commits into
mainfrom
dev/ygerges/harden-cache

Conversation

@Youssef1313

Copy link
Copy Markdown
Member

Fixes #67907

This separates path base and path via key delimiter

Copilot AI lite review requested due to automatic review settings August 14, 2026 09:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the cache key serialization used by Response Caching and Output Caching by making the (PathBase, Path) portion of the key injective, preventing distinct tuples from producing identical cache keys.

Changes:

  • Insert the existing reserved KeyDelimiter (\x1e) between HttpRequest.PathBase and HttpRequest.Path in both key providers (case-sensitive and case-insensitive modes).
  • Update existing key-provider tests to reflect the new delimiter placement.
  • Add new tests asserting non-collision for a previously ambiguous (PathBase, Path) concatenation scenario.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/Middleware/ResponseCaching/src/ResponseCachingKeyProvider.cs Inserts KeyDelimiter between PathBase and Path when building the base key.
src/Middleware/ResponseCaching/test/ResponseCachingKeyProviderTests.cs Updates expected base-key strings and adds an injectivity test.
src/Middleware/OutputCaching/src/OutputCacheKeyProvider.cs Inserts KeyDelimiter between PathBase and Path when building the base key.
src/Middleware/OutputCaching/test/OutputCacheKeyProviderTests.cs Updates expected storage-key strings and adds an injectivity test.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
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.

Hardening: make Response/Output cache base-key serialization injective across PathBase and Path

4 participants