Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') Affecting aiohttp package, versions [1.0.5,3.9.2)


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
8.79% (95th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-AIOHTTP-6209406
  • published30 Jan 2024
  • disclosed29 Jan 2024
  • creditlcttty, solarpeng502

Introduced: 29 Jan 2024

CVE-2024-23334  (opens in a new tab)
CWE-22  (opens in a new tab)
First added by Snyk

How to fix?

Upgrade aiohttp to version 3.9.2 or higher.

Overview

Affected versions of this package are vulnerable to Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') via the configuration of static routes when the follow_symlinks option is set to True. An attacker can read arbitrary files on the system by exploiting the lack of validation for file paths to ensure they are within the specified root directory for static files.

Notes:

This vulnerability has been present since the introduction of the follow_symlinks parameter.

An application is only vulnerable with setup code like:

app.router.add_routes([
    web.static("/static", "static/", follow_symlinks=True),  # Remove follow_symlinks to avoid the vulnerability
])

Workaround

This vulnerability can be mitigated by disabling the follow_symlinks option if it is set to True, especially in environments beyond restricted local development. Additionally, using a reverse proxy server to handle static resources is recommended over serving static resources directly with aiohttp in production environments.

CVSS Scores

version 3.1