CVE-2024-52303: Aiohttp Remote Code Execution Vulnerability

MODERATE
Advisory Identifier: GHSA-27mf-ghqm-j3j8
CVSS 7.5
CWE-772
Published
Advisory Summary

CVE-2024-52303 is a MODERATE (CVSS 7.5) remote code execution vulnerability (CWE-772: Missing Release of Resource after Effective Lifetime) affecting Aiohttp libraries in the PyPI ecosystem. The issue involves aiohttp has a memory leak when middleware is enabled when requesting a resource with a non-allowed method. Remediation is available by upgrading affected packages to version 3.10.11.

CVE-2024-52303 at a Glance

CVE Identifier CVE-2024-52303
GHSA Identifier GHSA-27mf-ghqm-j3j8
Severity MODERATE
CVSS v3.1 Base Score 7.5
CWE Classification CWE-772: Missing Release of Resource after Effective Lifetime
Affected Product Aiohttp
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2024-52303

To remediate this vulnerability, upgrade all affected Aiohttp dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

aiohttp fixed: 3.10.11
pip install aiohttp>=3.10.11
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show aiohttp

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-52303, inspect your installed packages using pip:

pip show aiohttp

Analyze the terminal output to locate any version of Aiohttp in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.10.11), your application is affected.

Note: The pip show aiohttp command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-772: Missing Release of Resource after Effective Lifetime, where the product does not release a resource after its effective lifetime has ended, i.e., after the resource is no longer needed. In Aiohttp, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary A memory leak can occur when a request produces a `MatchInfoError`. This was caused by adding an entry to a cache on each request, due to the building of each `MatchInfoError` producing a unique cache entry. ### Impact If the user is making use of any middlewares with `aiohttp.web` then it is advisable to upgrade immediately. An attacker may be able to exhaust the memory resources of a server by sending a substantial number (100,000s to millions) of such requests. ----- Patch: https://github.com/aio-libs/aiohttp/commit/bc15db61615079d1b6327ba42c682f758fa96936

CVE-2024-52303 Affected Aiohttp Versions

1 component(s)
Fixed Versions:
3.10.11
Product / Package Ecosystem Affected Versions Fixed Version
aiohttp
PyPI
≥ 3.10.6
< 3.10.11
3.10.11

References

Frequently Asked Questions

What is CVE-2024-52303?
CVE-2024-52303 is a security vulnerability in Aiohttp involving aiohttp has a memory leak when middleware is enabled when requesting a resource with a non-allowed method under CWE-772: Missing Release of Resource after Effective Lifetime.
Which Aiohttp versions are affected?
Affected versions include releases prior to 3.10.11 across affected packages: aiohttp.
What version fixes CVE-2024-52303?
Upgrading to 3.10.11 (or the latest patched release for your respective branch) resolves the vulnerability.
Is aiohttp affected?
Yes, aiohttp is affected in releases prior to 3.10.11. Upgrade your dependency to 3.10.11 or later.
What is the CVSS score of CVE-2024-52303?
CVE-2024-52303 has a CVSS v3.1 base score of 7.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2024-52303?
CVE-2024-52303 is classified under CWE-772: Missing Release of Resource after Effective Lifetime (The product does not release a resource after its effective lifetime has ended, i.e., after the resource is no longer needed.).
How can I check PyPI dependencies for CVE-2024-52303?
Run the dependency tree command: 'pip show aiohttp'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-27mf-ghqm-j3j8",
  "modified" : "2024-11-19T20:48:51Z",
  "published" : "2024-11-18T21:02:17Z",
  "aliases" : [ "CVE-2024-52303" ],
  "summary" : "aiohttp has a memory leak when middleware is enabled when requesting a resource with a non-allowed method",
  "details" : "### Summary\n\nA memory leak can occur when a request produces a `MatchInfoError`. This was caused by adding an entry to a cache on each request, due to the building of each `MatchInfoError` producing a unique cache entry.\n\n### Impact\n\nIf the user is making use of any middlewares with `aiohttp.web` then it is advisable to upgrade immediately.\n\nAn attacker may be able to exhaust the memory resources of a server by sending a substantial number (100,000s to millions) of such requests.\n\n-----\n\nPatch: https://github.com/aio-libs/aiohttp/commit/bc15db61615079d1b6327ba42c682f758fa96936",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "aiohttp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.10.6"
      }, {
        "fixed" : "3.10.11"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/aio-libs/aiohttp/security/advisories/GHSA-27mf-ghqm-j3j8"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-52303"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/aio-libs/aiohttp/commit/bc15db61615079d1b6327ba42c682f758fa96936"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/aio-libs/aiohttp"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-772" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-11-18T21:02:17Z",
    "nvd_published_at" : "2024-11-18T20:15:06Z"
  }
}