From 8a8839e48efc5d3c7b2f6d40640b98766d63e724 Mon Sep 17 00:00:00 2001 From: Khashayar Fereidani Date: Wed, 24 Jun 2026 09:14:20 +0000 Subject: [PATCH 1/2] Guard nil payload in decoded session messages on the client. --- client.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client.go b/client.go index 0404ca3..ed78dce 100644 --- a/client.go +++ b/client.go @@ -123,6 +123,13 @@ func handshakeWithServerSync(test *ethrTest, conn net.Conn) (startTime time.Time err = os.ErrInvalid return } + // A SyncReady whose payload was omitted decodes with a nil SyncReady + // pointer; the Type check above does not prove otherwise. + if ethrMsg.SyncReady == nil { + ui.printDbg("Received SyncReady message with nil payload from Ethr server.") + err = os.ErrInvalid + return + } delayNs := ethrMsg.SyncReady.DelayNs if delayNs == 0 { @@ -335,6 +342,14 @@ func tcpRunBandwidthTestSync(test *ethrTest, toStop chan int, duration time.Dura toStop <- disconnect return } + // A SyncReady whose payload was omitted decodes with a nil SyncReady + // pointer; the Type check above does not prove otherwise. + if ethrMsg.SyncReady == nil { + ui.printErr("Received SyncReady message with nil payload from server.") + controlConn.Close() + toStop <- disconnect + return + } delayNs := ethrMsg.SyncReady.DelayNs rtt := recvTime.Sub(sendTime) rttNs := rtt.Nanoseconds() From b8b619a4976246be098b5b3fe8bdb9fe7e86b477 Mon Sep 17 00:00:00 2001 From: Khashayar Fereidani Date: Wed, 24 Jun 2026 09:15:10 +0000 Subject: [PATCH 2/2] Use checked type assertions when parsing ICMP messages. --- client.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index ed78dce..fd9d60a 100644 --- a/client.go +++ b/client.go @@ -1130,7 +1130,12 @@ func icmpRecvMsg(c net.PacketConn, proto EthrProtocol, timeout time.Duration, ne continue } if icmpMsg.Type == ipv4.ICMPTypeTimeExceeded || icmpMsg.Type == ipv6.ICMPTypeTimeExceeded { - body := icmpMsg.Body.(*icmp.TimeExceeded).Data + te, ok := icmpMsg.Body.(*icmp.TimeExceeded) + if !ok { + ui.printDbg("Received TimeExceeded ICMP message with unexpected body type.") + continue + } + body := te.Data index := bytes.Index(body, neededSig[:4]) if index > 0 { if proto == TCP { @@ -1159,7 +1164,11 @@ func icmpRecvMsg(c net.PacketConn, proto EthrProtocol, timeout time.Duration, ne } if proto == ICMP && (icmpMsg.Type == ipv4.ICMPTypeEchoReply || icmpMsg.Type == ipv6.ICMPTypeEchoReply) { - echo := icmpMsg.Body.(*icmp.Echo) + echo, ok := icmpMsg.Body.(*icmp.Echo) + if !ok { + ui.printDbg("Received EchoReply ICMP message with unexpected body type.") + continue + } ethrUnused(echo) b, _ := icmpMsg.Body.Marshal(1) if string(b[4:]) != string(neededIcmpBody) {