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)
PoC verification
Evidence pack
findings/poc/DF-0964 Β· 1 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | Missing bounds check on ivlen in cryptoapi_cipher_encrypt/decrypt (latent stack | 362 B | view raw |
Fix verification
fixedfix.diff applied + combined nativekernel build rc=0 (-Werror)
fix.diff applied + combined nativekernel build rc=0 (-Werror)
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)
No comments yet.