diff mbox series

security: openssl: check all signer names

Message ID 20261009135235.399263-1-stefano.babic@swupdate.org
State Accepted
Headers show
Series security: openssl: check all signer names | expand

Commit Message

Stefano Babic Oct. 9, 2026, 1:52 p.m. UTC
Avoid to bypass the signer name. If a certificate of the same CA is
compromised, the attacker can sign with the compromised certificate even
if was not intended for updating the device. Because the result
is overwritten on each match, an attacker can append a certificate
carrying the expected CN after the compromised signer and the check passes.

This happens in the bad cases where a global PKI is used. No impact if the
trust store contains only update-signing certificates.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
---
 crypto/swupdate_cms_verify_openssl.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/crypto/swupdate_cms_verify_openssl.c b/crypto/swupdate_cms_verify_openssl.c
index 3a18e70b..ab4d255e 100644
--- a/crypto/swupdate_cms_verify_openssl.c
+++ b/crypto/swupdate_cms_verify_openssl.c
@@ -306,9 +306,12 @@  static int check_signer_name(CMS_ContentInfo *cms, const char *name)
 			if (CMS_SignerInfo_cert_cmp(si, crt) == 0) {
 				ret = check_common_name(
 					X509_get_subject_name(crt), name);
+				if (ret)
+					goto out_check_signer;
 			}
 		}
 	}
+out_check_signer:
 	sk_X509_pop_free(crts, X509_free);
 
 	return ret;