summaryrefslogtreecommitdiff
path: root/main/tcptls.c
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2015-04-08 16:49:18 +0000
committerJonathan Rose <jrose@digium.com>2015-04-08 16:49:18 +0000
commit8ec9a82b9a96846244b94faafa0f8d5768032eb2 (patch)
tree12ba26d2f59b48f9fda082db6ab79d2786ec5f01 /main/tcptls.c
parent2bd9e008a71a1212b0131ff7073146478e7c16b7 (diff)
Security/tcptls: MitM Attack potential from certificate with NULL byte in CN.
When registering to a SIP server with TLS, Asterisk will accept CA signed certificates with a common name that was signed for a domain other than the one requested if it contains a null character in the common name portion of the cert. This patch fixes that by checking that the common name length matches the the length of the content we actually read from the common name segment. Some certificate authorities automatically sign CA requests when the requesting CN isn't already taken, so an attacker could potentially register a CN with something like www.google.com\x00www.secretlyevil.net and have their certificate signed and Asterisk would accept that certificate as though it had been for www.google.com - this is a security fix and is noted in AST-2015-003. ASTERISK-24847 #close Reported by: Maciej Szmigiero Patches: asterisk-null-in-cn.patch submitted by mhej (license 6085) ........ Merged revisions 434337 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 434338 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 434384 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434385 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/tcptls.c')
-rw-r--r--main/tcptls.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/main/tcptls.c b/main/tcptls.c
index 22fb1447e..92fee604d 100644
--- a/main/tcptls.c
+++ b/main/tcptls.c
@@ -640,9 +640,15 @@ static void *handle_tcptls_connection(void *data)
break;
}
str = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name, pos));
- ASN1_STRING_to_UTF8(&str2, str);
+ ret = ASN1_STRING_to_UTF8(&str2, str);
+ if (ret < 0) {
+ continue;
+ }
+
if (str2) {
- if (!strcasecmp(tcptls_session->parent->hostname, (char *) str2)) {
+ if (strlen((char *) str2) != ret) {
+ ast_log(LOG_WARNING, "Invalid certificate common name length (contains NULL bytes?)\n");
+ } else if (!strcasecmp(tcptls_session->parent->hostname, (char *) str2)) {
found = 1;
}
ast_debug(3, "SSL Common Name compare s1='%s' s2='%s'\n", tcptls_session->parent->hostname, str2);