]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: ocsp: Increment certificate_ocsp refcount in 'ssl_sock_copy_cert_key_and_c...
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Thu, 26 Nov 2026 14:38:59 +0000 (15:38 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 26 Nov 2026 14:55:47 +0000 (15:55 +0100)
commit6117bf4bc64b7d443835f084a85459c1e55cefd5
tree8d79a313b56ca8fd53b63c69e062bf0de9ac4c31
parenta505d952ca56e19184b2465c95b15f7a9bd2b601
BUG/MINOR: ocsp: Increment certificate_ocsp refcount in 'ssl_sock_copy_cert_key_and_chain'

ssl_sock_copy_cert_key_and_chain() duplicates a ckch_data and duplicates
its ocsp_cid via OCSP_CERTID_dup(). Since the response tree is keyed on
the OCSP_CERTID itself, the copy points to the very same
certificate_ocsp entry as the original ckch_data, but no additional
reference was taken on it.

This was an issue because ssl_sock_free_cert_key_and_chain_contents
unconditionally decrements this certificate_ocsp's refcount_store while
the matching increment was only performed in ssl_sock_load_ocsp(),

If a duplicated ckch_data is freed (an aborted "set ssl cert"
transaction for instance) while the original ckch_store is still alive,
refcount_store can fall to 0 and the shared certificate_ocsp entry be
freed, leaving the original ckch_store with a dangling pointer. The next
OCSP response lookup or update would then use freed memory.

This was reported by brhenc in GitHub issue #3591.

This patch should be backported up to 2.8.
src/ssl_ckch.c