GHSA-J586-36CW-2GC2

Vulnerability from github – Published: 2026-10-27 15:04 – Updated: 2026-10-27 15:04
VLAI
Summary
MessagePack: Unbounded memory leak in msgpack C extension on strict_map_key validation failure
Details

Impact

The msgpack-python C extension (msgpack._cmsgpack) leaks a decoded map value when deserialization rejects a key with strict_map_key=True (the default). Repeated malformed inputs can cause unbounded process memory growth and denial of service in applications that deserialize attacker-controlled MessagePack data. Both unpackb() and the streaming Unpacker API are affected. The pure-Python fallback does not exhibit this leak in the reported tests.

The report measured approximately 4 MiB retained per failed parse and 100 MiB after 25 failed parses on Windows with Python 3.14 and msgpack 1.2.2. These are reporter-provided results.

Additional impact: stale parser-stack references

The reference-ownership audit performed while fixing this leak found an additional memory-safety issue in the streaming Unpacker.

After unpack() completed a nested container, an inactive parser-stack slot could retain a non-owning pointer to the decoded object. A subsequent skip() could reactivate that slot. If parsing then failed, context cleanup treated the stale pointer as an owned reference and decremented it.

This corrupts the object's reference count and can result in a use-after-free or double Py_DECREF when its actual owners later release it.

Although few users use this API, but those who do may experience crashes or unexpected errors due to a use-after-free.

Details

In msgpack/unpack.h, unpack_callback_map_item() rejects keys that are neither str nor bytes. At this point the map value has already been constructed. The early error return does not release the value reference.

In msgpack/unpack_template.h, the value is held in the local obj in unpack_execute(). The CT_MAP_VALUE error path jumps to _failed without decrementing that reference. Cleanup of the parser stack does not recover the value because it is not stored in the stack. The fallback checks the key before decoding the value.

Affected versions

The report reproduces the issue on 1.2.2 and reports it on development commit 475c1b7. The affected-product field lists the reproduced release only; it is not a claim that earlier releases are unaffected.

The earliest affected release needs confirmation: the report's summary says 1.1.x through 1.2.2, while its root-cause analysis attributes introduction to commit cd81370 (PR #673). Resolve this discrepancy before publishing a definitive affected-version range.

Reproduction

Run in a disposable local process with the C extension installed:

import msgpack

payload = msgpack.packb({42: b"A" * (4 * 1024 * 1024)}, use_bin_type=True)
msgpack.unpackb(payload)  # Raises ValueError; the report observes a 4 MiB leak.

Streaming API trigger:

import msgpack

payload = msgpack.packb({42: b"A" * (4 * 1024 * 1024)}, use_bin_type=True)
u = msgpack.Unpacker()
u.feed(payload)
list(u)  # Same strict_map_key error path.

Workarounds

The pure-Python fallback is reported not to leak on this path and may be used as a temporary workaround after application compatibility and performance checks. Request-size and rate limits may reduce the impact but do not eliminate cumulative leakage.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "PyPI",
        "name": "msgpack"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "1.2.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-114613"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-401",
      "CWE-416"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-10-27T15:04:07Z",
    "nvd_published_at": "2026-10-22T19:17:37Z",
    "severity": "HIGH"
  },
  "details": "### Impact\n\nThe msgpack-python C extension (`msgpack._cmsgpack`) leaks a decoded map value when deserialization rejects a key with `strict_map_key=True` (the default). Repeated malformed inputs can cause unbounded process memory growth and denial of service in applications that deserialize attacker-controlled MessagePack data. Both `unpackb()` and the streaming `Unpacker` API are affected. The pure-Python fallback does not exhibit this leak in the reported tests.\n\nThe report measured approximately 4 MiB retained per failed parse and 100 MiB after 25 failed parses on Windows with Python 3.14 and msgpack 1.2.2. These are reporter-provided results.\n\n### Additional impact: stale parser-stack references\n\nThe reference-ownership audit performed while fixing this leak found an\nadditional memory-safety issue in the streaming `Unpacker`.\n\nAfter `unpack()` completed a nested container, an inactive parser-stack slot\ncould retain a non-owning pointer to the decoded object. A subsequent `skip()`\ncould reactivate that slot. If parsing then failed, context cleanup treated the\nstale pointer as an owned reference and decremented it.\n\nThis corrupts the object\u0027s reference count and can result in a use-after-free\nor double `Py_DECREF` when its actual owners later release it.\n\nAlthough few users use this API, but those who do may experience crashes or unexpected errors due to a use-after-free.\n\n### Details\n\nIn `msgpack/unpack.h`, `unpack_callback_map_item()` rejects keys that are neither `str` nor `bytes`. At this point the map value has already been constructed. The early error return does not release the value reference.\n\nIn `msgpack/unpack_template.h`, the value is held in the local `obj` in `unpack_execute()`. The `CT_MAP_VALUE` error path jumps to `_failed` without decrementing that reference. Cleanup of the parser stack does not recover the value because it is not stored in the stack. The fallback checks the key before decoding the value.\n\n### Affected versions\n\nThe report reproduces the issue on **1.2.2** and reports it on development commit `475c1b7`. The affected-product field lists the reproduced release only; it is not a claim that earlier releases are unaffected.\n\nThe earliest affected release needs confirmation: the report\u0027s summary says 1.1.x through 1.2.2, while its root-cause analysis attributes introduction to commit `cd81370` (PR #673). Resolve this discrepancy before publishing a definitive affected-version range.\n\n### Reproduction\n\nRun in a disposable local process with the C extension installed:\n\n```python\nimport msgpack\n\npayload = msgpack.packb({42: b\"A\" * (4 * 1024 * 1024)}, use_bin_type=True)\nmsgpack.unpackb(payload)  # Raises ValueError; the report observes a 4 MiB leak.\n```\n\nStreaming API trigger:\n\n```python\nimport msgpack\n\npayload = msgpack.packb({42: b\"A\" * (4 * 1024 * 1024)}, use_bin_type=True)\nu = msgpack.Unpacker()\nu.feed(payload)\nlist(u)  # Same strict_map_key error path.\n```\n\n### Workarounds\n\nThe pure-Python fallback is reported not to leak on this path and may be used as a temporary workaround after application compatibility and performance checks. Request-size and rate limits may reduce the impact but do not eliminate cumulative leakage.",
  "id": "GHSA-j586-36cw-2gc2",
  "modified": "2026-10-27T15:04:07Z",
  "published": "2026-10-27T15:04:07Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/msgpack/msgpack-python/security/advisories/GHSA-j586-36cw-2gc2"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-114613"
    },
    {
      "type": "WEB",
      "url": "https://github.com/msgpack/msgpack-python/commit/620b0eb4c89cd72d4098564537624d9dbb2ce141"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/msgpack/msgpack-python"
    },
    {
      "type": "WEB",
      "url": "https://github.com/msgpack/msgpack-python/releases/tag/v1.2.3"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "MessagePack: Unbounded memory leak in msgpack C extension on strict_map_key validation failure"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline

Sightings and recorded dates, grouped by day · UTC

JSON
Events included in the timeline

Loading timeline…


    Loading…

    Loading…

    Loading…

    Related by attack behaviour

    Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.