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


0.0
medium

Snyk CVSS

    Attack Complexity High
    Confidentiality High

    Threat Intelligence

    Exploit Maturity Proof of concept
    EPSS 5.17% (93rd percentile)
Expand this section
NVD
7.5 high
Expand this section
Red Hat
5.9 medium
Expand this section
SUSE
7.5 high

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 ID SNYK-PYTHON-AIOHTTP-6209406
  • published 30 Jan 2024
  • disclosed 29 Jan 2024
  • credit lcttty, solarpeng502

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.