Silent Python Name-Mangling Bug Would Have Broken All WebRTC-Direct Connections in py-libp2p

A developer debugging py-libp2p's WebRTC-Direct implementation discovered a subtle bug where a certificate assignment appeared to work but was silently ignored by the aiortc library. When aiortc version 1.5 removed support for the certificates= parameter in RTCConfiguration, a workaround using pc._certificates failed because Python's name-mangling feature means aiortc internally stores the value as _RTCPeerConnection__certificates. As a result, aiortc continued using its own auto-generated certificate instead of the libp2p-specified one, meaning every real peer connection would have failed fingerprint verification. The flaw went undetected because the loopback echo test used for validation never checks DTLS fingerprints against the multiaddr certhash — the exact security property that was broken. The fix required setting the correctly mangled attribute pc._RTCPeerConnection__certificates directly, exposing how silent no-ops at library boundaries can defeat security guarantees without raising any error.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in