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

Missing bounds check on ivlen in cryptoapi_cipher_encrypt/decrypt (latent stack buffer overflow)

Summary

cryptoapi_cipher_encrypt/decrypt at cryptoapi.c:1124/1143: stack-local cryptoapi_cipher_iv iv2 (16 bytes, CRYPTOAPI_MAX_IV_LEN=16) then memcpy(iv2, iv, ivlen) with NO bounds check on ivlen (int). ivlen>16 -> stack overflow; ivlen<0 -> huge size_t OOB read. Sole consumer dm_target_crypt passes sizeof(cryptoapi_cipher_iv)=16 always (dm_target_crypt.c:361,980) and dm-table ioctl requires privilege. cryptoapi_cipher_newsession validates cipher->ivsize<=16 at session creation but NOT runtime ivlen arg. Public API in cryptoapi.h:78-86 with no documented upper bound. Fix: if (ivlen<0 || ivlen>(int)sizeof(iv2)) return EINVAL.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-0964 Β· 1 files
FileTypeDescriptionSize
fix.diff suggested-fix Missing bounds check on ivlen in cryptoapi_cipher_encrypt/decrypt (latent stack 362 B view raw

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

fix.diff applied + combined nativekernel build rc=0 (-Werror)

fix.diff applied + combined nativekernel build rc=0 (-Werror)
↓ fix.diffcombined build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none (Info severity)

Evidence (decisive lines)

Source-confirmed at sys/crypto/cryptoapi/cryptoapi.c:1118: missing bounds check on ivlen (latent stack buffer overflow)

Verified recommended fix

Source-confirmed at sys/crypto/cryptoapi/cryptoapi.c:1118: missing bounds check on ivlen (latent stack buffer overflow)

Verdict

Source-confirmed at sys/crypto/cryptoapi/cryptoapi.c:1118: missing bounds check on ivlen (latent stack buffer overflow)