GHSA-7H2C-65CX-P93W
S/MIME Verifier trusts signatures made with any self-signed certificate when it has no trust anchors
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-7H2C-65CX-P93W divulgada · CVSS 7.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Impact
`Psl\MIME\SMIME\Verifier::verify()` checks the signer's certificate chain by default (`verifyCertificateChain: true`). When the verifier had no trust anchors, which is the constructor default (`new Verifier()`), this check accepted any signer certificate that is self-signed. The constructor documentation says that an empty list means no chain validation is possible, but the code treated every self-signed certificate as trusted instead of failing.
An attacker can create a self-signed certificate with any subject and email address, sign arbitrary content with it, and send it to the application. `verify()` returns a `VerificationResult` with `valid` set to `true` and the attacker's certificate as `signerCertificate`, so an application that treats `valid` as proof that a trusted party signed the content, or that compares the email address in the signer certificate with the sender, accepts forged content.
Applications are affected when they verify S/MIME or CMS signed data from untrusted sources with `Verifier` constructed without trusted certificates and chain verification left enabled. The attack is remote and needs no authentication or user interaction: the attacker only has to get a signed message to the application, for example by email. Applications that pass `verifyCertificateChain: false` never received a trust decision from the verifier and are not affected by this part.
A second, narrower flaw affected verifiers configured with trust anchors: the signer certificate only had to be signed directly by one of the trusted certificates, and its key usage and extended key usage were not checked. A certificate that a trusted CA issued for another purpose, such as a TLS server certificate, was accepted as an S/MIME signer. Exploiting this needs a certificate and private key issued by a configured CA.
Patches
Fixed in 6.4.0 https://github.com/php-standard-library/php-standard-library/releases/tag/6.4.0.
- An empty list of trusted certificates now fails chain verification instead of trusting self-signed certificates.
- The signer certificate is the one named by the identifier of the first `SignerInfo`, as RFC 5652 requires, instead of the first certificate embedded in the message.
- OpenSSL validates the chain against the configured trust anchors only (the system CA store is not consulted), building it through intermediates embedded in the message and checking validity periods, CA `basicConstraints` and the S/MIME signing purpose of the signer certificate.
- Verification now writes certificates to a private temporary directory, so it needs a writable `sys_get_temp_dir()` within `open_basedir`.
Workarounds
- Always construct `Verifier` with the certificates you trust, for example `new Verifier([$caCertificatePem])`. With a non-empty list, a self-signed certificate that is not in the list is rejected on affected versions.
- If a configured CA also issues certificates for other purposes, check the signer certificate after verification yourself, or pin the expected signers by comparing `openssl_x509_fingerprint($result->signerCertificate, 'sha256')` with a list of known fingerprints.
References
- RFC 5652 sections 5.3 and 10.2.4 (SignerInfo, SignerIdentifier and IssuerAndSerialNumber)
- RFC 5280 section 6 (certification path validation)
- RFC 8550 (S/MIME 4.0 certificate handling)
- https://github.com/php-standard-library/php-standard-library/releases/tag/6.4.0
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistphp-standard-library/mime |
Corregida | 6.4.0 | — | — |
Packagistphp-standard-library/php-standard-library |
Corregida | 6.4.0 | — | — |
6.4.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/php-standard-library/php-standard-library/security/advisories/GHSA-7h2c-65cx-p93wLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
