-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PKCS5_PBKDF1 buffer overflow #874
Comments
Another issue is the following #include <sha.h>
#include <pwdbased.h>
int main(void)
{
const unsigned char password[8] = { 0 };
const unsigned char salt[8] = { 0 };
::CryptoPP::PKCS5_PBKDF1<::CryptoPP::SHA1> pbkdf1;
pbkdf1.DeriveKey(
nullptr,
0,
0,
password,
sizeof(password),
salt,
sizeof(salt),
4);
return 0;
} (It is a nonsensical use of the API, but my fuzzer tries all parameter combinations) This causes memcpy(derived, buffer, derivedLen); in memcpy(NULL, buffer, 0); memcpy'ing to NULL even when the Something like this would be better: if ( derivedLen ) memcpy(derived, buffer, derivedLen); Or just return near the start of the function if |
Thanks for the find. Yeah, something looks odd with Here is Crypto++ 5.6.2 |
Cleared at Commit c0a5a06a8285 (pwdbased) and Commit e22700f741af (scrypt and hkdf). |
If you need to stretch a key, use |
Results in a buffer overflow in
PKCS5_PBKDF1<T>::DeriveKey
because:So with SHA1, 20 bytes are allocated, but because
derivedLen
is 714, (714-20)=694 too many bytes are copied.The text was updated successfully, but these errors were encountered: