]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: tools: insert an XXH64 layer on the PRNG output
authorWilly Tarreau <w@1wt.eu>
Mon, 25 May 2026 15:30:58 +0000 (17:30 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 26 May 2026 11:13:24 +0000 (13:13 +0200)
commit9b6389c8a007cd86ebd61f1d3b33c13468abf26d
tree000df0b545532efa9c799a0c588a6e28d849de77
parent93f9ecbfe62a8ede2ab86dd1cb858f972697cd83
BUG/MEDIUM: tools: insert an XXH64 layer on the PRNG output

Consuming randoms in pairs directly exposes the internal PRNG's state
on moderately idle system. It can allow to predict next (or previous)
UUIDs, QUIC retry tokens, and WS keys for example. Let's insert an XXH64
call on the ha_random64() output to avoid this. We expand the boot seed
as the secret at boot, and use now_ns as the seed for each call. The
original ha_random64() function was renamed to ha_random64_internal()
for use cases where it's not a problem to directly use the internal
state.

The performance loss is only measurable when single-threaded. It drops
from 7.32M UUID per second to 7.16M. Above that there is no longer any
difference due to the DWCAS loop which reaches up to 98.5% CPU at 20
threads.

This will need to be backported to stable releases after a period of
observation.
include/haproxy/tools.h
src/tools.c