rc4_init reads key[0] before bounds check when keylen==0 (OOB read / NULL deref)
Summary
rc4_init KSA loop at rc4.c:72 derefs key[k] BEFORE bounds check at :74 (if(++k>=keylen) k=0). With keylen==0: k stays 0, key[0] read 256 times. Zero-length alloc -> 1-byte heap OOB read folded into permutation -> keystream corruption. key==NULL -> NULL deref panic. Docstring at :56 advertises arbitrary length including 0. Public kernel-exported symbol (rc4.h:49, rc4.ko module). No in-tree caller triggers it: ng_mppc.c KEYLEN(bits) always 8 or 16. Latent for future kld modules. Fix: if (keylen<=0) return; at entry.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-0971 Β· 2 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | git-apply-able fix for the cited path | 438 B | view raw |
| VERDICT.md | verdict | source-confirmation narrative | 975 B | β raw |
DF-0971 source-confirmation
Verdict: REPRODUCED (source-confirmed)
Impact: leak Confidence: likely
Kernel ref: sys/crypto/rc4/rc4.c:72
Mechanism
rc4_init reads key[0] before keylen check; keylen==0 -> 256x OOB read (latent)
Confirmation method
Source-trace confirmed the cited code path matches the finding (exact line/condition
verified against sys/). Runtime PoC not exercised for this source-only Low-severity
item; confirmation is by code inspection.
Recommended fix
See fix.diff in this folder (git-apply-able unified diff).
Phase 8 (combined build)
All 64 fixes were batched into one combined patch
(../_batch/combined_64.patch) and applied to in-guest /usr/src. A single
make -j6 nativekernel KERNCONF=X86_64_GENERIC completed rc=0 with 0 errors under
-Werror (../_batch/fix_build.log, 35374 lines). The GENERIC kernel + all modules
(drm, firewire, usb, netgraph, smbfs, fuse, crypto, vm, pmap) compiled clean.
Fix verification
not_testablenot_testable (source-only): no runtime PoC exercised; fix.diff applies cleanly and the combined single nativekernel build of all 64 fixes completed rc=0 with 0 errors under -Werror (findings/poc/_batch/fix_build.log). Bug source-confirmed in baseline tree. Compile-validation of the fix is the requested Phase-8 deliverable for this batch.
combined build: '=== NK_DONE rc=0 ===' and '>>> Kernel build for X86_64_GENERIC completed on Thu Jul 23 09:17:55 UTC 2026' (0 'error:' lines in 35374-line log).
Confirmed kernel references
- s
- y
- s
- /
- c
- r
- y
- p
- t
- o
- /
- r
- c
- 4
- /
- r
- c
- 4
- .
- c
- :
- 7
- 2
Detail
Exploit chain
none (non-corruption / source-only confirmation; no memory-corruption escalation chain developed for this Low-severity item)
Evidence (decisive lines)
source-only: rc4_init reads key[0] before keylen check; keylen==0 -> 256x OOB read (latent) @ sys/crypto/rc4/rc4.c:72. Combined fix build: '=== NK_DONE rc=0 ===' / 'Kernel build for X86_64_GENERIC completed', 0 errors under -Werror (findings/poc/_batch/fix_build.log).
PoC changes
authored git-apply-able fix.diff targeting the cited line; source-trace verified the vulnerable path. Evidence pack (VERDICT.md, manifest.json, env.txt, fix.diff) in findings/poc/DF-0971/.
Verified recommended fix
return early if keylen<=0 before the KSA loop. matches finding proposal. Full diff in findings/poc/DF-0971/fix.diff.
Verdict
REPRODUCED (source-confirmed). Source-trace confirmed rc4_init reads key[0] before keylen check; keylen==0 -> 256x OOB read (latent) at sys/crypto/rc4/rc4.c:72 against the audited sys/ tree; exact line/condition verified.
No comments yet.