NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · PyPI

CVE-2026-114613: MessagePack: Unbounded memory leak in msgpack C extension on strict_map_key validation failure

highCVSS 3.1 7.5GHSA-j586-36cw-2gc2

The msgpack Python package (msgpack-python) leaks memory in its C extension when it rejects a map key under strict_map_key=True, the default. Repeated malformed input from an untrusted source can grow process memory without limit and cause denial of service. A related stale-pointer bug in the streaming Unpacker can cause use-after-free. Upgrade to msgpack 1.2.3.

Published Oct 27, 2026 · Analysis Nov 1, 2026

What an attacker can do

In msgpack/unpack.h, unpack_callback_map_item() rejects keys that are not str or bytes. By then the map value has already been built, and the early error return does not release it. In msgpack/unpack_template.h, the value sits in the local obj in unpack_execute(), and the CT_MAP_VALUE error path jumps to _failed without decrementing it. Parser-stack cleanup cannot recover it. Both unpackb() and the streaming Unpacker are affected. The pure-Python fallback checks the key before decoding the value, so it does not leak.

The reporter measured about 4 MiB kept per failed parse, and 100 MiB after 25 failed parses, on Windows with Python 3.14 and msgpack 1.2.2. An attacker who can send MessagePack to a service, such as an API, queue consumer or RPC endpoint, needs no login. The payload is one map with a non-string key and a large value. Repeating it exhausts memory.

The advisory also describes a second bug. After unpack() finishes a nested container, an inactive parser-stack slot can keep a non-owning pointer. A later skip() can reactivate it, and if parsing then fails, cleanup decrements a reference it does not own. This corrupts the reference count and can cause use-after-free or a double Py_DECREF. Few applications use that API path.

Who is affected

The reporter reproduced the issue on msgpack 1.2.2 and on development commit 475c1b7. The package data lists everything below 1.2.3 as vulnerable. The advisory says the earliest affected release is unconfirmed: the report's summary says 1.1.x through 1.2.2, while its root-cause analysis points to commit cd81370 (PR 673). Only the C extension, msgpack._cmsgpack, leaks.

Check your version:

pip show msgpack

msgpack

Ecosystem
PyPI
Affected
< 1.2.3
Fixed in
1.2.3
Check
pip show msgpack

How to fix it

Upgrade to msgpack 1.2.3. Its release notes say it fixes memory leaks in the C extension when map key validation or container hooks fail.

pip install --upgrade "msgpack>=1.2.3"

If you cannot upgrade yet, the advisory says the pure-Python fallback does not leak on this path. Test compatibility and speed before you switch. Request-size and rate limits help, but they do not stop the cumulative leak.

How to tell if you were hit

Watch for steady resident-memory growth in processes that decode MessagePack from outside, along with repeated ValueError exceptions from unpackb() or Unpacker iteration about map keys. Memory that grows in steps of several MiB per bad request matches the reported pattern. Check each service's lockfile for msgpack below 1.2.3. Look for out-of-memory kills and restarts of those workers. Crashes inside the C extension after a failed skip() may point to the use-after-free bug.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

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.

Questions

Is the default msgpack configuration vulnerable to CVE-2026-114613?

Yes. The leak happens on the strict_map_key=True path, which is the default. It needs the C extension, so a build that runs the pure-Python fallback is not affected by the leak.

Which msgpack version fixes the leak?

msgpack 1.2.3. The advisory lists versions below 1.2.3 as vulnerable. It confirms 1.2.2 and says the earliest affected release still needs confirmation.

Can an attacker run code with this flaw?

The main effect is denial of service through memory growth. The advisory also describes a use-after-free in the streaming Unpacker after skip() and a failed parse, which could crash the process. It does not claim code execution.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More PyPI vulnerabilities

All PyPI entries