CVE-2024-30251
aiohttp vulnerable to infinite loop from crafted POST requests. Upgrade advised.
- CVSS 7.5
- CWE-835
- Resource Management
- Remote
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.
- CWE
- CWE-835
- CVSS base score
- 7.5
- Published
- 2024-05-02
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- aiohttp
- Fixed by upgrading
- Yes
Solution
Upgrade to aiohttp version 3.9.4 or later.
Vulnerable code sample
from aiohttp import web
async def handle(request):
# VULNERABLE: This code is susceptible to xss
data = await request.post()
while True:
pass
app = web.Application()
app.router.add_post('/', handle)
if __name__ == '__main__':
web.run_app(app, port=8080)Patched code sample
from aiohttp import web
async def handle(request):
# SECURE: This version prevents xss
data = await request.post()
return web.Response(text="Data received")
app = web.Application()
app.router.add_post('/', handle)
if __name__ == '__main__':
web.run_app(app, port=8080)Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- [PR #8332/482e6cdf backport][3.9] Add set_content_disposition test (#8333) (aio-libs/aiohttp)
aiohttp/multipart.py · MultipartWriter.append_payload,aiohttp/multipart.py · MultipartWriter.write - Fix handling of multipart/form-data (#8280) (#8302) (aio-libs/aiohttp)
aiohttp/formdata.py,aiohttp/formdata.py · FormData.add_field,aiohttp/multipart.py,aiohttp/multipart.py · BodyPartReader.decode,aiohttp/multipart.py · BodyPartReader.get_charset,aiohttp/multipart.py · BodyPartReader._read_chunk_from_length,aiohttp/multipart.py · BodyPartReader.__init__,aiohttp/multipart.py · MultipartReader.next,aiohttp/multipart.py · MultipartReader._get_boundary,aiohttp/multipart.py · MultipartReader._get_part_reader,aiohttp/multipart.py · MultipartReader.__init__,aiohttp/multipart.py · MultipartWriter.append_payloadand 1 more - [PR #8335/5a6949da backport][3.9] Add Content-Disposition automatically (#8336) (aio-libs/aiohttp)
aiohttp/multipart.py · MultipartWriter.append_payload
Payload
POST / HTTP/1.1
Host: vulnerable-server.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="exploit"
Content-Type: application/octet-stream
<large amount of data to trigger the infinite loop>
------WebKitFormBoundary7MA4YWxkTrZu0gW--
Cite this entry
@misc{vaitp:cve202430251,
title = {{aiohttp vulnerable to infinite loop from crafted POST requests. Upgrade advised.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-30251},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-30251/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
