Skip to content

Commit

Permalink
Merge pull request #2 from ActiveState/BE-2343-cve-2022-40897
Browse files Browse the repository at this point in the history
  • Loading branch information
icanhasmath committed May 3, 2023
2 parents c641cf3 + 629020f commit 2d1e5bd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
@@ -1,3 +1,8 @@
v44.1.1.1
-------

* #3659: Limit the amount of whitespace to search/backtrack (CVE-2022-40897)

v44.1.1
-------

Expand Down
6 changes: 4 additions & 2 deletions setuptools/package_index.py
Expand Up @@ -214,8 +214,10 @@ def wrapper(*args, **kwargs):
return wrapper


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


@unique_values
Expand Down
8 changes: 8 additions & 0 deletions setuptools/tests/test_packageindex.py
Expand Up @@ -337,3 +337,11 @@ def test_percent_in_password(self, tmpdir, monkeypatch):
cred = cfg.creds_by_repository['https://pypi.org']
assert cred.username == 'jaraco'
assert cred.password == 'pity%'


@pytest.mark.timeout(1)
def test_REL_DoS():
"""
REL should not hang on a contrived attack string.
"""
setuptools.package_index.REL.search('< rel=' + ' ' * 2**12)

0 comments on commit 2d1e5bd

Please sign in to comment.