Zephyr's IP socket recvmsg() implementation (subsys/net/lib/sockets/sockets_inet.c, insert_pktinfo()) validated the user-supplied ancillary (msg_control) buffer using only the payload length (msg->msg_controllen < pktinfo_len) before writing a full control message consisting of an aligned cmsg header plus the payload. Because the check omitted the cmsg header size, a control buffer whose length falls in the under-checked window (e.g. 16-27 bytes for IPv4 IP_PKTINFO on a 64-bit target, where a single element actually occupies 28 bytes) passes the guard yet causes a fixed-size out-of-bounds write of up to one cmsg header (~12 bytes) past the end of the buffer.
Under CONFIG_USERSPACE the recvmsg verifier allocates a kernel-heap copy of the control buffer sized to msg_controllen and runs the implementation against it, so the overflow corrupts kernel heap memory and is triggerable from an unprivileged userspace thread; in supervisor mode it corrupts the caller's buffer.
The path is reachable on a UDP/IP socket with IP_PKTINFO/IPV6_RECVPKTINFO (or hoplimit/timestamping) enabled when the application calls recvmsg() with an undersized control buffer and a datagram is received; part of the overwritten bytes (the destination IP in ipi_addr) is influenced by the received packet.
The fix makes the capacity check use NET_CMSG_SPACE(pktinfo_len) (aligned header + aligned data) and returns -ENOMEM when the buffer is too small. Affected: v3.6.0 through v4.4.0.
Affected components
Affected versions
v3.6.0 through v4.4.0 (present in latest release; CONFIG_NET_CONTEXT_RECV_PKTINFO / RECV_HOPLIMIT / NET_CONTEXT_TIMESTAMPING with the matching socket option enabled)
Fix
Fixed (silently, merged) in 01fe77b
Projected fixed version: 4.5.0 (the fix is merged on main but not yet released; this forecast should be confirmed against the actual release).
Introduced by: 5488e76 net: socket: Add support for filling receive pktinfo data (2023-11-27; later relocated by 404e9c7)
Evidence
- subsys/net/lib/sockets/sockets_inet.c:1019-1023 (post-fix) — capacity check now NET_CMSG_SPACE(pktinfo_len); parent rev only checked msg_controllen < pktinfo_len, omitting the cmsg header
- subsys/net/lib/sockets/sockets_inet.c:1035-1039 — writes NET_CMSG_LEN header then memcpy of pktinfo_len into NET_CMSG_DATA, spanning aligned-header + payload (28 bytes for IPv4 PKTINFO)
- include/zephyr/net/net_ip.h:332-368 — NET_CMSG_FIRSTHDR requires msg_controllen >= sizeof(net_cmsghdr) (16); NET_CMSG_SPACE = aligned header + aligned data; NET_CMSG_LEN = aligned header + data — establishes the [16,27] overflow window
- subsys/net/lib/sockets/sockets.c:626-639,654-660 — z_vrfy_zsock_recvmsg allocates kernel-heap msg_control via k_usermode_alloc_from_copy(.., msg_controllen) and runs the impl on it, so the OOB write hits kernel heap; copy-back is bounded by msg_controllen (no copy-back overflow)
- subsys/net/lib/sockets/sockets_inet.c:1308-1338 — recv_dgram only checks msg_control!=NULL and msg_controllen>0 before insert_pktinfo; no outer full-space guard; add_pktinfo gated on net_context_is_recv_pktinfo_set
- git tag --contains 5488e76 and git show v4.4.0:...sockets_inet.c — vulnerable check shipped in v3.6.0..v4.4.0, still present in latest release (reportable)
Patches
Fix 1 — #106464
| Branch |
Pull request |
Status |
main |
#106464 |
merged |
v4.4-branch |
#110668 |
merged |
v4.3-branch |
#110669 |
merged |
v3.7-branch |
— |
not affected |
Fix 2 — #110780
For more information
If you have any questions or comments about this advisory:
embargo: 2026-06-19
Zephyr's IP socket
recvmsg()implementation (subsys/net/lib/sockets/sockets_inet.c,insert_pktinfo()) validated the user-supplied ancillary (msg_control) buffer using only the payload length (msg->msg_controllen<pktinfo_len) before writing a full control message consisting of an aligned cmsg header plus the payload. Because the check omitted the cmsg header size, a control buffer whose length falls in the under-checked window (e.g. 16-27 bytes for IPv4IP_PKTINFOon a 64-bit target, where a single element actually occupies 28 bytes) passes the guard yet causes a fixed-size out-of-bounds write of up to one cmsg header (~12 bytes) past the end of the buffer.Under
CONFIG_USERSPACEtherecvmsgverifier allocates a kernel-heap copy of the control buffer sized tomsg_controllenand runs the implementation against it, so the overflow corrupts kernel heap memory and is triggerable from an unprivileged userspace thread; in supervisor mode it corrupts the caller's buffer.The path is reachable on a UDP/IP socket with
IP_PKTINFO/IPV6_RECVPKTINFO(or hoplimit/timestamping) enabled when the application callsrecvmsg()with an undersized control buffer and a datagram is received; part of the overwritten bytes (the destination IP inipi_addr) is influenced by the received packet.The fix makes the capacity check use
NET_CMSG_SPACE(pktinfo_len)(aligned header + aligned data) and returns-ENOMEMwhen the buffer is too small. Affected: v3.6.0 through v4.4.0.Affected components
subsys/net/lib/socketsAffected versions
v3.6.0 through v4.4.0 (present in latest release; CONFIG_NET_CONTEXT_RECV_PKTINFO / RECV_HOPLIMIT / NET_CONTEXT_TIMESTAMPING with the matching socket option enabled)
Fix
Fixed (silently, merged) in 01fe77b
Projected fixed version: 4.5.0 (the fix is merged on
mainbut not yet released; this forecast should be confirmed against the actual release).Introduced by: 5488e76 net: socket: Add support for filling receive pktinfo data (2023-11-27; later relocated by 404e9c7)
Evidence
Patches
Fix 1 — #106464
mainv4.4-branchv4.3-branchv3.7-branchFix 2 — #110780
mainv4.4-branchv4.3-branchv3.7-branchFor more information
If you have any questions or comments about this advisory:
embargo: 2026-06-19