Skip to content

fix(http): distinguish binary transfer cache request bodies - #70227

Open
SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:fix/http-transfer-cache-body-identity
Open

fix(http): distinguish binary transfer cache request bodies#70227
SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:fix/http-transfer-cache-body-identity

Conversation

@SkyZeroZx

@SkyZeroZx SkyZeroZx commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Include the serialized body type and ArrayBuffer bytes in transfer cache keys. Avoid caching Blob and FormData requests when a complete synchronous identity cannot be derived.

Prevent distinct protobuf and gRPC POST payloads from sharing a cache entry during hydration.

Fixes #70226

The impact is similar to other cache poisoning or cache-key confusion issues: distinct attacker-controlled protobuf or gRPC bodies could collide on the same cache key, causing a response cached for one request to be incorrectly reused for another during hydration , similar to advisories such as GHSA-jhpw-976m-542j and GHSA-39pv-4j6c-2g6v.

A minimal example can also be seen at https://github.com/SkyZeroZx/angular-protobuf-transfercache-poc

@angular-robot angular-robot Bot added the area: common/http Issues related to HTTP and HTTP Client label Aug 16, 2026
@ngbot ngbot Bot added this to the Backlog milestone Aug 16, 2026
@SkyZeroZx
SkyZeroZx force-pushed the fix/http-transfer-cache-body-identity branch 2 times, most recently from 52eab8e to d7f932d Compare August 16, 2026 23:42
});
});

it('should not cache POST requests with Blob bodies', () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looking into it a bit more, we could try wrapping it in observables and modifying the interceptor in transferCache, but that would be extra work and would further increase the bundle size.

I'm not sure if it's worthwhile or if we should revisit it later.

@SkyZeroZx
SkyZeroZx marked this pull request as ready for review August 17, 2026 05:01
bodyForCacheKey = sortAndConcatParams(serializedBody);
} else if (serializedBody instanceof ArrayBuffer) {
bodyType = 'arrayBuffer';
bodyForCacheKey = toBase64(serializedBody);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do see a concern with very large bodies here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated, we can directly use the ArrayBuffer bytes to convert it to SHA-256, avoiding unnecessary conversion back to bytes.

@SkyZeroZx
SkyZeroZx force-pushed the fix/http-transfer-cache-body-identity branch 2 times, most recently from bc039fb to 8ee9f48 Compare August 17, 2026 22:05
@@ -1,5 +1,5 @@
{
"dist/browser/main-[hash].js": 232419,
"dist/browser/main-[hash].js": 237440,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Apparently, it was not updated (or exceeded the accepted tolerance) when SHA-256 was added.

Include the serialized body type and ArrayBuffer bytes in transfer cache keys.
Avoid caching Blob and FormData requests when a complete synchronous identity cannot be derived.

Prevent distinct protobuf and gRPC POST payloads from sharing a cache entry during hydration.

Fixes angular#70226
@SkyZeroZx
SkyZeroZx force-pushed the fix/http-transfer-cache-body-identity branch from dff1192 to 4f4bc43 Compare August 19, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HttpTransferCache collapses distinct binary POST bodies into the same cache key

2 participants