Commit a6c1091a8f for openssl.org

commit a6c1091a8feadf0a16851cdda38a85aafe41cb11
Author: Neil Horman <nhorman@openssl.org>
Date:   Tue Jun 30 15:09:01 2026 -0400

    Fix unbounded cert cache growth in cmp

    If a remote user sends cmp messages to a server with a list of
    extraCerts and the message is rejected, the extraCerts from the message
    remain in the server contexts untrusted certificate stack.  This exposes
    servers with long lived ctx objects to denial of service attacks in
    which an attacker sends messages intending to be rejected with a large
    list of additional cerificated repeatedly, forcing the server to store
    them indefinately.

    Fix it by rolling back the added extra certs if the message is rejected,
    using the same method we do when the context is configured to not do
    caching at all.

    Fixes openssl/srt#224

    Fixes CVE-2026-63074

    Reviewed-by: Milan Broz <mbroz@openssl.org>
    Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
    Merge-date: Mon Aug 24 12:41:41 2026

diff --git a/crypto/cmp/cmp_vfy.c b/crypto/cmp/cmp_vfy.c
index 48014295e3..c529464dce 100644
--- a/crypto/cmp/cmp_vfy.c
+++ b/crypto/cmp/cmp_vfy.c
@@ -816,8 +816,13 @@ int ossl_cmp_msg_check_update(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *msg,
     res = 1; /* support more aggressive fuzzing by letting invalid msg pass */
 #endif

-    /* remove extraCerts again if not caching */
-    if (ctx->noCacheExtraCerts)
+    /*
+     * remove extraCerts again if not caching
+     * or if we failed validation above, lest a remote user
+     * starts sending us lots of certificates in invalid messages
+     * leading to a DOS from unbounded certificate stack growth
+     */
+    if (ctx->noCacheExtraCerts || res != 1)
         while (num_added-- > 0)
             X509_free(sk_X509_shift(ctx->untrusted));