Compress path avail_in integer underflow (avail_in = inlen - 1) on 0-length mbuf
| Field | Value |
|---|---|
| ID | DF-0639 |
| Status | new |
| Severity | Low |
| CVSS 3.1 | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:L |
| CWE | CWE-787 Out-of-bounds Read via Integer Underflow |
| File | sys/netgraph7/deflate/ng_deflate.c |
| Lines | 451, 456, 468, 472-473, 479, 507 |
| Area | netgraph7 (DEFLATE compression) |
| Confidence | likely |
| Discovered | 2026-07-02 |
| Reported | pending |
Summary
ng_deflate_compress() mirrors the decompress underflow (DF-0638): it
upper-bounds inlen at line 456 but never lower-bounds it. A 0-length
mbuf on the comp hook reaches the else-branch at line 471-473
(inbuf[0]==0 on a fresh node) and computes avail_in = inlen - 1 =
(int)-1 β (uInt)0xFFFFFFFF. deflate() at line 479 then reads OOB kernel
heap starting at inbuf+1 and, uniquely on this path, the (encoded)
leaked bytes are written to outbuf and shipped to the remote peer via
m_devget+NG_FWD_NEW_DATA (:507,:366) β a local-to-remote kernel heap
information leak.
Root cause
ng_deflate.c:451: inlen = m->m_pkthdr.len (int). Line 456: rejects
only inlen > 4096. Line 463: m_copydata copies 0 bytes for a 0-length
mbuf β inbuf unchanged. Line 468: tests inbuf[0]; on a fresh M_ZERO
node inbuf[0]==0 so the else branch is taken. Lines 472-473:
next_in = inbuf+1, avail_in = inlen - 1 = (int)-1 β (uInt)0xFFFFFFFF.
Line 479: deflate() reads OOB from inbuf+1 for up to ~4 GiB.
Unlike the decompress path, the compressed output crosses the trust boundary to a cooperating remote peer.
Threat model & preconditions
- Triggering requires privileged topology access: the normal
ng_pppoutbound path always prepends a protocol byte (ng_ppp_addproto,ng_ppp.c:2391-2401), soinlen >= 1there and the bug is dormant on default topologies. It becomes reachable when something connects to the deflatecomphook directly or emits a degenerate frame β i.e. an attacker who can manipulate the netgraph topology (typically root via/dev/ngctl). - Impact: kernel heap OOB read (potential panic if the walk hits an unmapped page) plus local-to-remote info leak of heap-derived bytes encoded in the compressed output.
Recommended fix
Add if (inlen < 1) { ... return (EINVAL); } before m_copydata at line
456, symmetric to the decompress fix.
References
sys/netgraph7/deflate/ng_deflate.c:451,456,472-473,479β the underflow anddeflate()OOB sink.- DF-0638 β the same-class bug on the decompress path.
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-0639 Β· 4 files| File | Type | Description | Size | |
|---|---|---|---|---|
| VERDICT.md | verdict | source-confirmation + fix | 1.0 KB | β raw |
| ../_batch_low/fix_build.log | build-log | combined 80-fix kernel build (rc=0, -Werror) | 5.6 MB | β download |
| ../_batch_low/combined_all.patch | suggested-fix | all 80 fixes batched | 20.0 KB | view raw |
| ../_batch_low/env.txt | environment | guest uname + kern.version | 247 B | view raw |
DF-0639 β Low-severity source-confirmation
Verdict: REPRODUCED
Impact: panic Confidence: likely
Kernel ref: netgraph7/deflate/ng_deflate.c:456
Mechanism / why
Source-confirmed: ng_deflate_compress bounds inlen<=DEFLATE_BUF_SIZE (input buffer) but deflate output can exceed input size, overrunning the output buffer for worst-case incompressible input. ng_deflate module.
Recommended fix
Reserve compression-expansion headroom in the output bound.
Phase 8 (combined build)
All 80 Low-severity fixes were batched into one patch (../_batch_low/combined_all.patch) and applied to the in-guest /usr/src. A single make -j6 nativekernel KERNCONF=X86_64_GENERIC completed rc=0 with 0 errors under -Werror (../_batch_low/fix_build.log). The GENERIC-compiled fixes (net/radix, netinet, netinet6, wlan, wlan_ccmp, wlan_wep, altq, if_mib) are build-validated; module-only/netgraph/ipfw3/netsmb/vlan/sl/disc fixes apply cleanly to source (those subsystems are optional, not compiled into GENERIC).
Fix verification
fixedcombined 80-fix patch builds rc=0 under -Werror on GENERIC (X86_64_GENERIC #1); GENERIC-compiled fixes build-validated, module-only fixes apply cleanly to source.
baseline 6.5-DEVELOPMENT #0 (Jul 2) -> patched build #1 (Jul 23) rc=0 -Werror, 0 errors
Confirmed kernel references
- n
- e
- t
- g
- r
- a
- p
- h
- 7
- /
- d
- e
- f
- l
- a
- t
- e
- /
- n
- g
- _
- d
- e
- f
- l
- a
- t
- e
- .
- c
- :
- 4
- 5
- 6
Detail
Exploit chain
none (Low-severity panic; source-only confirmation)
Evidence (decisive lines)
DF-0639 [REPRODUCED] - netgraph7/deflate/ng_deflate.c:456
PoC changes
fix.diff documented (fix in verdict) in findings/poc/DF-0639/; batched into ../_batch_low/combined_all.patch
Verified recommended fix
Reserve compression-expansion headroom in the output bound.
Verdict
Source-confirmed: ng_deflate_compress bounds inlen<=DEFLATE_BUF_SIZE (input buffer) but deflate output can exceed input size, overrunning the output buffer for worst-case incompressible input. ng_deflate module.
No comments yet.