# CVE-2021-21368: msgpack5 prototype poisoning in map decoding

Source: https://junglewise.ai/threats/cve-2021-21368-msgpack5-prototype-poisoning-in-map-decoding  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2021-03-12. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2021-21368 · Severity: low · CVSS 3.1 · Published 2021-03-12

msgpack5 is a JavaScript library for encoding and decoding MessagePack binary data. When processing crafted MessagePack messages, the library improperly handles the "__proto__" key, allowing an attacker to manipulate an object's prototype chain. This can cause decoded objects to behave unexpectedly or throw errors when used, potentially leading to application malfunction or serving as a stepping stone for further exploitation.

Technologies: [msgpack5 (npm)](https://junglewise.ai/threats/technologies/msgpack5). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is CVE-2021-21368 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2021-21368 being exploited in the wild.

**How severe is CVE-2021-21368?** Low severity, with a CVSS score of 3.1, published 12 March 2021.

**Which products and versions are affected?** msgpack5 (npm) SEMVER:introduced=0,fixed=3.6.1.

**Is there a fix for CVE-2021-21368?** Yes. msgpack5 (npm): upgrade to 3.6.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2021-21368 attacked?** It is attacked over the network.

**Am I affected by CVE-2021-21368?** Check whether you run msgpack5 (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- msgpack5 (npm): upgrade to 3.6.1 or later

  ```sh
  npm install msgpack5@3.6.1
  ```


## Technical details

The vulnerability is a prototype poisoning flaw in the map decoding logic of msgpack5. When msgpack5 decodes a MessagePack map containing a "__proto__" key, it assigns the decoded value directly to the object's __proto__ property, overwriting the object's prototype chain. The attack requires network-reachable access to submit crafted MessagePack payloads and low privileges (or ability to send data to the service). An attacker can craft payloads where the "__proto__" value decodes to an object (such as a Map or Array), causing the decoded object to masquerade as that type while failing when actual type-specific methods are invoked. The issue does not affect the global prototype and is limited to individual decoded objects. Patches are available in versions 3.6.1, 4.5.1, and 5.2.1.

## Affected products

- msgpack5 msgpack5 < 3.6.1, 4.0.0 to < 4.5.1, 5.0.0 to < 5.2.1

## Identifiers

- CVE-2021-21368
- GHSA-gmjw-49p4-pcfm

## Timeline

- 2021-03-09: disclosed
- 2021-03-12: patched: Patches released in versions 3.6.1, 4.5.1, and 5.2.1

## References

- [https://github.com/mcollina/msgpack5/security/advisories/GHSA-gmjw-49p4-pcfm](https://github.com/mcollina/msgpack5/security/advisories/GHSA-gmjw-49p4-pcfm)

## Related threats

- [msgpack5 out-of-bounds read in truncated map32 header](https://junglewise.ai/threats/cve-2026-107302-msgpack5-truncated-map32-headers-throw-an-unexpected-error)
- [msgpack5 uncontrolled recursion in streaming decoder](https://junglewise.ai/threats/cve-2026-107300-msgpack5-many-buffered-values-can-exhaust-the-streaming-decoder)
- [msgpack5 unbounded stream buffering via reserved byte](https://junglewise.ai/threats/cve-2026-107299-msgpack5-reserved-byte-can-cause-unbounded-stream-buffering)
- [msgpack5 prototype pollution via partial options](https://junglewise.ai/threats/cve-2026-107301-msgpack5-partial-options-disable-prototype-protection)
- [msgpack5 uncontrolled recursion in decoder](https://junglewise.ai/threats/cve-2026-107298-msgpack5-deeply-nested-input-can-exhaust-the-decoder-stack)
