# CVE-2020-5236: Catastrophic backtracking in regex allows Denial of Service in Waitress

> An attacker can cause a denial of service in Waitress by sending a request with an invalid header, triggering catastrophic regex backtracking and consuming all CPU resources.

- **Severity:** Medium 5.7 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 4 Feb 2020
- **Updated:** 4 Aug 2024
- **Also known as:** GHSA-73m2-3pwg-5fgc, PYSEC-2020-155

## What is CVE-2020-5236?

CVE-2020-5236 is a medium-severity denial of service vulnerability in Pylons Waitress, published on 4 Feb 2020. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

Waitress version 1.4.2 allows a DOS attack When waitress receives a header that contains invalid characters. When a header like "Bad-header: xxxxxxxxxxxxxxx\x10" is received, it will cause the regular expression engine to catastrophically backtrack causing the process to use 100% CPU time and blocking any other interactions. This allows an attacker to send a single request with an invalid header and take the service offline. This issue was introduced in version 1.4.2 when the regular expression was updated to attempt to match the behaviour required by errata associated with RFC7230. The regular expression that is used to validate incoming headers has been updated in version 1.4.3, it is recommended that people upgrade to the new version of Waitress as soon as possible.

Weakness: CWE-400 (Uncontrolled Resource Consumption)

## Which versions are affected by CVE-2020-5236?

3 open source packages ship an affected version, including waitress. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `waitress` | PyPI | All versions | 1.4.3 |
| `waitress` | PyPI | From 1.4.2 | 1.4.3 |
| `waitress` | PyPI | From 1.4.2 | 1.4.3 |

Products: Agendaless Waitress.

## How do I fix CVE-2020-5236?

Upgrade waitress to 1.4.3 or later.

## Is CVE-2020-5236 being exploited?

There is no known exploitation of CVE-2020-5236 in the wild and no public exploit code.

Public exploit code:

- Waitress 1.4.2 ReDoS - CVE-2020-5236 (Blog Sample Code) (github_poc): https://github.com/motikan2010/CVE-2020-5236

## Other vulnerabilities in Pylons Waitress

- [CVE-2024-49768](https://insights.sbomify.com/CVE-2024-49768/): Waitress has request processing race condition in HTTP pipelining with invalid first request (critical 9.1)
- [CVE-2024-49769](https://insights.sbomify.com/CVE-2024-49769/): Waitress has a denial of service leading to high CPU usage/resource exhaustion (high 7.5)
- [CVE-2022-24761](https://insights.sbomify.com/CVE-2022-24761/): HTTP Request Smuggling in waitress (high 7.5)
- [CVE-2019-16792](https://insights.sbomify.com/CVE-2019-16792/): HTTP Request Smuggling: Content-Length Sent Twice in Waitress (high 7.1)
- [CVE-2019-16789](https://insights.sbomify.com/CVE-2019-16789/): HTTP Request Smuggling in Waitress: Invalid whitespace characters in headers (high 7.1)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2020-5236 and fix it if it is affected.

What it is: CVE-2020-5236 is a medium-severity denial of service vulnerability in Pylons Waitress, published on 4 Feb 2020. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2020-5236 in the wild and no public exploit code.

Affected packages and fixed versions:
- waitress (PyPI): affected all versions; fixed in 1.4.3
- waitress (PyPI): affected from 1.4.2; fixed in 1.4.3
- waitress (PyPI): affected from 1.4.2; fixed in 1.4.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2020-5236/ (Markdown: https://insights.sbomify.com/CVE-2020-5236/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2020-5236
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2020-5236
- OSV: https://osv.dev/vulnerability/CVE-2020-5236

---
From sbomify Insights: https://insights.sbomify.com/CVE-2020-5236/
Summaries are generated and may contain mistakes; the official description above is the record.
