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

CVE-2026-119793: libp2p: gossipsub creates a permanent topics-map entry per distinct subscription with no cap in the default config

highCVSS 3.1 7.5GHSA-x2vm-cf3p-m2w8

@libp2p/gossipsub before 17.0.0 stores every topic a peer subscribes to in a map with no cap in the default config. One connected peer can flood subscription RPCs and grow the map toward out-of-memory, and scoring never greylists it. Upgrade to 17.0.0, which adds a per-peer budget.

Published Nov 17, 2026 · Analysis Nov 17, 2026

What an attacker can do

handleReceivedSubscription in packages/gossipsub/src/gossipsub.ts runs this.topics.set(topic, new Set()) for every new topic string a peer subscribes to. Nothing bounds it by default: no global cap, no per-peer cap and no topic-length cap. The only gate, allowedTopics, is skipped when it is null, which is the default. Subscriptions are unsigned RPC metadata. The per-RPC decode limit of 5000 subscriptions caps count per message, not total size. Peer scoring has no subscription-volume term, so the attacker's score stays at 0, above the graylist threshold of -80, and the peer is never dropped (CWE-770, CWE-400).

The reporter's proof of concept sent 300 RPC frames of 4,000 unique topics of about 190 bytes each from one peer. The victim's topics map reached about 1.1 million entries and resident memory grew by about 900 MB. A control run with allowedTopics set to one topic rejected the same flood, which confirms the default config is the trigger.

The attacker needs one connection to a gossipsub node. No authentication is required. The result is memory exhaustion and a crashed node, a denial of service. When the peer disconnects, removePeer walks every topic entry, which adds CPU cost.

Who is affected

@libp2p/gossipsub below 17.0.0 (npm), running with the default configuration where allowedTopics is not set. The reporter verified it on js-libp2p with @libp2p/gossipsub 16.0.4. Nodes that set allowedTopics are not exposed to this flood.

Check your install:

npm ls @libp2p/gossipsub

If you use libp2p through another package, check the nested dependency as well.

@libp2p/gossipsub

Ecosystem
npm
Affected
< 17.0.0
Fixed in
17.0.0
Check
npm ls @libp2p/gossipsub

How to fix it

Upgrade to @libp2p/gossipsub 17.0.0.

npm install @libp2p/[email protected]

The fix (PR 3593) adds a per-peer memory budget for tracked topics, set with the option maxTopicBytesPerPeer. The default is 1 MiB, roughly 1,000 topics per peer. Each topic costs its string length plus a small fixed overhead. Subscriptions beyond the budget are ignored, and the peer keeps the topics it already had. Unsubscribing refunds the budget, and removing the peer clears it.

This is a breaking change: a peer that legitimately subscribes to more than about 1,000 topics now has the excess ignored. Raise maxTopicBytesPerPeer if you need that. Also consider setting allowedTopics to the topics your app uses, which the reporter's control run showed blocks the flood.

How to tell if you were hit

Watch node memory. A steady climb in resident set size with few connected peers points to this. Inspect the size of the gossipsub topics map if you expose it in metrics, and look for one peer that has subscribed to far more topics than your application uses, especially long random topic names. On 17.0.0, the over-budget log message shows that a peer exceeded its limit. After a suspect peer disconnects, expect a CPU spike from the removePeer sweep.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Summary

A single gossipsub peer can grow a node's topics map without bound by flooding subscription RPCs, because the default configuration has no global, per-peer, or topic-length cap and peer scoring does not penalise subscription volume. The peer is never greylisted, so the growth continues toward OOM.

Details

handleReceivedSubscription (packages/gossipsub/src/gossipsub.ts:1028, line 1036) runs this.topics.set(topic, new Set()) for every distinct topic string:

private handleReceivedSubscription (from, topic, subscribe) {
  let topicSet = this.topics.get(topic)
  if (subscribe) {
    if (topicSet == null) {
      topicSet = new Set()
      this.topics.set(topic, topicSet)   // no global cap, no per-peer cap
    }
    topicSet.add(from.toString())
  }
}

The only topical gate (gossipsub.ts:981, if (this.allowedTopics != null && !this.allowedTopics.has(topic)) return) is skipped when allowedTopics is null — the default. Subscriptions are unsigned RPC metadata (no signature needed); decodeRpc's per-RPC limit caps count (maxSubscriptions = 5000) but not topic-string length or aggregate size; and the peer-scoring components P1–P7 have no subscription-volume term, so the attacker's score stays at 0 (above the graylistThreshold of −80) and acceptFrom keeps returning true. Verified on js-libp2p commit a04f5e0, where @libp2p/gossipsub reads 16.0.4.

PoC

Full PoC attached (gossipsub-topics-unbounded-growth-poc.tar.gz). Build the js-libp2p monorepo at the affected version (npm install --ignore-scripts && npm run build), extract the package inside the monorepo root (sibling of packages/), then cd gossipsub-topics-unbounded-growth-poc && node attack.mjs. Expected (default config):

[*] sending 300 RPC frames x 4000 unique ~190-byte topic subscriptions (1,200,000 topics total)
[*]   progress: 88% sent | victim topics=1,032,000 rss=740MB peers=1
[*] victim quiesced: topics=~1,100,000 rss=~870MB peers=1
[!] Vulnerability reproduced: one connected peer grew the victim's gossipsub topics map to ~1.1M entries (RSS +~900MB) with 300 subscription RPCs — no global, per-peer, or topic-length cap in the default config

Control run (ALLOWED_TOPICS=legit-topic, i.e. node attack.mjs control): the identical flood is rejected at the allowedTopics gate and the topics map stays at 0 entries — confirming the vulnerable condition is the default allowedTopics-unset config. The map grows monotonically with no cap until the victim's own resource pressure trips; on disconnect removePeer performs an O(N) sweep over every topic entry (a secondary CPU cost) while the ~1 GB heap stays committed.

Impact

CWE-400/CWE-770. Every node running default gossipsub is affected; the attacker needs only one connection and is never rate-limited or greylisted. Growth continues toward OOM; on disconnect the O(N) removePeer sweep adds CPU cost. Suggested fix: bound by default (not opt-in) — a global cap on topics.size, a per-peer subscription cap with a P7 behaviour penalty so acceptFrom eventually greylists, a topic-string length cap at decode time, and/or flipping allowedTopics to deny-by-default; make removePeer's topic iteration non-blocking/capped.

gossipsub-topics-unbounded-growth-poc.tar.gz

Credited to X1AOxiang.

Questions

Is the default gossipsub configuration vulnerable?

Yes. Before 17.0.0 the default config has allowedTopics unset and no cap on stored topics, so one peer can grow the map without limit.

Does it need authentication?

No. The attacker needs one connection to the node. Subscriptions are unsigned RPC metadata and peer scoring never penalizes them.

Which version fixes CVE-2026-119793?

@libp2p/gossipsub 17.0.0, which adds the maxTopicBytesPerPeer budget with a 1 MiB default.

Does the upgrade change behavior?

Yes, it is a breaking change. Subscriptions past a peer's budget, about 1,000 topics, are ignored unless you raise maxTopicBytesPerPeer.

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 npm vulnerabilities

All npm entries