Several of our OpenSSL-specific certificate-parsing code paths did not
always clear all allocated memory. Since a client can cause a few bytes
of memory to be leaked for each connection attempt, a client can cause a
server to run out of memory and thereby kill the server. That makes this
a (quite inefficient) DoS attack.
When using the --x509-alt-username option on openssl builds with an
extension (argument prefixed with "ext:", e.g. "ext:subjectAltName"), the
code would not free all allocated memory. Fix this by using the proper
free function.
If ASN1_STRING_to_UTF8() returns 0, it didn't fail and *did* allocate
memory. So also free the returned buffer if it returns 0.
These issues were found, analysed and reported to the OpenVPN team by Guido
Vranken.
CVE: 2017-7521
Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Acked-by: Guido Vranken <guidovranken@gmail.com>
Message-Id: <1497864520-12219-4-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/search?l=mid&q=1497864520-12219-4-git-send-email-steffan.karger@fox-it.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
... | ... |
@@ -313,6 +313,11 @@ Security |
313 | 313 |
--x509-track option and the client has a correct, signed and unrevoked |
314 | 314 |
certificate that contains an embedded NUL in the certificate subject. |
315 | 315 |
Discovered and reported to the OpenVPN security team by Guido Vranken. |
316 |
+- CVE-2017-7521: Fix post-authentication remote-triggerable memory leaks |
|
317 |
+ A client could cause a server to leak a few bytes each time it connects to the |
|
318 |
+ server. That can eventuall cause the server to run out of memory, and thereby |
|
319 |
+ causing the server process to terminate. Discovered and reported to the |
|
320 |
+ OpenVPN security team by Guido Vranken. (OpenSSL builds only.) |
|
316 | 321 |
|
317 | 322 |
User-visible Changes |
318 | 323 |
-------------------- |
... | ... |
@@ -163,7 +163,7 @@ extract_x509_extension(X509 *cert, char *fieldname, char *out, int size) |
163 | 163 |
break; |
164 | 164 |
} |
165 | 165 |
} |
166 |
- sk_GENERAL_NAME_free(extensions); |
|
166 |
+ GENERAL_NAMES_free(extensions); |
|
167 | 167 |
} |
168 | 168 |
return retval; |
169 | 169 |
} |
... | ... |
@@ -225,8 +225,7 @@ extract_x509_field_ssl(X509_NAME *x509, const char *field_name, char *out, |
225 | 225 |
{ |
226 | 226 |
return FAILURE; |
227 | 227 |
} |
228 |
- tmp = ASN1_STRING_to_UTF8(&buf, asn1); |
|
229 |
- if (tmp <= 0) |
|
228 |
+ if (ASN1_STRING_to_UTF8(&buf, asn1) < 0) |
|
230 | 229 |
{ |
231 | 230 |
return FAILURE; |
232 | 231 |
} |
... | ... |
@@ -466,7 +465,7 @@ x509_setenv_track(const struct x509_track *xt, struct env_set *es, const int dep |
466 | 466 |
{ |
467 | 467 |
ASN1_STRING *val = X509_NAME_ENTRY_get_data(ent); |
468 | 468 |
unsigned char *buf = NULL; |
469 |
- if (ASN1_STRING_to_UTF8(&buf, val) > 0) |
|
469 |
+ if (ASN1_STRING_to_UTF8(&buf, val) >= 0) |
|
470 | 470 |
{ |
471 | 471 |
do_setenv_x509(es, xt->name, (char *)buf, depth); |
472 | 472 |
OPENSSL_free(buf); |
... | ... |
@@ -553,7 +552,7 @@ x509_setenv(struct env_set *es, int cert_depth, openvpn_x509_cert_t *peer_cert) |
553 | 553 |
{ |
554 | 554 |
continue; |
555 | 555 |
} |
556 |
- if (ASN1_STRING_to_UTF8(&buf, val) <= 0) |
|
556 |
+ if (ASN1_STRING_to_UTF8(&buf, val) < 0) |
|
557 | 557 |
{ |
558 | 558 |
continue; |
559 | 559 |
} |