File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed
Misc/NEWS.d/next/Security Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -101,14 +101,15 @@ def ToASCII(label):
101101 raise UnicodeError ("label empty or too long" )
102102
103103def ToUnicode (label ):
104- if len (label ) > 1000 :
104+ if len (label ) > 1024 :
105105 # Protection from https://github.com/python/cpython/issues/98433.
106106 # https://datatracker.ietf.org/doc/html/rfc5894#section-6
107107 # doesn't specify a label size limit prior to NAMEPREP. But having
108108 # one makes practical sense.
109109 # This leaves ample room for nameprep() to remove Nothing characters
110- # while still preventing us from wasting CPU decoding a big thing
111- # that'll just hit the actual <= 63 length limit in Step 6.
110+ # per https://www.rfc-editor.org/rfc/rfc3454#section-3.1 while still
111+ # preventing us from wasting time decoding a big thing that'll just
112+ # hit the actual <= 63 length limit in Step 6.
112113 raise UnicodeError ("label way too long" )
113114 # Step 1: Check for ASCII
114115 if isinstance (label , bytes ):
Original file line number Diff line number Diff line change @@ -1554,7 +1554,7 @@ def test_builtin_encode(self):
15541554
15551555 def test_builtin_decode_length_limit (self ):
15561556 with self .assertRaises (UnicodeError ) as ctx :
1557- (b"xn--016c" + b"a" * 1010 ).decode ("idna" )
1557+ (b"xn--016c" + b"a" * 1100 ).decode ("idna" )
15581558 self .assertIn ("way too long" , str (ctx .exception ))
15591559 with self .assertRaises (UnicodeError ) as ctx :
15601560 (b"xn--016c" + b"a" * 70 ).decode ("idna" )
Original file line number Diff line number Diff line change @@ -6,8 +6,9 @@ such as :mod:`urllib` http ``3xx`` redirects potentially allow for an attacker
66to supply such a name.
77
88Individual labels within an IDNA encoded DNS name will now raise an error early
9- during IDNA decoding if they are longer than 1000 encoded characters given that
10- each decoded DNS label must be 63 or fewer characters. Only an application
11- presenting a suspicious hostname value consisting primarily of "Nothing"
12- characters to be removed would run into of this new limit. See :rfc: `5894 `
13- section 6 and :rfc: `3491 `.
9+ during IDNA decoding if they are longer than 1024 unicode characters given that
10+ each decoded DNS label must be 63 or fewer characters and the entire decoded
11+ DNS name is limited to 255. Only an application presenting a hostname or label
12+ consisting primarily of :rfc: `3454 ` section 3.1 "Nothing" characters to be
13+ removed would run into of this new limit. See also :rfc: `5894 ` section 6 and
14+ :rfc: `3491 `.
You can’t perform that action at this time.
0 commit comments