]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: ssl: Crash because of dangling ckch_store reference in a ckch instance
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Wed, 22 Oct 2025 14:49:06 +0000 (16:49 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Tue, 28 Oct 2025 09:43:45 +0000 (10:43 +0100)
commit7482b6ebf011246916c24a8f4c177c37018f65ad
treea85102e28624fc983d5cbc638f34ffa63f88b57c
parent2d7e3ddd4a28ef9ffefef44e6aa931d555053a3d
BUG/MEDIUM: ssl: Crash because of dangling ckch_store reference in a ckch instance

When updating CAs via the CLI, we need to create new copies of all the
impacted ckch instances (as in referenced in the ckch_inst_link list of
the updated CA) in order to use them instead of the old ones once the
updated is completed. This relies on the ckch_inst_rebuild function that
would set the ckch_store field of the ckch_inst. But we forgot to also
add the newly created instances in the ckch_inst list of the
corresponding ckch_store.

When updating a certificate afterwards, we iterate over all the
instances linked in the ckch_inst list of the ckch_store (which is
missing some instances because of the previous command) and rebuild the
instances before replacing the ckch_store. The previous ckch_store,
still referenced by the dangling ckch instance then gets deleted which
means that the instance keeps a reference to a free'd object.

Then if we were to once again update the CA file, we would iterate over
the ckch instances referenced in the cafile_entry's ckch_inst_link list,
which includes the first mentioned ckch instance with the dead
ckch_store reference. This ends up crashing during the ckch_inst_rebuild
operation.

This bug was raised in GitHub #3165.
This patch should be backported to all stable branches.
src/ssl_ckch.c