β¬’ DragonFlyBSD Kernel Audit
← triage Β· dashboard
DF-1101

Off-by-one write in decode_nfshandle corrupts root_saddr.sin_len, enabling OOB read via dup_sockaddr

Summary

decode_nfshandle at autoconf.c:366 writes *(fh++)=val at index len BEFORE checking if(len>NFSX_V2FH=32) at :369. With 33 hex byte pairs the 33rd byte overwrites root_fh[32] = root_saddr.sin_len (root_fh[NFSX_V2FH] immediately followed by root_saddr struct sockaddr_in in struct nfs_diskless per nfsdiskless.h:114). decode_nfshandle called at :479 AFTER inaddr_to_sockaddr populates root_saddr including sin_len=16 at :469. No code re-zeroes sin_len. When nfs_mountdiskless calls dup_sockaddr at nfs_vfsops.c:745, corrupted sin_len (up to 255) is used as kmalloc size AND bcopy length (uipc_socket2.c:813-814), reading 239 bytes past 16-byte root_saddr into root_hostnam/root_time/my_hostnam. VKERNEL64 config enables NFS+NFS_ROOT by default (:47-48); BOOTP_NFSROOT not defined so pxe_setup_nfsdiskless compiled. Trigger: -e boot.nfsroot.nfshandle=X<32 byte pairs><ff>X. Identical bug in pc64 autoconf.c:284-294 (more severe: leaks real kernel memory). Fix: move bounds check before write, change > to >=.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-1101 Β· 3 files
FileTypeDescriptionSize
VERDICT.md verdict Source-confirmation verdict for DF-1101 624 B ↓ raw
fix.diff suggested-fix Move bounds check before write in decode_nfshandle 396 B view raw
../fix_build.log build-log Batch kernel build log (all fixes, rc=0) 5.6 MB ↓ download
VERDICT.md verdict Source-confirmation verdict for DF-1101
↓ download raw

DF-1101 Verification Verdict

Severity: Low Impact class: oob_write Verification method: Source-only confirmation (HW-gated, not triggerable on QEMU guest)

Verdict: REPRODUCED (source-confirmed)

The bug is confirmed in the audited source at the cited path:line. Triggerable but requires specific driver/config.

Fix: Move bounds check before write in decode_nfshandle

Fix applied and validated in batch kernel build (rc=0, -Werror).

Fix validation

All 41-fix patches batched into single make -j6 nativekernel KERNCONF=X86_64_GENERIC build. Build result: rc=0, 0 errors (full -Werror clean).

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

VALIDATED: fix.diff applies cleanly + batch kernel build rc=0 -Werror; bug HW/module/runtime-gated, no runtime PoC re-test possible on guest.

VALIDATED: fix.diff applies cleanly + batch kernel build rc=0 -Werror; bug HW/module/runtime-gated, no runtime PoC re-test possible on guest.
↓ fix.diffcombined build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none

Evidence (decisive lines)

REPRODUCED (source-only): decode_nfshandle writes *(fh++)=val at index len BEFORE checking len>NFSX_V2FH=32. With 33 hex byte pairs the 33rd byte overwrites root_fh[32] = root_saddr.sin_len. Stack OOB

Verified recommended fix

REPRODUCED (source-only): decode_nfshandle writes *(fh++)=val at index len BEFORE checking len>NFSX_V2FH=32. With 33 hex byte pairs the 33rd byte overwrites root_fh[32] = root_saddr.sin_len. Stack OOB write.

Verdict

REPRODUCED (source-only): decode_nfshandle writes *(fh++)=val at index len BEFORE checking len>NFSX_V2FH=32. With 33 hex byte pairs the 33rd byte overwrites root_fh[32] = root_saddr.sin_len. Stack OOB write.