]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: cache: Manage collisions on primary key
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Tue, 18 Aug 2026 16:01:23 +0000 (18:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 26 Aug 2026 16:26:27 +0000 (18:26 +0200)
commitc813ccd944df3261c09afb83cde4b1a4bfb06af4
treeb8b492480c04877daa94b48386bfcae5f60a07d4
parentb722b691d10de052ca54276f01c986129d8a7a64
BUG/MINOR: cache: Manage collisions on primary key

When storing an entry in the cache, we calculate a hash (sha1) of the
host and uri which is 20 bytes long but we only use the first 4 bytes of
this hash as key for the eb32 tree. The tree itself is then vulnerable
to collisions which might even be forced since the sha1 is not seeded.
Since all the "vary" logic was added to the cache, dup entries have been
allowed so colliding entries would then be inserted in the tree
indefinitely and only the first one would be retrieved in the use_cache
operation.
This patch checks that in case of collision the full hashes match, and
if not the newly inserted entry is removed.

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