Can a malicious/malformed DNS name pass gnutls_certificate_verify_peers function?

Thomas Deutschmann <[email protected]>
Newsgroups gmane.network.gnutls.general
Organization Gentoo Foundation, Inc
Message-ID <[email protected]>
Hi,

I am currently auditing a program which was, while looking for a valid
peer name, looping through alternative names list like:

> char szAltName[1024];
> int iAltName;
> char allNames[32*1024];
> int iAllNames;
> size_t szAltNameLen;
> 
> [...]
> 
> while(!bFoundName) {
> 	szAltNameLen = sizeof(szAltName);
> 	gnuRet = gnutls_x509_crt_get_subject_alt_name(cert, iAltName,
> 			szAltName, &szAltNameLen, NULL);
> 	if(gnuRet < 0)
> 		break;
> 	else if(gnuRet == GNUTLS_SAN_DNSNAME) {
> 		iAllNames += snprintf(allNames+iAllNames, sizeof(allNames)-iAllNames,
> 			"DNSname: %s; ", szAltName);
> 		myCustomPeerNameValidator(szAltName, &bFoundName);
> 	}
> 	++iAltName;
> }
> 
> [...]

Like you probably already noticed, "snprintf" usage is invalid and can be
exploited using a crafted certificate with a lot of large SANs.

However, I am wondering if an attack would be very limited because before
this code runs, the program calls "gnutls_certificate_verify_peers2"
function on that certificate. I.e. does GnuTLS guarantees at this stage,
that any certificate validated using this function does only contain
valid dnsNames (i.e. IA5String values) or not?

Thanks.


-- 
Regards,
Thomas Deutschmann / Gentoo Linux Developer
C4DD 695F A713 8F24 2AA1 5638 5849 7EE5 1D5D 74A5

_______________________________________________
Gnutls-help mailing list
[email protected]
http://lists.gnupg.org/mailman/listinfo/gnutls-help
signature.asc (application/pgp-signature, 981 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQKTBAEBCgB9FiEEM8WEgsQCKS0uPFwGlwn5DDyW/8gFAlq4/mFfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDMz
QzU4NDgyQzQwMjI5MkQyRTNDNUMwNjk3MDlGOTBDM0M5NkZGQzgACgkQlwn5DDyW
/8idig/9GKWlM7T1QHVw9Bd9fm6T6leHdAe5f58DZsdIzf6x617JvozSEyNh6oBr
6cQzt9BdOFiTanJxEcS8ZIFsfHkZSoKXg6ulG7/tggdMMqecxSLwKIDV279RE+3w
nWZ9Ebyby88/LJ9GiF6/OhWrnI1ksPL5bC7+QDOWZpQroce8w2GY9O/a+rVoX4+8
cO8h8KeS73iZsmah6EPgSuo7Jv9/SCYHtfsGBHsE9bXmVCVuxtjk8aO9Vh/6BFUK
y17xrxJCm4G8eF4vs19pMLrFLGGxrBJRZtkue3ZBEjFGtv/alqUS/ChmufI0YyXB
fAF1JVrMiWkMM44v1JD8pvPx30RI/YAGbDY4SwsiRWxBodJPtjHR8X+OuRM+K2hI
jzTBdZxxOIvFVs/fu8raXqpM4Z9NKb/YJWq5p8HypCimUJRXhMXVdTp0iiL9E8xU
Z+fEUmtGob2dv0X0ig07BDzjtQkew2HbSIY5mA6JbGANL8nmedIIF1o3HvXU504P
e79TxEbwbKTBw4AeqITndHYuNykwcs4PCT0b1bTC/4kgvGkCTe09r15ewe9ZJe38
V7oHMDnPBaHH4voXl8LjCRMfpJhnzMI4uIv7ziTX6VsM6HpjM5U9lXlIaktHWhEi
IfAuxoyxcpl+o0rktzQ9YR1F1t7JwuwsTon17d8R4wozimkBhwg=
=w8Xg
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.