]> git.ipfire.org Git - thirdparty/squid.git/commit
ICMP: Harden echo paths, fix overflows, UB, and leaks (#2199)
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Thu, 23 Oct 2025 10:11:27 +0000 (10:11 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 25 Oct 2025 07:18:40 +0000 (07:18 +0000)
commit5725a54a18083101a03abf70b54c8b29130376b3
treef7278fc1aaa4135da8dd9881c7d795861200361a
parent85b9d6d92057c1185c1ab883c550a01347b1c02e
ICMP: Harden echo paths, fix overflows, UB, and leaks (#2199)

ICMPv4 send now validates getAddrInfo results before touching
ai_addr, avoiding null-deref, and frees the address on error.
Logging no longer passes nullptr strings, preventing UB.

ICMPv4 recv gained strict bounds checks: reject packets shorter
than IP/ICMP headers, reject bogus iphdrlen, and require enough
bytes for echo meta. Payload length is computed from real data,
clamped to MAX_PAYLOAD, and malformed negatives are dropped. The
result size calculation now uses PINGER_PAYLOAD_SZ instead of the
wrong MAX_PKT4_SZ, fixing excess memory disclosure.

ICMPv6 send added the same getAddrInfo validation and safe log
string handling. The recv path now checks for minimal header
lengths, validates echo meta, fixes ident comparison with ntohs,
and clamps payload length safely before copying into preply.

The pinger handshake no longer uses strlen() on raw buffers;
it now echoes exactly the bytes received, avoiding OOB reads.

Squid Recv was changed to treat pingerReplyData as variable-
length. It validates base header size, available payload, and
non-negative psize, and rejects truncated or oversized datagrams,
fixing past OOB read risks.

Finally, netdbBinaryExchange now flushes its 4K buffer before
writing the next record, fixing a possible overflow at the end of
the buffer.
src/icmp/Icmp4.cc
src/icmp/Icmp6.cc
src/icmp/IcmpPinger.cc
src/icmp/IcmpSquid.cc
src/icmp/net_db.cc
src/icmp/pinger.cc