X509_get_pubkey() already returns an owned reference, so the extra
EVP_PKEY_up_ref() on the cert-store path leaked one reference per
verification, since only one EVP_PKEY_free() is done afterwards. Over
time this means key objects accumulate and are never released, even
across certificate reloads.
Drop the extra reference. The "jwt_cert_tree" path below still needs
its up_ref, since it only holds a borrowed pointer.
Introduced in 3.3 by
522bca98e ("MAJOR: jwt: Allow certificate instead
of public key in jwt_verify converter"). Must be backported to 3.3.
Reported-by: Claude (ANT-2026-PKPCQ3ZN)
store = ckchs_lookup(ctx->key);
if (store) {
if (store->conf.jwt) {
+ /* Note: X509_get_pubkey() already returns an
+ * owned reference, don't take another one!
+ */
pubkey = X509_get_pubkey(store->data->cert);
- if (pubkey)
- EVP_PKEY_up_ref(pubkey);
} else
retval = JWT_VRFY_UNAVAIL_CERT;
}