DragonFlyBSD Kernel Audit
← triage · dashboard
DF-2364

Silent 64-bit->32-bit length truncation when invoking chacha_encrypt_bytes

Summary

_chacha20poly1305_update and _chacha20poly1305_final typed with size_t in_len but pass directly to chacha_encrypt_bytes(...uint32_t bytes). Implicit narrowing silently truncates lengths>=2^32 while poly1305_update (size_t bytes) does NOT truncate producing internal inconsistency where MAC covers more data than encrypted. For in_len>=2^32 keystream generated for only low 32 bits while MAC computed over full length breaking AEAD invariant. All current callers bounded well under 2^32 (WireGuard fixed sizes mbuf pkthdr.len int32). Latent API misuse risk for future >4GiB caller.

Discussion (0)

No comments yet.