CVE-2026-44660: Ujson UltraJSON Has A Memory Leak Vulnerability

HIGH
Advisory Identifier: GHSA-c38f-wx89-p2xg
CVSS 7.5
CWE-401
Published
Advisory Summary

CVE-2026-44660 is a HIGH (CVSS 7.5) ultrajson has a memory leak vulnerability (CWE-401: Missing Release of Memory after Effective Lifetime) affecting Ujson libraries in the PyPI ecosystem. The issue involves ultrajson has a memory leak in ujson.dump() on write failure. Remediation is available by upgrading affected packages to version 5.12.1.

CVE-2026-44660 at a Glance

CVE Identifier CVE-2026-44660
GHSA Identifier GHSA-c38f-wx89-p2xg
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-401: Missing Release of Memory after Effective Lifetime
Affected Product Ujson
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-2026-44660

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

ujson fixed: 5.12.1
pip install ujson>=5.12.1
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 ujson

How to Check if You Are Affected

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

pip show ujson

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-401: Missing Release of Memory after Effective Lifetime, where the product does not sufficiently track and release allocated memory after it has been used, making the memory unavailable for reallocation and reuse. In Ujson, 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 When `ujson.dump()` writes to a file-like object and the write operation raises an exception, the serialized JSON string object is not decremented, leaking memory. Each failed write operation leaks the full size of the serialized payload. Code that uses `ujson.dumps()` rather than `ujson.dump()` or only JSON load/decode methods is unaffected. ### Details **Vulnerability Location:** - `src/ujson/python/objToJSON.c:913` - `objToJSONFile()` function start - `src/ujson/python/objToJSON.c:931` - Error return on write failure - `src/ujson/python/objToJSON.c:942` - Early return without cleanup **Root Cause:** The `objToJSONFile()` function allocates a Python string object via `ujson_dumps_internal()`, calls the file's `write()` method, and returns early if `write()` raises an exception—but never calls `Py_DECREF(string)` on the early exit path. ### PoC ```python import gc, tracemalloc, ujson class BadFile: def write(self, s): raise RuntimeError("boom") obj = {"x": "A" * 200000} def run(): try: ujson.dump(obj, BadFile()) except RuntimeError: pass run() tracemalloc.start() gc.collect() base = tracemalloc.get_traced_memory()[0] for i in range(5): run() gc.collect() cur = tracemalloc.get_traced_memory()[0] print(i, cur - base) ``` ### Impact Any application that serializes data through `ujson.dump()` to an attacker-influenced file-like object that can fail can be driven into linear memory growth. An attacker can quickly use up all the memory of say a web server that sends JSON responses using `ujson.dump()` by repeatedly making requests then closing the connection mid response. ### Remediation The missing dec-refs were added in 82af1d0ac01d09aa40c887b460d44b9d9f4bccd9. We recommend upgrading to [UltraJSON 5.12.1](https://github.com/ultrajson/ultrajson/releases/tag/5.12.1). ### Workarounds Replacing `ujson.dump(obj, file)` with `file.write(ujson.dumps(obj))` is equivalent (contrary to popular misconception, there are no streaming benefits to using `ujson.dump()`) and will avoid the memory leak.

CVE-2026-44660 Affected Ujson Versions

1 component(s)
Fixed Versions:
5.12.1
Product / Package Ecosystem Affected Versions Fixed Version
ujson
PyPI
< 5.12.1
5.12.1

References

Frequently Asked Questions

What is CVE-2026-44660?
CVE-2026-44660 is a security vulnerability in Ujson involving UltraJSON has a Memory Leak in ujson.dump() on Write Failure under CWE-401: Missing Release of Memory after Effective Lifetime.
Which Ujson versions are affected?
Affected versions include releases prior to 5.12.1 across affected packages: ujson.
What version fixes CVE-2026-44660?
Upgrading to 5.12.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is ujson affected?
Yes, ujson is affected in releases prior to 5.12.1. Upgrade your dependency to 5.12.1 or later.
What is the CVSS score of CVE-2026-44660?
CVE-2026-44660 has a CVSS v3.1 base score of 7.5 (HIGH) 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-2026-44660?
CVE-2026-44660 is classified under CWE-401: Missing Release of Memory after Effective Lifetime (The product does not sufficiently track and release allocated memory after it has been used, making the memory unavailable for reallocation and reuse.).
How can I check PyPI dependencies for CVE-2026-44660?
Run the dependency tree command: 'pip show ujson'. 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-c38f-wx89-p2xg",
  "modified" : "2026-06-08T23:53:55Z",
  "published" : "2026-05-12T22:25:11Z",
  "aliases" : [ "CVE-2026-44660" ],
  "summary" : "UltraJSON has a Memory Leak in ujson.dump() on Write Failure",
  "details" : "### Summary\n\nWhen `ujson.dump()` writes to a file-like object and the write operation raises an exception, the serialized JSON string object is not decremented, leaking memory. Each failed write operation leaks the full size of the serialized payload.\n\nCode that uses `ujson.dumps()` rather than `ujson.dump()` or only JSON load/decode methods is unaffected.\n\n### Details\n\n**Vulnerability Location:**\n- `src/ujson/python/objToJSON.c:913` - `objToJSONFile()` function start\n- `src/ujson/python/objToJSON.c:931` - Error return on write failure\n- `src/ujson/python/objToJSON.c:942` - Early return without cleanup\n \n**Root Cause:**\n\nThe `objToJSONFile()` function allocates a Python string object via `ujson_dumps_internal()`, calls the file's `write()` method, and returns early if `write()` raises an exception—but never calls `Py_DECREF(string)` on the early exit path.\n\n### PoC\n```python\nimport gc, tracemalloc, ujson\n\nclass BadFile:\n    def write(self, s):\n        raise RuntimeError(\"boom\")\n\nobj = {\"x\": \"A\" * 200000}\n\ndef run():\n    try:\n        ujson.dump(obj, BadFile())\n    except RuntimeError:\n        pass\n\nrun()\ntracemalloc.start()\ngc.collect()\nbase = tracemalloc.get_traced_memory()[0]\n\nfor i in range(5):\n    run()\n    gc.collect()\n    cur = tracemalloc.get_traced_memory()[0]\n    print(i, cur - base)\n```\n\n### Impact\n\nAny application that serializes data through `ujson.dump()` to an attacker-influenced file-like object that can fail can be driven into linear memory growth. An attacker can quickly use up all the memory of say a web server that sends JSON responses using `ujson.dump()` by repeatedly making requests then closing the connection mid response.\n\n### Remediation\n\nThe missing dec-refs were added in 82af1d0ac01d09aa40c887b460d44b9d9f4bccd9. We recommend upgrading to [UltraJSON 5.12.1](https://github.com/ultrajson/ultrajson/releases/tag/5.12.1).\n\n### Workarounds\n\nReplacing `ujson.dump(obj, file)` with `file.write(ujson.dumps(obj))` is equivalent (contrary to popular misconception, there are no streaming benefits to using `ujson.dump()`) and will avoid the memory leak.",
  "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:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "ujson"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.12.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.12.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ultrajson/ultrajson/security/advisories/GHSA-c38f-wx89-p2xg"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-44660"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ultrajson/ultrajson/commit/82af1d0ac01d09aa40c887b460d44b9d9f4bccd9"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ultrajson/ultrajson"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ultrajson/ultrajson/releases/tag/5.12.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-401" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-05-12T22:25:11Z",
    "nvd_published_at" : "2026-05-27T21:16:17Z"
  }
}