Skip to content

Commit 2d1e5bd

Browse files
authoredMay 3, 2023
Merge pull request #2 from ActiveState/BE-2343-cve-2022-40897
BE-2343-cve-2022-40897
2 parents c641cf3 + 629020f commit 2d1e5bd

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed
 

‎CHANGES.rst

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v44.1.1.1
2+
-------
3+
4+
* #3659: Limit the amount of whitespace to search/backtrack (CVE-2022-40897)
5+
16
v44.1.1
27
-------
38

‎setuptools/package_index.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,10 @@ def wrapper(*args, **kwargs):
214214
return wrapper
215215

216216

217-
REL = re.compile(r"""<([^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*)>""", re.I)
218-
# this line is here to fix emacs' cruddy broken syntax highlighting
217+
REL = re.compile(r"""<([^>]*\srel\s{0,10}=\s{0,10}['"]?([^'" >]+)[^>]*)>""", re.I)
218+
"""
219+
Regex for an HTML tag with 'rel="val"' attributes.
220+
"""
219221

220222

221223
@unique_values

‎setuptools/tests/test_packageindex.py

+8
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,11 @@ def test_percent_in_password(self, tmpdir, monkeypatch):
337337
cred = cfg.creds_by_repository['https://pypi.org']
338338
assert cred.username == 'jaraco'
339339
assert cred.password == 'pity%'
340+
341+
342+
@pytest.mark.timeout(1)
343+
def test_REL_DoS():
344+
"""
345+
REL should not hang on a contrived attack string.
346+
"""
347+
setuptools.package_index.REL.search('< rel=' + ' ' * 2**12)

0 commit comments

Comments
 (0)
Please sign in to comment.