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):
101
101
raise UnicodeError ("label empty or too long" )
102
102
103
103
def ToUnicode (label ):
104
- if len (label ) > 1000 :
104
+ if len (label ) > 1024 :
105
105
# Protection from https://github.com/python/cpython/issues/98433.
106
106
# https://datatracker.ietf.org/doc/html/rfc5894#section-6
107
107
# doesn't specify a label size limit prior to NAMEPREP. But having
108
108
# one makes practical sense.
109
109
# 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.
112
113
raise UnicodeError ("label way too long" )
113
114
# Step 1: Check for ASCII
114
115
if isinstance (label , bytes ):
Original file line number Diff line number Diff line change @@ -1554,7 +1554,7 @@ def test_builtin_encode(self):
1554
1554
1555
1555
def test_builtin_decode_length_limit (self ):
1556
1556
with self .assertRaises (UnicodeError ) as ctx :
1557
- (b"xn--016c" + b"a" * 1010 ).decode ("idna" )
1557
+ (b"xn--016c" + b"a" * 1100 ).decode ("idna" )
1558
1558
self .assertIn ("way too long" , str (ctx .exception ))
1559
1559
with self .assertRaises (UnicodeError ) as ctx :
1560
1560
(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
6
6
to supply such a name.
7
7
8
8
Individual 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