summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pkcs12
diff options
context:
space:
mode:
authortb <>2026-01-27 14:14:20 +0000
committertb <>2026-01-27 14:14:20 +0000
commit80b52a32d57440334a364d1c23155c87f46f2831 (patch)
tree0ae654b4575cd737892f8c973cbede6465a39386 /src/lib/libcrypto/pkcs12
parent81617536ce695a5b2c65926fbe0b3b14466d95b6 (diff)
downloadopenbsd-80b52a32d57440334a364d1c23155c87f46f2831.tar.gz
openbsd-80b52a32d57440334a364d1c23155c87f46f2831.tar.bz2
openbsd-80b52a32d57440334a364d1c23155c87f46f2831.zip
Avoid type confusion in PKCS#12 parsing
A type confusion can lead to a 1-byte read at address 0x00-0xff, so a crash. Reported by Luigino Camastra, fix by Bob Beck, via OpenSSL, CVE 2025-22795 ok jsing
Diffstat (limited to 'src/lib/libcrypto/pkcs12')
-rw-r--r--src/lib/libcrypto/pkcs12/p12_kiss.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/libcrypto/pkcs12/p12_kiss.c b/src/lib/libcrypto/pkcs12/p12_kiss.c
index f6f09ff2de..4324201598 100644
--- a/src/lib/libcrypto/pkcs12/p12_kiss.c
+++ b/src/lib/libcrypto/pkcs12/p12_kiss.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_kiss.c,v 1.29 2025/05/10 05:54:38 tb Exp $ */ 1/* $OpenBSD: p12_kiss.c,v 1.30 2026/01/27 14:14:20 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999. 3 * project 1999.
4 */ 4 */
@@ -231,11 +231,17 @@ parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen, EVP_PKEY **pkey,
231 ASN1_BMPSTRING *fname = NULL; 231 ASN1_BMPSTRING *fname = NULL;
232 ASN1_OCTET_STRING *lkid = NULL; 232 ASN1_OCTET_STRING *lkid = NULL;
233 233
234 if ((attrib = PKCS12_SAFEBAG_get0_attr(bag, NID_friendlyName))) 234 if ((attrib = PKCS12_SAFEBAG_get0_attr(bag, NID_friendlyName))) {
235 if (attrib->type != V_ASN1_BMPSTRING)
236 return 0;
235 fname = attrib->value.bmpstring; 237 fname = attrib->value.bmpstring;
238 }
236 239
237 if ((attrib = PKCS12_SAFEBAG_get0_attr(bag, NID_localKeyID))) 240 if ((attrib = PKCS12_SAFEBAG_get0_attr(bag, NID_localKeyID))) {
241 if (attrib->type != V_ASN1_OCTET_STRING)
242 return 0;
238 lkid = attrib->value.octet_string; 243 lkid = attrib->value.octet_string;
244 }
239 245
240 switch (OBJ_obj2nid(bag->type)) { 246 switch (OBJ_obj2nid(bag->type)) {
241 case NID_keyBag: 247 case NID_keyBag: