title: Stack overflow in ping(8)
description: ping reads raw IP packets from the network to process responses in the pr_pack() function.  As part of processing a response ping has to reconstruct the IP header, the ICMP header and if present a "quoted packet," which represents the packet that generated an ICMP error.  The quoted packet again has an IP header and an ICMP header.
The pr_pack() copies received IP and ICMP headers into stack buffers for further processing.  In so doing, it fails to take into account the possible presence of IP option headers following the IP header in either the response or the quoted packet.  When IP options are present, pr_pack() overflows the destination buffer by up to 40 bytes.
The memory safety bugs described above can be triggered by a remote host, causing the ping program to crash.
The ping process runs in a capability mode sandbox on all affected versions of FreeBSD and is thus very constrained in how it can interact with the rest of the system at the point where the bug can occur.
affected:
{
defaultStatus: unknown
modules: ping
product: FreeBSD
vendor: FreeBSD
versions:
lessThan: p5, status: affected, version: 13.1-RELEASE, versionType: release
lessThan: p2, status: affected, version: 12.4-RC2, versionType: release
lessThan: p10, status: affected, version: 12.3-RELEASE, versionType: release
}