# CVE-2022-40897: pypa/setuptools vulnerable to Regular Expression Denial of Service (ReDoS)

Source: https://junglewise.ai/threats/cve-2022-40897-pypa-setuptools-vulnerable-to-regular-expression-denial-of  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2022-12-23  
License: CC BY 4.0 with a link back

CVE-2022-40897 · Severity: low · CVSS 3.1 · Published 2022-12-23

Python Packaging Authority (PyPA) setuptools before 65.5.1 allows remote attackers to cause a denial of service via HTML in a crafted package or custom PackageIndex page. There is a Regular Expression Denial of Service (ReDoS) in package_index.py.

Technologies: [setuptools (PyPI)](https://junglewise.ai/threats/technologies/pypi-setuptools). Vendors: [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is CVE-2022-40897 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2022-40897 being exploited in the wild.

**How severe is CVE-2022-40897?** Low severity, with a CVSS score of 3.1, published 23 December 2022.

**Which products and versions are affected?** setuptools (PyPI) ECOSYSTEM:introduced=0,fixed=65.5.1, GIT:introduced=0,fixed=43a9c9bfa6aa626ec2a22540bea28d2ca77964be|ECOSYSTEM:introduced=0,fixed=65.5.1.

**Is there a fix for CVE-2022-40897?** Yes. setuptools (PyPI): upgrade to 65.5.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**Am I affected by CVE-2022-40897?** Check whether you run setuptools (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- setuptools (PyPI): upgrade to 65.5.1 or later

  ```sh
  pip install "setuptools>=65.5.1"
  ```


## Affected products

- setuptools (PyPI) ECOSYSTEM:introduced=0,fixed=65.5.1, GIT:introduced=0,fixed=43a9c9bfa6aa626ec2a22540bea28d2ca77964be|ECOSYSTEM:introduced=0,fixed=65.5.1

## Identifiers

- CVE-2022-40897
- GHSA-r9hx-vwmv-q579
- PYSEC-2022-43012

## Related threats

- [setuptools path escape via namespace_packages.txt on Windows](https://junglewise.ai/threats/setuptools-windows-path-escape-via-namespace-packages-txt-during-legacy-93ae767b)
- [pypa setuptools Unicode normalization bypass in MANIFEST.in exclusions](https://junglewise.ai/threats/cve-2026-59890-pypa-setuptools-unicode-normalization-bypass-in-manifest-in)
- [PYSEC-2026-1918 - setuptools vulnerable to Command Injection via package URL](https://junglewise.ai/threats/cve-2024-6345-setuptools-vulnerable-to-command-injection-via-package-url)
- [setuptools has a path traversal vulnerability in PackageIndex.download that leads to Arbitrary File Write](https://junglewise.ai/threats/cve-2025-47273-setuptools-has-a-path-traversal-vulnerability-in-packageindex)
- [Setuptools man-in-the-middle attack in package installation](https://junglewise.ai/threats/cve-2013-1633-setuptools-man-in-the-middle-attack-in-package-installation)
