All projects with patches now have outreach docs. 276 new docs covering CWE-407, CWE-312, CWE-362 across C, C++, Java, Python, Go, Rust, C#, PHP, Ruby, JavaScript, Dart, Erlang, R, and more. Outreach gap: 276 -> 0.
2.2 KiB
go-libp2p — CWE-407 Disclosure Brief (go-libp2p-0002)
2026-04-13 · Patch available — awaiting upstream merge
Finding
One O(n²) defect in go-libp2p's noise transport muxer negotiation. The matchMuxers() function in p2p/security/noise/transport.go uses slices.Contains() to find the first common muxer between initiator and responder lists.
The Defect
go-libp2p-0002 (PATCHED — LOW): p2p/security/noise/transport.go in matchMuxers()
func matchMuxers(initiatorMuxers, responderMuxers []protocol.ID) protocol.ID {
for _, initMuxer := range initiatorMuxers {
if slices.Contains(responderMuxers, initMuxer) { // O(R) per iteration
return initMuxer
}
}
return ""
}
For I initiator muxers and R responder muxers, the worst-case cost (no match found) is O(I*R).
Complexity Proof
At I=10, R=10 muxers:
- Defective: 10 × 10 = 100 comparisons (worst case)
- Fixed: 10 map build + 10 lookups = 20 operations
- ~5× op reduction. Fires on every noise handshake.
Impact
go-libp2p's noise transport handles encrypted connections for IPFS, Filecoin, and many other P2P networks. Muxer negotiation fires on every connection establishment. While muxer lists are currently small, the fix eliminates unnecessary quadratic scaling.
The Fix
Build a map[protocol.ID]struct{} from responder muxers, then iterate initiator muxers with O(1) lookup:
// After
respSet := make(map[protocol.ID]struct{}, len(responderMuxers))
for _, m := range responderMuxers { respSet[m] = struct{}{} }
for _, initMuxer := range initiatorMuxers {
if _, ok := respSet[initMuxer]; ok { return initMuxer }
}
Patch
Fix available: defects/go-libp2p-0002/patch/go-libp2p-0002.patch
Single-file patch in p2p/security/noise/transport.go. ~5× speedup at 10 muxers.
What We Ask
A patch is ready for review.
- Confirm receipt and assign a GitHub issue reference (libp2p/go-libp2p).
- Assess severity — fires on every noise handshake.
- Coordinate a disclosure date — we are targeting 90 days from first contact.
- We will credit the libp2p team in the public disclosure. Preferred acknowledgment format welcome.
Contact: see cover email. This brief is confidential until coordinated disclosure.