Executive brief
The GossipSub component of libp2p, used for peer-to-peer message routing in decentralized networks, contains a memory exhaustion vulnerability. An attacker can send specially crafted subscription messages containing thousands of unique topics to cause a Node.js process to consume excessive memory and crash within seconds. This affects any application using the vulnerable library on a public network without authentication requirements.
Technical details
The vulnerability arises from three compounding issues in @libp2p/gossipsub: (1) no decode-level cap on subscription entries per RPC (defaultDecodeRpcLimits.maxSubscriptions = Infinity), allowing a single 4MB frame to carry ~349K unique SUBSCRIBE entries; (2) unbounded growth of the this.topics map with no per-peer subscription limit, creating new Map/Set entries for every unique topic string; (3) a memory leak in removePeer() that retains empty Sets after peer disconnection, making memory non-reclaimable for the process lifetime. An unauthenticated attacker can open a gossipsub stream and repeatedly send RPCs with sequential unique topic subscriptions, achieving ~22x memory amplification (4MB attacker payload → ~89MB heap consumption) per frame. A Node.js process with default 1.5GB heap limit crashes after ~17 frames (~68MB total bandwidth). Patch version 15.0.23 and later address these defects.
Affected products
- libp2p @libp2p/gossipsub <=15.0.22
Timeline
- 2026-05-21: disclosed
- 2026-05-21: patched: patch version 15.0.23