Summary
A resource exhaustion issue in the JavaScript libp2p gossipsub implementation allows a single unauthenticated peer to consume excessive Node.js heap memory on targeted nodes using default options.
Under sustained attack traffic, affected gossipsub nodes may become unresponsive or crash, disrupting peer-to-peer messaging and dependent applications.
Affected context
This vulnerability affects applications built on the JavaScript libp2p stack that enable the gossipsub protocol with default configuration.
It becomes relevant in open or semi-open peer-to-peer networks where unknown peers can connect without prior authentication or strict admission controls.
The issue arises from a combination of omitted checks or limits in message handling and resource management paths, allowing abnormal traffic patterns to trigger excessive in-memory state growth in the Node.js process.
Exploit preconditions
- Attack surface: Network-accessible gossipsub endpoints running on Node.js.
- Required access: Ability to join or connect as a libp2p peer; no prior authentication is needed in typical default deployments.
- Trigger point: Malicious or malformed gossipsub traffic crafted to exercise the unchecked paths that grow memory usage.
- Why exploitation is possible: The implementation lacks robust validation and bounding of certain protocol inputs, and does not enforce strict memory or lifecycle limits for related data structures, allowing a single peer to trigger unbounded heap growth.
Why this happens
The underlying issue stems from insufficient input validation and incomplete resource management in the gossipsub implementation.
Protocol messages and peer interactions are accepted and processed without adequately constraining their volume, frequency, or associated memory footprint.
This maps to CWE-400: Uncontrolled Resource Consumption, reinforced by aspects of CWE-20: Improper Input Validation and CWE-401: Missing Release of Memory After Effective Lifetime, where data associated with untrusted peers or messages is allowed to accumulate on the heap without timely bounds or reclamation.
Potential impact
- A single malicious peer may cause targeted gossipsub nodes to exhaust available Node.js heap memory.
- Nodes can become unresponsive, crash, or restart repeatedly, leading to effective denial of service.
- Peer-to-peer messaging, pub/sub channels, and higher-level protocols relying on gossipsub may experience outages or degraded performance.
- In multi-node networks, the issue could be used to selectively destabilize critical relay or routing nodes, amplifying network-wide disruption.
General mitigation guidance
Mitigation typically focuses on enforcing strict limits and validation around untrusted network inputs and their resource impact.
Common defensive patterns include:
- Applying rigorous input validation on gossipsub messages, rejecting malformed or excessive traffic early.
- Introducing quotas and backpressure for per-peer and per-topic state (e.g., caps on message buffers, tracking queues, and in-memory maps).
- Implementing configurable resource budgets and timeouts that bound the size and lifetime of protocol-related data structures.
- Using peer scoring, rate-limiting, or connection gating to reduce the influence of untrusted or misbehaving peers.
- Running pub/sub components with least-privilege and monitoring, so that failures are isolated and quickly observable.
How teams detect issues like this
Effective detection blends runtime observability with proactive code analysis:
- Monitor Node.js processes for abnormal heap growth, frequent garbage collection pauses, or recurring out-of-memory crashes on gossipsub nodes.
- Track per-peer and per-topic metrics (message rates, buffer sizes, connection churn) to identify anomalous patterns indicative of abuse.
- Use static analysis and code review to flag unbounded data structures keyed by peer or message inputs, and areas that lack limits, timeouts, or eviction policies.
- Integrate automated checks in CI/CD that enforce policy rules around resource management (e.g., maximum queue sizes, required throttling for network handlers).
- Periodically perform stress and fuzz testing of the gossipsub layer to surface new memory pressure or leak scenarios before deployment.

