GHSA-jp3c-6v3g-mpxv: Uncaught Runtime Panic via Integer Underflow in insomniacslk/dhcp BroadcastRawUDPConn

Vulnerability ID: GHSA-JP3C-6V3G-MPXV
CVSS Score: 6.5
Published: 2026-11-24

A denial-of-service vulnerability exists in the Go library github.com/insomniacslk/dhcp within the dhcpv4/nclient4 subpackage. In affected versions, the raw packet parsing function BroadcastRawUDPConn.ReadFrom subtracts the fixed 8-byte UDP header length from the IPv4 payload length declared in the packet header without first verifying that the declared payload length is at least 8 bytes. An unauthenticated attacker on an adjacent local network segment can broadcast or unicast a malformed IPv4 packet with a declared payload length between 0 and 7 bytes, causing a signed integer underflow that passes a negative slice bound into buf.Consume and triggers an unhandled Go runtime panic.

TL;DR

An adjacent network attacker can crash Go applications using github.com/insomniacslk/dhcp/dhcpv4/nclient4 by sending a single malformed IPv4 packet declaring a payload length under 8 bytes, resulting in a negative slice index and an uncaught Go runtime panic in BroadcastRawUDPConn.ReadFrom.

⚠️ Exploit Status: POC

Technical Details

  • Advisory ID: GHSA-jp3c-6v3g-mpxv / GO-2026-6237
  • CWE Classification: CWE-191 (Integer Underflow) / CWE-129 (Improper Validation of Array Index)
  • CVSS v3.1 / v4.0: 6.5 Medium (v3.1) / 7.1 High (v4.0)
  • Attack Vector: Adjacent Network (Layer 2 Broadcast Domain, UDP Port 67 -> 68)
  • Affected Symbol: BroadcastRawUDPConn.ReadFrom (dhcpv4/nclient4)
  • Primary Impact: Denial of Service via Unhandled Go Runtime Slice Bounds Panic
  • Exploit Status: Proof-of-Concept (Unit test reproduction in upstream commit)
  • Patched Version: v0.0.0-20260719225207-c76316d4aa82

Affected Systems

  • github.com/insomniacslk/dhcp
  • github.com/insomniacslk/dhcp/dhcpv4/nclient4
  • github.com/insomniacslk/dhcp/dhcpv4/nclient4: >= v0.0.0-20190522091526-5dce45b2b680, < v0.0.0-20260719225207-c76316d4aa82 (Fixed in: v0.0.0-20260719225207-c76316d4aa82)

Code Analysis

Commit: c76316d

Validate that IPv4 payload length is at least udpHdrLen (8 bytes) and that buf has dhcpLen bytes before calling buf.Consume(dhcpLen) in BroadcastRawUDPConn.ReadFrom.

diff --git a/dhcpv4/nclient4/conn_unix.go b/dhcpv4/nclient4/conn_unix.go index f3e48c66e..51b93e6af 100644 --- a/dhcpv4/nclient4/conn_unix.go +++ b/dhcpv4/nclient4/conn_unix.go @@ -111,6 +111,14 @@ func (upc *BroadcastRawUDPConn) ReadFrom(b []byte) (int, net.Addr, error) { continue } + // The IPv4 payload must be large enough to hold a UDP header. Discarding + // frames that declare fewer bytes keeps the DHCP length computed below + // non-negative and avoids parsing trailing padding as a UDP header. + ipPayloadLen := int(ipHdr.payloadLength()) + if ipPayloadLen < udpHdrLen { + continue + } + if !buf.Has(udpHdrLen) { continue } @@ -128,9 +136,12 @@ func (upc *BroadcastRawUDPConn) ReadFrom(b []byte) (int, net.Addr, error) { IP: ipHdr.sourceAddress(), Port: int(udpHdr.sourcePort()), } - // Extra padding after end of IP packet should be ignored, - // if not dhcp option parsing will fail. - dhcpLen := int(ipHdr.payloadLength()) - udpHdrLen + // Extra padding after the end of the IP payload is ignored; otherwise + // dhcp option parsing would fail. + dhcpLen := ipPayloadLen - udpHdrLen + if !buf.Has(dhcpLen) { + continue + } return copy(b, buf.Consume(dhcpLen)), srcAddr, nil } } 

Exploit Details

  • GitHub: Upstream regression test harness (conn_unix_test.go) demonstrating packet crafting with short IPv4 Total Length values (20 and 27 bytes) that trigger negative dhcpLen values (-8 and -1).

Mitigation Strategies

  • Upgrade github.com/insomniacslk/dhcp to v0.0.0-20260719225207-c76316d4aa82 or later to enforce IPv4 payload length and buffer bounds checks in BroadcastRawUDPConn.ReadFrom.
  • Enable Layer 2 DHCP Snooping on network switches to drop rogue packets originating from UDP source port 67 or targeting UDP destination port 68 on untrusted ports.
  • Apply Linux netdev ingress filtering (nftables netdev hook or tc/ebtables) to discard malformed UDP-over-IPv4 packets with an IPv4 Total Length under 28 bytes before raw socket delivery.

Remediation Steps:

  1. Identify affected projects using govulncheck ./... to detect transitive or direct calls to github.com/insomniacslk/dhcp/dhcpv4/nclient4.BroadcastRawUDPConn.ReadFrom.
  2. Update go.mod by running: go get github.com/insomniacslk/dhcp@c76316d4aa825673b208730779843d0711021e81 && go mod tidy
  3. Rebuild and redeploy all Go binaries, initramfs images, or provisioning agents that link against the dhcpv4/nclient4 package.
  4. Re-run govulncheck against the compiled binary or source tree to confirm GO-2026-6237 / GHSA-jp3c-6v3g-mpxv is resolved.

References

Read the full report for GHSA-JP3C-6V3G-MPXV on our website for more details including interactive diagrams and full exploit analysis.