]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: cache: Seed cache primary hash
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Wed, 26 Aug 2026 15:08:26 +0000 (17:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 26 Aug 2026 16:26:27 +0000 (18:26 +0200)
Since only the first 32bits of the primary hash built in sha1_hosturi
are used as key in the cache tree and we reject entries when a hash
collision happens, it would be possible for an attacher to fill a
specific cache entry with "wrong" data and prevent actual caching.
Since a cache seed was already built for secondary key hashes we might
as well use it for primary hashes as well.

Reported-by: Claude (ANT-2026-9WRFEVJ3)
This patch should be backported to all stable branches.

src/cache.c

index b3009d41353d956c0d19ac8927cf217e8f64887f..b1a9803d6b9ccb43369efd5bdaa1d2370266c6d5 100644 (file)
@@ -2434,6 +2434,7 @@ int sha1_hosturi(struct stream *s)
 
        /* hash everything */
        blk_SHA1_Init(&sha1_ctx);
+       blk_SHA1_Update(&sha1_ctx, &cache_hash_seed, sizeof(cache_hash_seed));
        blk_SHA1_Update(&sha1_ctx, trash->area, trash->data);
        blk_SHA1_Final((unsigned char *)txn->cache_hash, &sha1_ctx);