Skip to main content
Vulnerability Database/CVE-2026-104874

CVE-2026-104874: Multidict Memory Leak DOS Vulnerability

CVE-2026-104874 is a memory leak denial of service flaw in Multidict C extension that causes unbounded process memory growth through reference leaks. This post explains its impact, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-104874 Overview

CVE-2026-104874 is a memory leak vulnerability in the multidict Python library, a widely used implementation of the multidict data structure. The flaw affects versions 6.7.0 through 6.9.0 of the C extension. Two specific items-view operations fail to release references returned from operand elements, allowing unbounded memory growth. Applications performing these set-like operations on attacker-influenced sequences can be driven into denial-of-service conditions. The issue is tracked as CWE-401: Missing Release of Memory after Effective Lifetime and is resolved in version 6.9.1.

Critical Impact

Repeated invocation of the affected items-view operators against attacker-controlled data causes unbounded process memory growth, leading to denial of service.

Affected Products

  • multidict library versions 6.7.0 through 6.9.0 (C extension builds)
  • Python applications that import multidict with the compiled C extension enabled
  • Downstream frameworks that expose MultiDict.items() to untrusted input (for example, aiohttp-based services)

Discovery Timeline

  • 2026-10-02 - CVE-2026-104874 published to NVD
  • 2026-10-06 - Last updated in NVD database

Technical Details for CVE-2026-104874

Vulnerability Analysis

The vulnerability resides in the C extension of multidict, specifically in two items-view operator implementations. The function multidict_itemsview_or2_impl handles the reflected union operator operand | d.items(). The function multidict_itemsview_sub1_impl handles the subtraction operator d.items() - operand. Both routines iterate over operand elements and request new key-identity and value references for each item. Neither path decrements those references after use. Each element processed therefore leaks two strong references that the Python garbage collector cannot reclaim.

Forward union, intersection, non-tuple operand elements, and pure-Python builds are not affected. The leak only manifests in C-extension builds when tuple operand elements are supplied to the two affected operators.

Root Cause

The root cause is a missing release of allocated resources along a success path in the C implementation ([CWE-401]). The affected functions obtain identity and valuePyObject pointers via functions that return new references, but omit the corresponding Py_CLEAR or Py_DECREF calls before continuing the loop. Reference counts for leaked objects never reach zero, preventing deallocation.

Attack Vector

An attacker who can influence the sequence passed as the operand to operand | md.items() or md.items() - operand can trigger the leak. The attack requires no authentication or user interaction when the vulnerable operation is exposed to network input. Repeated requests that carry large or numerous operand elements progressively exhaust process memory, eventually causing the application to be terminated by the OS or orchestrator.

text
# Patch note from CHANGES/b9b1e1f.bugfix.rst
Fixed a reference leak in the C extension where ``operand | md.items()``
and ``md.items() - operand`` leaked one key and one value reference per
element of ``operand``, letting a large operand grow memory without bound
(GHSA-54p9-h82j-f925) -- by asvetlov.

The issue was reported by waydeshi.

Source: GitHub commit 350b4a07

Detection Methods for CVE-2026-104874

Indicators of Compromise

  • Steady, monotonic increase in resident set size (RSS) of Python processes that use multidict without a corresponding workload increase
  • Repeated OOM-kills or container restarts of services such as aiohttp servers under modest request volume
  • High-frequency inbound requests that submit large tuple-based collections processed against header or query multidicts

Detection Strategies

  • Inventory Python environments and identify installations where multidict is between 6.7.0 and 6.9.0 using pip show multidict or SBOM tooling
  • Enable tracemalloc or objgraph sampling in staging to detect unbounded growth of str and tuple objects originating from items-view operators
  • Add runtime memory-ceiling alerts on Python application pods and correlate with request patterns that exercise MultiDict.items()

Monitoring Recommendations

  • Alert on sustained RSS growth exceeding baseline for services exposing header or query parsing endpoints
  • Capture process-level metrics (RSS, GC generations, object counts) in your observability stack and retain them long enough to spot slow leaks
  • Monitor dependency manifests in CI to flag any build pinning multidict<6.9.1

How to Mitigate CVE-2026-104874

Immediate Actions Required

  • Upgrade multidict to version 6.9.1 or later across all Python environments and container images
  • Rebuild and redeploy downstream services (notably aiohttp-based applications) to pick up the fixed dependency
  • Restart long-running Python processes already exhibiting elevated memory consumption to reclaim leaked allocations

Patch Information

The fix is published in multidict v6.9.1 and detailed in GitHub Security Advisory GHSA-54p9-h82j-f925. The code change adds the missing Py_CLEAR calls for the identity and value references within the affected loop in multidict/_multilib/views.h:

c
            }
        }
        Py_CLEAR(arg);
        Py_CLEAR(identity);
        Py_CLEAR(value);
    }
    if (st < 0) {
        goto fail;

Source: GitHub commit 350b4a07

Workarounds

  • Force the pure-Python implementation by setting the environment variable MULTIDICT_NO_EXTENSIONS=1 before application startup, since pure-Python builds are not affected
  • Avoid invoking operand | md.items() and md.items() - operand on untrusted or large operand sequences until the patch is applied
  • Place memory limits on worker processes (for example, via cgroups or ulimit -v) so leaking workers are recycled before exhausting host memory
bash
# Upgrade multidict to the patched release
pip install --upgrade 'multidict>=6.9.1'

# Verify the installed version
python -c "import multidict; print(multidict.__version__)"

# Temporary workaround: disable the C extension
export MULTIDICT_NO_EXTENSIONS=1

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.