Skip to content

Upgrade github.com/pion/dtls from v2.2.12 to v3.1.8 - #482

Merged
antoninbas merged 1 commit into
vmware:mainfrom
antoninbas:bump-pion-dtls-v3
Sep 2, 2026
Merged

antoninbas merged 1 commit into
vmware:mainfrom
antoninbas:bump-pion-dtls-v3

Conversation

@antoninbas

Copy link
Copy Markdown
Member

The v2.2.12 release is affected by CVE-2026-26014 (GHSA-9f3f-wv7r-qc8r) and is quite old at this point.

The main behavior change in v3 is that the handshake is no longer performed by Dial and Accept: it now happens lazily on the first Read or Write. We restore the previous semantics by calling Handshake explicitly in both the exporter and the collector. This matters: without it, a certificate validation failure would no longer be reported by InitExportingProcess, and on the collector side the resulting read error would be misinterpreted as a normal shutdown signal by the existing "size == 0" check, silently dropping the connection.

Note that v2 bounded the handshake performed by Dial and Accept with a default 30s timeout (ConnectContextMaker), which has no equivalent in v3: Handshake blocks forever by default. We therefore use HandshakeContext with an explicit 30s timeout, which preserves the v2 semantics. Without it, a peer which starts a handshake and then stops responding would leave the collector goroutine (along with the listener and the connection) around for the lifetime of the process, and InitExportingProcess would never return.

The dtls.Config struct along with Dial and Listen are all deprecated in v3, so we move to the new functional options API. Note that the WithCipherSuites option rejects an empty list, and pion only falls back to its default suites when none were configured, hence we only set the option when the user actually provided cipher suites.

Cipher suite IDs are unchanged between the 2 versions (v3 only adds ChaCha20-Poly1305 suites), so the exported CipherSuites configuration fields keep their meaning. DTLS 1.2 also remains the only supported protocol version.

One more behavior change worth noting: v3 Dial creates the client socket with net.ListenUDP instead of net.DialUDP, as the latter prevents the use of net.PacketConn.WriteTo. The exporter's socket is therefore no longer connected, and the kernel no longer filters out datagrams from other sources. It also means that the local address of the connection is unspecified, which is why TestDTLSCollectingProcess can no longer rely on localConnSessionID to compute the session ID.

@antoninbas
antoninbas force-pushed the bump-pion-dtls-v3 branch 2 times, most recently from 470f23d to f567c7e Compare September 2, 2026 07:45
The v2.2.12 release is affected by CVE-2026-26014 (GHSA-9f3f-wv7r-qc8r)
and is quite old at this point.

The main behavior change in v3 is that the handshake is no longer
performed by Dial and Accept: it now happens lazily on the first Read or
Write. We restore the previous semantics by calling Handshake explicitly
in both the exporter and the collector. This matters: without it, a
certificate validation failure would no longer be reported by
InitExportingProcess, and on the collector side the resulting read error
would be misinterpreted as a normal shutdown signal by the existing
"size == 0" check, silently dropping the connection.

Note that v2 bounded the handshake performed by Dial and Accept with a
default 30s timeout (ConnectContextMaker), which has no equivalent in v3:
Handshake blocks forever by default. We therefore use HandshakeContext
with an explicit 30s timeout, which preserves the v2 semantics. Without
it, a peer which starts a handshake and then stops responding would leave
the collector goroutine (along with the listener and the connection)
around for the lifetime of the process, and InitExportingProcess would
never return.

Making the handshake explicit also surfaced how its failure was handled
on the collector side: a handshake error aborted startUDPServer, which
closed the listener and permanently stopped DTLS collection. This was
already the case with v2, where the error surfaced from Accept, and it
means any peer can take the collector down by failing to authenticate.
Accept and the handshake now run in a loop which drops the offending
connection and keeps accepting. As before, the DTLS path serves a single
exporter once a client completes the handshake.

The dtls.Config struct along with Dial and Listen are all deprecated in
v3, so we move to the new functional options API. Note that the
WithCipherSuites option rejects an empty list, and pion only falls back
to its default suites when none were configured, hence we only set the
option when the user actually provided cipher suites.

Cipher suite IDs are unchanged between the 2 versions (v3 only adds
ChaCha20-Poly1305 suites), so the exported CipherSuites configuration
fields keep their meaning. DTLS 1.2 also remains the only supported
protocol version.

One more behavior change had to be worked around: v3 Dial creates the
client socket with net.ListenUDP instead of net.DialUDP, as the latter
prevents the use of net.PacketConn.WriteTo. We have no use for WriteTo,
and an unconnected socket would change the exporter's behavior in 3 ways:
the source address of exported packets would be chosen by a route lookup
for every datagram, instead of being fixed when we dial, the kernel would
no longer discard datagrams from sources other than the collector, and
Write would no longer report ICMP errors such as ECONNREFUSED. It would
also make DTLS behave differently from plaintext UDP, which goes through
net.Dial and is therefore connected. We keep the v2 semantics by dialing
the socket ourselves and passing it to dtls.Client as a net.PacketConn,
using the PacketConnFromConn wrapper provided by pion, which ignores the
address given to WriteTo and writes to the connected socket.

Signed-off-by: Antonin Bas <antonin.bas@gmail.com>
@antoninbas
antoninbas merged commit b2c6fed into vmware:main Sep 2, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant