[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-18 Thread Christian Heimes
Christian Heimes added the comment: The IDNA RFC contains additional rules for wildcard matching ... very well hidden indead! http://tools.ietf.org/html/rfc6125#section-6.4.3 -- ___ Python tracker rep...@bugs.python.org

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-18 Thread Roundup Robot
Roundup Robot added the comment: New changeset b9b521efeba3 by Antoine Pitrou in branch '3.2': Issue #17980: Fix possible abuse of ssl.match_hostname() for denial of service using certificates with many wildcards (CVE-2013-2099). http://hg.python.org/cpython/rev/b9b521efeba3 New changeset

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ok, this should be fixed now. Thanks a lot for reporting! -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Bohuslav Slavek Kabrda
Changes by Bohuslav Slavek Kabrda bkab...@redhat.com: -- nosy: +bkabrda ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980 ___ ___

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread STINNER Victor
STINNER Victor added the comment: Are multiple wildcards per fragment even specified? I don't know the standard, but it sounds strange to have more than one wildcard per part of an URL. *.*.*.google.com looks valid to me, whereas *a*a*a*.google.com looks very suspicious. Said differently, I

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Florian Weimer
Florian Weimer added the comment: * pattern is replace with '[^.]+' regex, so I may not cause the exponential complexity issue. (I didn't check.) A possessive quantifier might also help, that is [^.]+?. -- ___ Python tracker

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: SSL certificate hostname matching is defined in RFC 2818: * http://www.ietf.org/rfc/rfc2818.txt It's not very verbose on how exactly matching should be done: Names may contain the wildcard character * which is considered to match any single domain

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Antoine Pitrou
Antoine Pitrou added the comment: Non-greedy matching actually makes things worse :-) $ ./python -m timeit -s import re; pat = re.compile('\A*a*a*a\Z'.replace('*', '[^.]+'), re.IGNORECASE) pat.match('a' * 100 +'z') 100 loops, best of 3: 3.31 msec per loop $ ./python -m timeit -s import re;

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Antoine Pitrou
Antoine Pitrou added the comment: Florian, I'm actually surprised by your assertion that OpenSSL supports a single wildcard character. Last I looked, I couldn't find any hostname matching function in OpenSSL (which is why I had to write our own). Could you point me to the relevant piece of

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Florian Weimer
Florian Weimer added the comment: Antoine, support for OpenSSL host name matching is quite new: http://www.openssl.org/docs/crypto/X509_check_host.html -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Antoine Pitrou
Antoine Pitrou added the comment: libcurl supports a single wildcard for the whole domain name pattern (not even one per fragment), as per lib/hostcheck.c (this is when linked against OpenSSL; when linked against GnuTLS, curl will use the GnuTLS-provided matching function) Based on all the

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Antoine Pitrou
Antoine Pitrou added the comment: Antoine, support for OpenSSL host name matching is quite new Ah, thanks. I was looking in 1.0.1e. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Here's another long discussions about SSL hostname matching that may provide some useful insights: * https://bugzilla.mozilla.org/show_bug.cgi?id=159483 Note how RFC 2595 doesn't even allow sub-string matching. It only allows '*' to be used as

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Antoine Pitrou
Antoine Pitrou added the comment: Attached patch forbidding more than one wildcard per fragment. -- stage: needs patch - patch review Added file: http://bugs.python.org/file30292/ssl_wildcard_dos2.patch ___ Python tracker rep...@bugs.python.org

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Christian Heimes
Christian Heimes added the comment: I still think that sub string wildcard should not match the IDN xn-- prefix. With current code the rules x*.example.de gives a positive match for götter.example.de. ugötter.example.de.encode(idna) 'xn--gtter-jua.example.de' --

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Antoine Pitrou
Antoine Pitrou added the comment: I still think that sub string wildcard should not match the IDN xn-- prefix. With current code the rules x*.example.de gives a positive match for götter.example.de. You should open a separate issue for this (possibly with a patch). --

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-17 Thread Christian Heimes
Christian Heimes added the comment: #17997 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980 ___ ___ Python-bugs-list mailing list

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Jan Lieskovsky
Jan Lieskovsky added the comment: The CVE identifier of CVE-2013-2099 has been assigned: http://www.openwall.com/lists/oss-security/2013/05/16/6 to this issue. -- nosy: +iankko title: ssl.match_hostname() trips over crafted wildcard names - CVE-2013-2099 ssl.match_hostname() trips

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- stage: - needs patch type: - security versions: +Python 3.2, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980 ___

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: This is caused by the regex engine's performance behaviour: http://bugs.python.org/issue1662581 http://bugs.python.org/issue1515829 http://bugs.python.org/issue212521 -- ___ Python tracker rep...@bugs.python.org

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: I would like to know what is the expected scenario: - does the attacker only control the certificate? - or does the attacker control both the certificate and the hostname being validated? The reason is that the matching cost for a domain name fragment seems to

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +christian.heimes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980 ___ ___ Python-bugs-list

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Christian Heimes
Christian Heimes added the comment: RFC 2818 doesn't say anything about the maximum amount of wildcards. I'm going to check OpenSSL's implementation now. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Florian Weimer
Florian Weimer added the comment: OpenSSL supports only a single wildcard character. In my tests, I used a host name like .example.org, and a dNSName like a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*.example.org. Quadratic behavior wouldn't be

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Apostolis Bessas
Changes by Apostolis Bessas mpes...@gmail.com: -- nosy: +mpessas ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980 ___ ___ Python-bugs-list

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: Indeed, two wildcards seem to be ok with a 255-character domain name: $ ./python -m timeit -s import ssl; cert = {'subject': ((('commonName', '*a*a.com'),),)} try: ssl.match_hostname(cert, 'a' * 250 +'z.com') except ssl.CertificateError: pass 1000 loops, best

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: In my tests, I used a host name like .example.org, and a dNSName like a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*.example.org. Quadratic behavior wouldn't be too bad because the host name is necessarily rather

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980 ___

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Florian Weimer
Florian Weimer added the comment: The host name is looked up to get the IP address to connect to. The lookup will fail if the host name is longer than 255 characters, and the crafted certificate is never retrieved. -- ___ Python tracker

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Christian Heimes
Christian Heimes added the comment: I think a malicious user could abuse SNI to craft a longer host name and trigger the pathological case. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: In GnuTLS, _gnutls_hostname_compare() (lib/gnutls_str.c) uses a trivial recursive approach with a maximum number of 5 wildcards. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Jeffrey C. Jacobs
Changes by Jeffrey C. Jacobs timeho...@users.sourceforge.net: -- nosy: +timehorse ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980 ___ ___

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Tim Peters
Tim Peters added the comment: Wildcard matching can easily be done in worst-case linear time, but not with regexps. doctest.py's internal _ellipsis_match() shows one way to do it (doctest can use ... as a wildcard marker). -- nosy: +tim_one ___

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Christian Heimes
Christian Heimes added the comment: We could use an algorithm that doesn't need regexp for most cases. pseudo code: value = value.lower() hostname = hostname.lower() if '*' not in value: return value == hostname vparts = valuesplit(.) hparts = hostname.split(.) if len(vparts) !=

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: Wildcard matching can easily be done in worst-case linear time, but not with regexps. doctest.py's internal _ellipsis_match() shows one way to do it (doctest can use ... as a wildcard marker). Thanks, this may be a nice enhancement for 3.4. For 3.2 and

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: Here is a patch allowing at most 2 wildcards per domain fragment. Georg, do you think this should go into 3.2? -- keywords: +patch nosy: +georg.brandl Added file: http://bugs.python.org/file30288/ssl_wildcard_dos.patch

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Georg Brandl
Georg Brandl added the comment: It's certainly a security fix, but probably not one that warrants an immediate release. If you commit it to the 3.2 branch, that's fine, it will get picked up by coming releases. -- ___ Python tracker

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980 ___ ___ Python-bugs-list

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Gregory P. Smith
Gregory P. Smith added the comment: Indeed, doing this _without a regexp_ is preferred. :) -- nosy: +gregory.p.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17980 ___

[issue17980] CVE-2013-2099 ssl.match_hostname() trips over crafted wildcard names

2013-05-16 Thread Christian Heimes
Christian Heimes added the comment: Are multiple wildcards per fragment even specified? I'm unable to find information if the wildcard is supposed to be a greedy or a non-greedy match. By the way Chromium does more fancy checks. For example it requires * to match at least on character and it