]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ssl-gencert: enforce a stronger seed for the LRU cache key flx04/master
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 14 Aug 2026 09:07:12 +0000 (09:07 +0000)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 14 Aug 2026 09:07:12 +0000 (09:07 +0000)
The generated-certificate LRU cache key is seeded with the process
start time (time(NULL)).

This is not considered a bug per se: 'generate-certificates' is
generally deployed in MITM/interception contexts where the operator
already controls both ends of the connection. Still, relying on the
process start time for this seed is fragile, so switch to
ha_random64(), which is seeded at boot from /dev/urandom and
OpenSSL's RAND_bytes().

src/ssl_gencert.c

index f57c655ff6909788aa4e4622db95f5c08cc2c133..b608f552c30bc1868b2e426d26c801c1d301a19b 100644 (file)
@@ -15,6 +15,7 @@
 #include <haproxy/quic_ssl.h>
 #include <haproxy/ssl_ckch.h>
 #include <haproxy/ssl_sock.h>
+#include <haproxy/tools.h>
 #include <haproxy/xxhash.h>
 
 #if (defined SSL_CTRL_SET_TLSEXT_HOSTNAME && !defined SSL_NO_GENERATE_CERTIFICATES)
@@ -440,7 +441,8 @@ ssl_sock_gencert_load_ca(struct bind_conf *bind_conf)
        if (global_ssl.ctx_cache) {
                ssl_ctx_lru_tree = lru64_new(global_ssl.ctx_cache);
        }
-       ssl_ctx_lru_seed = (uint64_t)time(NULL);
+       /* unpredictable seed, must not be guessable from the outside */
+       ssl_ctx_lru_seed = ha_random64();
        ssl_ctx_serial   = now_ms;
 #endif