You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Slow IDNA decoding with large strings [CVE-2022-45061] #98433
According to spec https://unicode.org/reports/tr46/ an IDNA label must not be longer than 63 characters. Python's idna module enforces the restriction, but too late.
This may be abused in some cases, for example by passing a crafted host name to asyncio create_connection:
If there are libraries that allow an attacker controlled hostname without a reasonable length check on it to get into a connect or similar call that tries idna decoding, that'd make this remotely exploitable. Based solely on code inspection, the urllib.request.HTTPRedirectHandler class is probably vulnerable to this - https://github.com/python/cpython/blob/main/Lib/urllib/request.py#L652 - the location or uri headers it consumes on a HTTP 302 redirect reponse to construct the new URL are not obviously limited, nor is the host that ultimately winds it way down into the socket module. (I didn't test this, I was just reading code) A test case would be to point urllib at a malicious server that sends a 2000 byte idna hostname in a 302 redirect header...
Activity
gpshead commentedon Nov 4, 2022
This is probably in
ToUnicodeandToASCIIof https://github.com/python/cpython/blob/main/Lib/encodings/idna.py and/or in https://github.com/python/cpython/blob/main/Lib/encodings/punycode.py itself, where we could presumably just do an up front length check and reject inputs that are obviously too long to possibly decode into a label length that DNS standards will accept.If there are libraries that allow an attacker controlled hostname without a reasonable length check on it to get into a connect or similar call that tries idna decoding, that'd make this remotely exploitable. Based solely on code inspection, the
urllib.request.HTTPRedirectHandlerclass is probably vulnerable to this - https://github.com/python/cpython/blob/main/Lib/urllib/request.py#L652 - the location or uri headers it consumes on a HTTP 302 redirect reponse to construct the new URL are not obviously limited, nor is the host that ultimately winds it way down into the socket module. (I didn't test this, I was just reading code) A test case would be to point urllib at a malicious server that sends a 2000 byte idna hostname in a 302 redirect header...vstinner commentedon Nov 4, 2022
The issue #99083 was marked as a duplicate of this issue.
pythongh-98433: Fix quadratic time idna decoding.
gh-98433: Fix quadratic time idna decoding. (#99092)
pythongh-98433: Fix quadratic time idna decoding. (pythonGH-99092)
[3.11] gh-98433: Fix quadratic time idna decoding. (GH-99092) (#99222)
[3.11] pythongh-98433: Fix quadratic time idna decoding. (pythonGH-99092
[3.11] pythongh-98433: Fix quadratic time idna decoding. (pythonGH-99092
15 remaining items
00394-cve-2022-45061-cpu-denial-of-service-via-inefficient-idna-decod…
00394-cve-2022-45061-cpu-denial-of-service-via-inefficient-idna-decod…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…
00394: CVE-2022-45061: CPU denial of service via inefficient IDNA dec…