File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -552,9 +552,15 @@ let textEncoder: TextEncoder | undefined;
552552/**
553553 * Generates a SHA-256 hash representation of a string.
554554 *
555- * Note: A custom synchronous SHA-256 implementation is used here because the
556- * Web Crypto API (`crypto.subtle.digest`) is strictly asynchronous (Promise-based),
557- * whereas the transfer cache state lookup and interceptor flow must operate synchronously due to the HttpResource API.
555+ * Note: A custom synchronous SHA-256 implementation is used here because the Web Crypto API
556+ * (`crypto.subtle.digest`) is strictly asynchronous (Promise-based), whereas the transfer cache
557+ * state lookup and interceptor flow must operate synchronously due to the HttpResource API.
558+ *
559+ * The previous DJB2 hashing logic was vulnerable to pre-image and second-preimage attacks due to
560+ * its small 64-bit keyspace and mathematical simplicity. An attacker could craft colliding request
561+ * inputs to poison the cache, potentially causing a CDN or the application to serve the wrong
562+ * cached response to legitimate users. SHA-256 provides strong cryptographic collision resistance,
563+ * preventing cache key collision attacks.
558564 */
559565export function generateHash ( value : string ) : string {
560566 textEncoder ??= new TextEncoder ( ) ;
You can’t perform that action at this time.
0 commit comments