]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
x509: avoid double free when exporting othernames in SAN
authorDaiki Ueno <ueno@gnu.org>
Mon, 7 Jul 2025 01:44:12 +0000 (10:44 +0900)
committerDaiki Ueno <ueno@gnu.org>
Mon, 7 Jul 2025 21:57:48 +0000 (06:57 +0900)
Previously, the _gnutls_write_new_othername function, called by
gnutls_x509_ext_export_subject_alt_names to export "otherName" in a
certificate's SAN extension, freed the caller allocated ASN.1
structure upon error, resulting in a potential double-free.

Reported by OpenAI Security Research Team.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
NEWS
lib/x509/extensions.c

diff --git a/NEWS b/NEWS
index 1f3dec4f0c55e4e717497baa1ba828211079b90d..eb29ece30d5371fdca9bed1de115854715c5a399 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,9 +12,14 @@ See the end for copying conditions.
    and fix developed by Andrew Hamilton. [GNUTLS-SA-2025-07-07-1,
    CVSS: medium] [CVE-2025-32989]
 
+** libgnutls: Fix double-free upon error when exporting otherName in SAN
+   Reported by OpenAI Security Research Team. [GNUTLS-SA-2025-07-07-2,
+   CVSS: low] [CVE-2025-32988]
+
 ** libgnutls: PKCS#11 modules can now be used to override the default
    cryptographic backend. Use the [provider] section in the system-wide config
    to specify path and pin to the module (see system-wide config Documentation).
+
 ** libgnutls: Linux kernel version 6.14 bring a Kernel TLS (kTLS) key update
    support. The library running on the aforementioned version now utilizes the
    kernel’s key update mechanism when kTLS is enabled, allowing uninterrupted
index 6c2da8fd106e87b588709e3d812f3ee61b39134a..e8be12eaf517503da0d2fe0681ef46c9e987e954 100644 (file)
@@ -754,7 +754,6 @@ int _gnutls_write_new_othername(asn1_node ext, const char *ext_name,
        result = asn1_write_value(ext, name2, oid, 1);
        if (result != ASN1_SUCCESS) {
                gnutls_assert();
-               asn1_delete_structure(&ext);
                return _gnutls_asn2err(result);
        }
 
@@ -763,7 +762,6 @@ int _gnutls_write_new_othername(asn1_node ext, const char *ext_name,
        result = asn1_write_value(ext, name2, data, data_size);
        if (result != ASN1_SUCCESS) {
                gnutls_assert();
-               asn1_delete_structure(&ext);
                return _gnutls_asn2err(result);
        }