CVE-2024-30251: Denial of service when trying to parse malformed POST requests in aiohttp

Published May 2, 2024
·
Updated

Summary An attacker can send a specially crafted POST (multipart/form-data) request. When the aiohttp server processes it, the server will enter an infinite loop and be unable to process any further requests.

Impact An attacker can stop the application from serving requests after sending a single request.

-------

For anyone needing to patch older versions of aiohttp, the minimum diff needed to resolve the issue is (located in readchunkfromlength()):

diff diff --git a/aiohttp/multipart.py b/aiohttp/multipart.py index 227be605c..71fc2654a 100644 --- a/aiohttp/multipart.py +++ b/aiohttp/multipart.py @@ -338,6 +338,8 @@ class BodyPartReader: assert self.length is not None, "Content-Length required for chunked read" chunksize = min(size, self.length - self.readbytes) chunk = await self.content.read(chunksize) + if self.content.ateof(): + self.ateof = True return chunk async def readchunkfromstream(self, size: int) -> bytes:

This does however introduce some very minor issues with handling form data. So, if possible, it would be recommended to also backport the changes in: https://github.com/aio-libs/aiohttp/commit/cebe526b9c34dc3a3da9140409db63014bc4cf19 https://github.com/aio-libs/aiohttp/commit/7eecdff163ccf029fbb1ddc9de4169d4aaeb6597 https://github.com/aio-libs/aiohttp/commit/f21c6f2ca512a026ce7f0f6c6311f62d6a638866

Other sources

aiohttp is an asynchronous HTTP client/server framework for asyncio and Python. In affected versions an attacker can send a specially crafted POST (multipart/form-data) request. When the aiohttp server processes it, the server will enter an infinite loop and be unable to process any further requests. An attacker can stop the application from serving requests after sending a single request. This issue has been addressed in version 3.9.4. Users are advised to upgrade. Users unable to upgrade may manually apply a patch to their systems. Please see the linked GHSA for instructions.

NVD

Affected Software

3 affected componentsFixes available
pip/aiohttp<3.9.4
3.9.4
redhat/aiohttp<3.9.4
3.9.4
aiohttp aiohttp<3.9.4

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/aiohttp to a version that resolves this vulnerability.

    Fixed in 3.9.4
  2. Upgrade

    Upgrade redhat/aiohttp to a version that resolves this vulnerability.

    Fixed in 3.9.4
  3. Upgrade

    Upgrade aiohttp to a version that resolves this vulnerability.

    Fixed in 3.9.4Patch CVE-2024-30251
  4. Compensating control

    If upgrading is not possible, backport the minimum diff located in `_read_chunk_from_length()` in `aiohttp/multipart.py` to resolve CVE-2024-30251 (DoS via malformed `multipart/form-data`).

Event History

May 2, 2024
CVE Published
via MITRE·01:55 PM
Data Sourced
via MITRE·01:55 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·02:15 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·02:15 PM
RemedyAffected Software
Data Sourced
via Red Hat·08:02 PM
DescriptionSeverityAffected Software
May 3, 2024
Advisory Published
via GitHub·05:29 PM

Frequently Asked Questions

1

What is the severity of CVE-2024-30251?

CVE-2024-30251 is considered to be a critical vulnerability due to its potential to cause denial of service by entering an infinite loop.

2

How do I fix CVE-2024-30251?

To fix CVE-2024-30251, upgrade aiohttp to version 3.9.4 or later.

3

What type of attack does CVE-2024-30251 involve?

CVE-2024-30251 involves an attacker sending a specially crafted multipart/form-data POST request to the aiohttp server.

4

What impact does CVE-2024-30251 have on affected applications?

CVE-2024-30251 can cause an affected application to stop serving requests, leading to service disruption.

5

Which versions of aiohttp are affected by CVE-2024-30251?

CVE-2024-30251 affects aiohttp versions prior to 3.9.4.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203