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

Off-by-one write in decode_nfshandle corrupts root_saddr.sin_len (pc64 sibling of DF-1101)

Summary

decode_nfshandle at autoconf.c:289 writes *(fh++)=val at index len BEFORE checking if(len>NFSX_V2FH=32) at :292. 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-115). Byte-for-byte identical to DF-1101 (vkernel64 version); function copy-pasted without fix. On pc64 (real hardware kernel) this corrupts REAL kernel memory not just userland process memory. Caller at :385 only prints warning and does NOT bail out; nfs_diskless_valid set to 1 at :391 so corrupted root_saddr consumed by NFS root mount. Attacker must control PXE/boot loader environment (boot.nfsroot.nfshandle with 33+ hex byte pairs). Requires NFS+NFS_ROOT compiled in. Impact: corrupted sin_len may cause incorrect sockaddr processing or failed NFS root mount (boot DoS). Fix: move bounds check before write, change > to >=.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-1108 Β· 3 files
FileTypeDescriptionSize
VERDICT.md verdict Source-confirmation verdict for DF-1108 624 B ↓ raw
fix.diff suggested-fix Move bounds check before write in decode_nfshandle 373 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-1108
↓ download raw

DF-1108 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; 33 hex byte pairs overwrite root_fh[32]=root_saddr.sin_len. Stack OOB write.

Verified recommended fix

REPRODUCED (source-only): decode_nfshandle writes *(fh++)=val at index len BEFORE checking len>NFSX_V2FH=32; 33 hex byte pairs overwrite 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; 33 hex byte pairs overwrite root_fh[32]=root_saddr.sin_len. Stack OOB write.