CVE-2024-42367
Path traversal vulnerability in aiohttp for compressed file variants.
- CVSS 4.8
- CWE-61
- Input Validation and Sanitization
- Remote
aiohttp is an asynchronous HTTP client/server framework for asyncio and Python. Prior to version 3.10.2, static routes which contain files with compressed variants (`.gz` or `.br` extension) are vulnerable to path traversal outside the root directory if those variants are symbolic links. The server protects static routes from path traversal outside the root directory when `follow_symlinks=False` (default). It does this by resolving the requested URL to an absolute path and then checking that path relative to the root. However, these checks are not performed when looking for compressed variants in the `FileResponse` class, and symbolic links are then automatically followed when performing the `Path.stat()` and `Path.open()` to send the file. Version 3.10.2 contains a patch for the issue.
- CWE
- CWE-61
- CVSS base score
- 4.8
- Published
- 2024-08-09
- OWASP
- A01 Broken Access Control
- Orthogonal defect classification
- Checking
- Code defect classification
- Incorrect Check
- Category
- Input Validation and Sanitization
- Subcategory
- Path Traversal
- Accessibility scope
- Remote
- Impact
- Unauthorized Access
- Affected component
- aiohttp
- Fixed by upgrading
- Yes
Solution
Upgrade to aiohttp version 3.10.2 or later.
Vulnerable code sample
from aiohttp import web
async def handle(request):
return web.FileResponse(request.match_info['filename'])
app = web.Application()
app.router.add_get('/static/{filename:.*}', handle)
if __name__ == '__main__':
web.run_app(app, port=8080)Patched code sample
from aiohttp import web
import os
async def handle(request):
return web.FileResponse(request.match_info['filename'], follow_symlinks=False)
app = web.Application()
app.router.add_get('/static/{filename:.*}', handle)
if __name__ == '__main__':
web.run_app(app, port=8080)Payload
../../../../etc/passwd
Cite this entry
@misc{vaitp:cve202442367,
title = {{Path traversal vulnerability in aiohttp for compressed file variants.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-42367},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-42367/}}
}
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 ::
