openssl/crypto/x509
David Benjamin 08cecb4448 Add X509_STORE_get1_objects
X509_STORE_get0_objects returns a pointer to the X509_STORE's storage,
but this function is a bit deceptive. It is practically unusable in a
multi-threaded program. See, for example, RUSTSEC-2023-0072, a security
vulnerability caused by this OpenSSL API.

One might think that, if no other threads are mutating the X509_STORE,
it is safe to read the resulting list. However, the documention does not
mention that other logically-const operations on the X509_STORE, notably
certifcate verifications when a hash_dir is installed, will, under a
lock, write to the X509_STORE. The X509_STORE also internally re-sorts
the list on the first query.

If the caller knows to call X509_STORE_lock and X509_STORE_unlock, it
can work around this. But this is not obvious, and the documentation
does not discuss how X509_STORE_lock is very rarely safe to use. E.g.
one cannot call any APIs like X509_STORE_add_cert or
X509_STORE_CTX_get1_issuer while holding the lock because those
functions internally expect to take the lock. (X509_STORE_lock is
another such API which is not safe to export as public API.)

Rather than leave all this to the caller to figure out, the API should
have returned a shallow copy of the list, refcounting the values. Then
it could be internally locked and the caller can freely inspect the
result without synchronization with the X509_STORE.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23224)
2024-01-15 16:29:54 +01:00
..
build.info Support all NULL-syntax X.509v3 extensions 2023-09-25 15:12:04 -04:00
by_dir.c
by_file.c Fix loading more than one certificate in PEM format in X509_load_cert_file_ex() 2023-12-04 09:52:12 +01:00
by_store.c
ext_dat.h Copyright year updates 2023-09-28 14:23:29 +01:00
pcy_cache.c
pcy_data.c
pcy_lib.c
pcy_local.h
pcy_map.c
pcy_node.c
pcy_tree.c
standard_exts.h Copyright year updates 2023-09-28 14:23:29 +01:00
t_crl.c
t_req.c x509_print_ex: Remove unused setting when XN_FLAG_COMPAT is set 2023-10-26 15:48:00 +01:00
t_x509.c x509_print_ex: Remove unused setting when XN_FLAG_COMPAT is set 2023-10-26 15:48:00 +01:00
v3_addr.c Validate config options during x509 extension creation 2024-01-05 13:20:34 -05:00
v3_admis.c "foo * bar" should be "foo *bar" 2023-09-11 10:15:30 +02:00
v3_admis.h
v3_akeya.c
v3_akid.c
v3_asid.c Validate config options during x509 extension creation 2024-01-05 13:20:34 -05:00
v3_bcons.c
v3_bitst.c
v3_conf.c
v3_cpols.c
v3_crld.c Validate config options during x509 extension creation 2024-01-05 13:20:34 -05:00
v3_enum.c
v3_extku.c
v3_genn.c
v3_group_ac.c Support all NULL-syntax X.509v3 extensions 2023-09-25 15:12:04 -04:00
v3_ia5.c
v3_ind_iss.c Support all NULL-syntax X.509v3 extensions 2023-09-25 15:12:04 -04:00
v3_info.c
v3_int.c
v3_ist.c Removed logically dead code from function i2r_issuer_sign_tool 2024-01-15 08:55:06 -05:00
v3_lib.c
v3_ncons.c
v3_no_ass.c Support all NULL-syntax X.509v3 extensions 2023-09-25 15:12:04 -04:00
v3_no_rev_avail.c Support all NULL-syntax X.509v3 extensions 2023-09-25 15:12:04 -04:00
v3_pci.c
v3_pcia.c
v3_pcons.c
v3_pku.c
v3_pmaps.c
v3_prn.c
v3_purp.c
v3_san.c Fix a possible memory leak in do_othername 2023-12-12 13:43:08 +01:00
v3_single_use.c Support all NULL-syntax X.509v3 extensions 2023-09-25 15:12:04 -04:00
v3_skid.c
v3_soa_id.c Support all NULL-syntax X.509v3 extensions 2023-09-25 15:12:04 -04:00
v3_sxnet.c Fix a similar memory leak in SXNET_add_id_INTEGER 2024-01-10 17:59:53 +01:00
v3_tlsf.c
v3_utf8.c
v3_utl.c
v3err.c
x509_att.c Allow duplicate CMS attributes 2024-01-03 12:41:31 +01:00
x509_cmp.c
x509_d2.c
x509_def.c
x509_err.c
x509_ext.c
x509_local.h
x509_lu.c Add X509_STORE_get1_objects 2024-01-15 16:29:54 +01:00
x509_meth.c
x509_obj.c
x509_r2x.c
x509_req.c Add missing documentation for X509_ATTRIBUTE related functions. 2024-01-03 12:50:54 +01:00
x509_set.c
x509_trust.c
x509_txt.c
x509_v3.c
x509_vfy.c
x509_vpm.c
x509cset.c
x509name.c
x509rset.c
x509spki.c
x509type.c
x_all.c
x_attrib.c
x_crl.c
x_exten.c
x_name.c
x_pubkey.c
x_req.c
x_x509.c
x_x509a.c