Skip to content

Commit

Permalink
Fix freshly introduced double-free.
Browse files Browse the repository at this point in the history
We don't need the decoded X.509 Full(0) certificate for the EE usages 1 and 3,
because the leaf certificate is always part of the presented chain, so the
certificate is only validated as well-formed, and then discarded, but the
TLSA record is of course still used after the validation step.

Added DANE test cases for: 3 0 0, 3 1 0, 1 0 0, and 1 1 0

Reported by Claus Assmann.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from #22821)

(cherry picked from commit f636e7e)
  • Loading branch information
Viktor Dukhovni authored and t8m committed Nov 29, 2023
1 parent 3b61584 commit dcfed00
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 49 deletions.
13 changes: 12 additions & 1 deletion ssl/ssl_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,19 @@ static int dane_tlsa_add(SSL_DANE *dane,
}

if ((DANETLS_USAGE_BIT(usage) & DANETLS_TA_MASK) == 0) {
/*
* The Full(0) certificate decodes to a seemingly valid X.509
* object with a plausible key, so the TLSA record is well
* formed. However, we don't actually need the certifiate for
* usages PKIX-EE(1) or DANE-EE(3), because at least the EE
* certificate is always presented by the peer. We discard the
* certificate, and just use the TLSA data as an opaque blob
* for matching the raw presented DER octets.
*
* DO NOT FREE `t` here, it will be added to the TLSA record
* list below!
*/
X509_free(cert);
tlsa_free(t);
break;
}

Expand Down

0 comments on commit dcfed00

Please sign in to comment.