# CVE-2022-31015: Uncaught Exception (due to a data race) leads to process termination in Waitress

> A race condition in Waitress allows a thread to close a socket during select, causing an unhandled exception and terminating the server process.

- **Severity:** Medium 6.5 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:N/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:** Not needed
- **Fix available:** Yes
- **Published:** 31 May 2022
- **Updated:** 22 Apr 2025
- **Also known as:** AZL-43513, AZL-44571, DEBIAN-CVE-2022-31015, GHSA-f5x9-8jwc-25rw, PYSEC-2022-205, openSUSE-SU-2024:12346-1

## What is CVE-2022-31015?

CVE-2022-31015 is a medium-severity vulnerability in Pylons waitress, published on 31 May 2022. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

Waitress is a Web Server Gateway Interface server for Python 2 and 3. Waitress versions 2.1.0 and 2.1.1 may terminate early due to a thread closing a socket while the main thread is about to call select(). This will lead to the main thread raising an exception that is not handled and then causing the entire application to be killed. This issue has been fixed in Waitress 2.1.2 by no longer allowing the WSGI thread to close the socket. Instead, that is always delegated to the main thread. There is no work-around for this issue. However, users using waitress behind a reverse proxy server are less likely to have issues if the reverse proxy always reads the full response.

Weakness: CWE-362 (Concurrent Execution using Shared Resource with Improper Synchronization), CWE-248 (Uncaught Exception)

## Which versions are affected by CVE-2022-31015?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `waitress` | PyPI | From 2.1.0 | 2.1.2 |
| `waitress` | PyPI | From 2.1.0 | 2.1.2 |
| `waitress` | PyPI | From 2.1.0 | 2.1.2 |

Products: Agendaless Waitress.

## How do I fix CVE-2022-31015?

Upgrade waitress to 2.1.2 or later.

## Is CVE-2022-31015 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-31015 exists.

## 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-2022-31015 and fix it if it is affected.

What it is: CVE-2022-31015 is a medium-severity vulnerability in Pylons waitress, published on 31 May 2022. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-31015 exists.

Affected packages and fixed versions:
- waitress (PyPI): affected from 2.1.0; fixed in 2.1.2
- waitress (PyPI): affected from 2.1.0; fixed in 2.1.2
- waitress (PyPI): affected from 2.1.0; fixed in 2.1.2

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-2022-31015/ (Markdown: https://insights.sbomify.com/CVE-2022-31015/index.md)
```

## Sources

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

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