Skip to content
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

Undersized SipHash key leads to buffer out-of-bounds read #947

Closed
guidovranken opened this issue May 4, 2020 · 2 comments
Closed

Undersized SipHash key leads to buffer out-of-bounds read #947

guidovranken opened this issue May 4, 2020 · 2 comments
Labels

Comments

@guidovranken
Copy link

#include <seckey.h>
#include <siphash.h>

int main(void)
{
    const uint8_t key[3] = { 0 };
    ::CryptoPP::SipHash<2, 4, false> siphash(key, sizeof(key));
    return 0;
}

I think it would be more appropriate to throw an exception in this case?

@noloader
Copy link
Collaborator

noloader commented May 4, 2020

Thanks @guidovranken.

Can you give Commit d6a5b7664bde a try?

diff --git a/siphash.h b/siphash.h
index 76dcccf6..4ffe1b50 100644
--- a/siphash.h
+++ b/siphash.h
@@ -148,7 +148,8 @@ public:
        /// \param key a byte array used to key the cipher
        /// \param length the size of the byte array, in bytes
        SipHash(const byte *key, unsigned int length)
-               {this->UncheckedSetKey(key, length, g_nullNameValuePairs);}
+               {this->ThrowIfInvalidKeyLength(length);
+                this->UncheckedSetKey(key, length, g_nullNameValuePairs);}
 };

 template <unsigned int C, unsigned int D, bool T_128bit>

@guidovranken
Copy link
Author

Thank you, confirmed fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants