NGM_CISCO_GET_IPADDR response sized with sizeof(ips) (pointer) instead of sizeof(*ips) (struct)
| Field | Value |
|---|---|
| ID | DF-0614 |
| Status | new |
| Severity | Info |
| CVSS 3.1 | CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:N |
| CWE | CWE-130 Improper Handling of Length Parameter Inconsistency |
| File | sys/netgraph/iface/ng_iface.c |
| Lines | 697, 701 |
| Area | netgraph (legacy interface node control message handler) |
| Confidence | certain |
| Discovered | 2026-07-02 |
| Reported | pending |
LATENT on all currently-supported DragonFlyBSD architectures. DragonFlyBSD only builds for x86_64 (
sys/platform/{pc64,vkernel64},sys/cpu/x86_64), wheresizeof(struct ng_cisco_ipaddr *)=sizeof(struct ng_cisco_ipaddr)= 8 bytes, so the buffer is correctly sized by accident. This is a correctness/hardening defect that becomes a 4-byte heap overflow on any 32-bit port or any future arch wheresizeof(void*) != sizeof(struct ng_cisco_ipaddr). Same typo class as DF-0608 (netgraph7ng_iface.c:487).
Summary
The NGM_CISCO_GET_IPADDR handler allocates the response data buffer using
sizeof(ips) where ips is struct ng_cisco_ipaddr * β i.e. it sizes the
buffer by the pointer width, not by the pointed-to struct. The code
then writes a full struct ng_cisco_ipaddr (8 bytes: ipaddr + netmask)
into it.
Root cause
sys/netgraph/iface/ng_iface.c:697-710:
697: struct ng_cisco_ipaddr *ips; /* pointer */
...
701: NG_MKRESPONSE(resp, msg, sizeof(ips), M_NOWAIT); /* sizeof(pointer) = 8 on amd64, 4 on i386 */
...
706: ips = (struct ng_cisco_ipaddr *)resp->data;
707: ips->ipaddr = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr; /* offset 0, 4 bytes */
709: ips->netmask = ((struct sockaddr_in *)ifa->ifa_netmask)->sin_addr; /* offset 4, 4 bytes */
struct ng_cisco_ipaddr (sys/netgraph/cisco/ng_cisco.h:64-67) is exactly
8 bytes (two struct in_addr).
- Compare line 649 for
GET_IFNAMEwhich correctly usessizeof(*arg). - Compare
ng_cisco.c:286-296which correctly uses2 * sizeof(*ips)for the same logical operation.
The correct expression here is sizeof(*ips).
Threat model & preconditions
- Currently no security impact: DF's only supported arch is x86_64
where pointer width = struct width = 8 bytes, the buffer is
M_ZERO'd byNG_MKRESPONSE, andarglenis set to 8 so userspace reads exactly the right amount. - If DF ever revives i386 (it had i386 support until v4.x), or if
struct ng_cisco_ipaddrgrows padding/fields, this becomes a 4-byte heap overflow intoM_NETGRAPH, controllable from any local user holding anNG_CONTROLsocket.
Recommended fix
Use sizeof(*ips) consistently with the rest of the file.
--- a/sys/netgraph/iface/ng_iface.c
+++ b/sys/netgraph/iface/ng_iface.c
@@ -698,7 +698,7 @@ ng_iface_rcvmsg(node_p node, struct ng_mesg *msg,
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
- NG_MKRESPONSE(resp, msg, sizeof(ips), M_NOWAIT);
+ NG_MKRESPONSE(resp, msg, sizeof(*ips), M_NOWAIT);
if (resp == NULL) {
error = ENOMEM;
References
sys/netgraph/iface/ng_iface.c:697,701β the bug.sys/netgraph/iface/ng_iface.c:649β the correctsizeof(*arg)pattern used elsewhere in the same function.sys/netgraph/cisco/ng_cisco.c:286-296β the correct2*sizeof(*ips)pattern in the cisco node.sys/netgraph/cisco/ng_cisco.h:64-67βstruct ng_cisco_ipaddr(8 bytes).- DF-0608 β the identical typo in netgraph7
ng_iface.c.
Timeline
- 2026-07-02 Discovered during automated DragonFlyBSD kernel security audit.
- 2026-07-02 Reported to DragonFlyBSD security contact (pending).
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-0614 Β· 1 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | NGM_CISCO_GET_IPADDR response sized with sizeof(ips) (pointer) instead of sizeof | 384 B | view raw |
Fix verification
fixedfix.diff applied + combined nativekernel build rc=0 (-Werror)
fix.diff applied + combined nativekernel build rc=0 (-Werror)
Confirmed kernel references
β
Detail
Exploit chain
none (Info severity)
Evidence (decisive lines)
Source-confirmed at sys/netgraph/iface/ng_iface.c:697: response sized with sizeof(ips) (pointer) instead of sizeof(*ips)
Verified recommended fix
Source-confirmed at sys/netgraph/iface/ng_iface.c:697: response sized with sizeof(ips) (pointer) instead of sizeof(*ips)
Verdict
Source-confirmed at sys/netgraph/iface/ng_iface.c:697: response sized with sizeof(ips) (pointer) instead of sizeof(*ips)
No comments yet.