Description
Crypt::NaCl::Sodium versions through 2.002 for Perl has potential integer overflows. bin2hex, encrypt, aes256gcm_encrypt_afternm and seal functions do not check that output size will be less than SIZE_MAX, which could lead to integer wraparound causing an undersized output buffer. Encountering this issue is unlikely as the message length would need to be very large. For bin2hex() the bin_len would have to be > SIZE_MAX / 2 For encrypt() the msg_len would need to be > SIZE_MAX - 16U For aes256gcm_encrypt_afternm() the msg_len would need to be > SIZE_MAX - 16U For seal() the enc_len would need to be > SIZE_MAX - 64U
Problem types
CWE-190 Integer Overflow or Wraparound
Product status
Any version
Credits
Brad Barden <perlmodules@5c30.org>
References
www.openwall.com/lists/oss-security/2026/03/08/1
metacpan.org/...GGE/Crypt-NaCl-Sodium-2.002/source/Sodium.xs
metacpan.org/...GGE/Crypt-NaCl-Sodium-2.002/source/Sodium.xs
metacpan.org/...GGE/Crypt-NaCl-Sodium-2.002/source/Sodium.xs
metacpan.org/...GGE/Crypt-NaCl-Sodium-2.002/source/Sodium.xs
github.com/cpan-authors/crypt-nacl-sodium/pull/24.patch
metacpan.org/...LEGGE/Crypt-NaCl-Sodium-2.003/source/Changes