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

crypto.c: ensure we don't pass too large key size to CryptoNG #63

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

lstipakov
Copy link
Member

We use BCryptGenerateSymmetricKey() to generate a symmetric key object, passing a buffer containing a key and a key length. While buffer length is guaranteed not to exceed 32 bytes, the key length value is passed from userspace and could be at max 256 bytes.

The documentation says that:

If the data passed in exceeds the target key size, the data will be truncated and the excess will be ignored.

which means that passing large length should not be a problem. I confirmed it with test with driver verifier enabled - I passed "256" as key length and haven't got any errors (and got key objected created and VPN session set up).

Nevertheless, let's be good citizens and error out if passed key length exceeds 32 bytes - maximum key length for AES-GCM and ChaCha20 ciphers.

Bump version to 1.0.1.

Reported-by: Vladimir Tokarev vtokarev@microsoft.com

We use BCryptGenerateSymmetricKey() to generate a symmetric key object,
passing a buffer containing a key and a key length. While buffer length
is guaranteed not to exceed 32 bytes, the key length value is passed
from userspace and could be at max 256 bytes.

The documentation says that:

  If the data passed in exceeds the target key size, the data will be truncated and the excess will be ignored.

which means that passing large length should not be a problem. I confirmed
it with test with driver verifier enabled - I passed "256" as key length and
haven't got any errors (and got key objected created and VPN session set
up).

Nevertheless, let's be good citizens and error out if passed key length
exceeds 32 bytes - maximum key length for AES-GCM and ChaCha20 ciphers.

Bump version to 1.0.1.

Reported-by: Vladimir Tokarev <vtokarev@microsoft.com>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
@cron2
Copy link

cron2 commented Mar 18, 2024

Looks good to me.

@lstipakov lstipakov merged commit 9d4083c into OpenVPN:release/1 Mar 19, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants