diff options
| author | tb <> | 2026-06-09 12:20:34 +0000 |
|---|---|---|
| committer | tb <> | 2026-06-09 12:20:34 +0000 |
| commit | 256315fc6aeff5ec985bfee63fae84e6cafc4555 (patch) | |
| tree | eab66af56feeb7a13e946aabb054007314e50783 /src/lib | |
| parent | 77ad4436cc0876666030d6cc1ca6e7be853ef788 (diff) | |
| download | openbsd-256315fc6aeff5ec985bfee63fae84e6cafc4555.tar.gz openbsd-256315fc6aeff5ec985bfee63fae84e6cafc4555.tar.bz2 openbsd-256315fc6aeff5ec985bfee63fae84e6cafc4555.zip | |
Avoid out-of-bounds read in CMS password-based decryption
The RFC 3211 PWRI integrity check when unwrapping the password-derived key
accesses seven bytes from a heap-allocated buffer. If an (invalid) block
cipher with short blocks is in use 2 * blocksize may not be sufficient room
for 7 bytes. In that silly case, the function performs an OOB read. Add
length check to avoid this situation
From Igor Ustinov via OpenSSL.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/libcrypto/cms/cms_pwri.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/libcrypto/cms/cms_pwri.c b/src/lib/libcrypto/cms/cms_pwri.c index d282d1d42f..36a53568d1 100644 --- a/src/lib/libcrypto/cms/cms_pwri.c +++ b/src/lib/libcrypto/cms/cms_pwri.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: cms_pwri.c,v 1.36 2026/06/09 12:12:34 tb Exp $ */ | 1 | /* $OpenBSD: cms_pwri.c,v 1.37 2026/06/09 12:20:34 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 4 | * project. | 4 | * project. |
| @@ -232,6 +232,10 @@ kek_unwrap_key(unsigned char *out, size_t *outlen, const unsigned char *in, | |||
| 232 | unsigned char *tmp; | 232 | unsigned char *tmp; |
| 233 | int outl, rv = 0; | 233 | int outl, rv = 0; |
| 234 | 234 | ||
| 235 | /* Ensure inlen is large enough that tmp[6] is in bounds. */ | ||
| 236 | if (blocklen < 4) | ||
| 237 | return 0; | ||
| 238 | |||
| 235 | if (inlen < 2 * blocklen) { | 239 | if (inlen < 2 * blocklen) { |
| 236 | /* too small */ | 240 | /* too small */ |
| 237 | return 0; | 241 | return 0; |
