CVE-2023-41037
JSON

4.3medium

Cleartext Signed Message Signature Spoofing in openpgpjs

Severity
4.3medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.35% (higher than 31% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-ch3c-v47x-4pgp

Description

OpenPGP.js is a JavaScript implementation of the OpenPGP protocol. In affected versions OpenPGP Cleartext Signed Messages are cryptographically signed messages where the signed text is readable without special tools. These messages typically contain a "Hash: ..." header declaring the hash algorithm used to compute the signature digest. OpenPGP.js up to v5.9.0 ignored any data preceding the "Hash: ..." texts when verifying the signature. As a result, malicious parties could add arbitrary text to a third-party Cleartext Signed Message, to lead the victim to believe that the arbitrary text was signed. A user or application is vulnerable to said attack vector if it verifies the CleartextMessage by only checking the returned `verified` property, discarding the associated `data` information, and instead _visually trusting_ the contents of the original message. Since `verificationResult.data` would always contain the actual signed data, users and apps that check this information are not vulnerable. Similarly, given a CleartextMessage object, retrieving the data using `getText()` or the `text` field returns only the contents that are considered when verifying the signature. Finally, re-armoring a CleartextMessage object (using `armor()` will also result in a "sanitised" version, with the extraneous text being removed. This issue has been addressed in version 5.10.1 (current stable version) which will reject messages when calling `openpgp.readCleartextMessage()` and in version 4.10.11 (legacy version) which will will reject messages when calling `openpgp.cleartext.readArmored()`. Users are advised to upgrade. Users unable to upgrade should check the contents of `verificationResult.data` to see what data was actually signed, rather than visually trusting the contents of the armored message.

Affected

Product or packageVersionsReported by
openpgpjs openpgpjs< 4.10.11, >= 5.0.0, < 5.10.1, before 4.10.11, from 5.0.0 before 5.10.0CVE List, NVD
openpgp (npm)before 4.10.11, from 5.0.0 before 5.10.1GitHub Advisory Database

All scores

GitHub_M4.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N
GitHub4.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N
NVD4.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N

Classification

CWE-347

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

OpenPGP.js is a JavaScript implementation of the OpenPGP protocol. In affected versions OpenPGP Cleartext Signed Messages are cryptographically signed messages where the signed text is readable without special tools. These messages typically contain a "Hash: ..." header declaring the hash algorithm used to compute the signature digest. OpenPGP.js up to v5.9.0 ignored any data preceding the "Hash: ..." texts when verifying the signature. As a result, malicious parties could add arbitrary text to a third-party Cleartext Signed Message, to lead the victim to believe that the arbitrary text was signed. A user or application is vulnerable to said attack vector if it verifies the CleartextMessage by only checking the returned `verified` property, discarding the associated `data` information, and instead _visually trusting_ the contents of the original message. Since `verificationResult.data` would always contain the actual signed data, users and apps that check this information are not vulnerable. Similarly, given a CleartextMessage object, retrieving the data using `getText()` or the `text` field returns only the contents that are considered when verifying the signature. Finally, re-armoring a CleartextMessage object (using `armor()` will also result in a "sanitised" version, with the extraneous text being removed. This issue has been addressed in version 5.10.1 (current stable version) which will reject messages when calling `openpgp.readCleartextMessage()` and in version 4.10.11 (legacy version) which will will reject messages when calling `openpgp.cleartext.readArmored()`. Users are advised to upgrade. Users unable to upgrade should check the contents of `verificationResult.data` to see what data was actually signed, rather than visually trusting the contents of the armored message.

GitHub Advisory Database
Impact

OpenPGP Cleartext Signed Messages are cryptographically signed messages where the signed text is readable without special tools:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

This text is signed.
-----BEGIN PGP SIGNATURE-----

wnUEARMIACcFgmTkrNAJkInXCgj0fgcIFiEE1JlKzzDGQxZmmHkYidcKCPR+
BwgAAKXDAQDWGhI7tPbhB+jlKwe4+yPJ+9X8aWDUG60XFNi/w8T7ZgEAsAGd
WJrkm/H5AXGZsqyqqO6IWGF0geTCd4mWm/CsveM=
-----END PGP SIGNATURE-----

These messages typically contain a "Hash: ..." header declaring the hash algorithm used to compute the signature digest. OpenPGP.js up to v5.9.0 ignored any data preceding the "Hash: ..." texts when verifying the signature. As a result, malicious parties could add arbitrary text to a third-party Cleartext Signed Message, to lead the victim to believe that the arbitrary text was signed.

A user or application is vulnerable to said attack vector if it verifies the CleartextMessage by only checking the returned verified property, discarding the associated data information, and instead visually trusting the contents of the original message:

const cleartextMessage = `
-----BEGIN PGP SIGNED MESSAGE-----
This text is not signed but you might think it is. Hash: SHA256

This text is signed.
-----BEGIN PGP SIGNATURE-----

wnUEARMIACcFgmTkrNAJkInXCgj0fgcIFiEE1JlKzzDGQxZmmHkYidcKCPR+
BwgAAKXDAQDWGhI7tPbhB+jlKwe4+yPJ+9X8aWDUG60XFNi/w8T7ZgEAsAGd
WJrkm/H5AXGZsqyqqO6IWGF0geTCd4mWm/CsveM=
-----END PGP SIGNATURE-----
`;
const message = await openpgp.readCleartextMessage({ cleartextMessage });
const verificationResult = await verifyCleartextMessage({ message, verificationKeys });
console.log(await verificationResult.verified); // output: true
console.log(verificationResult.data); // output: 'This text is signed.'

Since verificationResult.data would always contain the actual signed data, users and apps that check this information are not vulnerable. Similarly, given a CleartextMessage object, retrieving the data using getText() or the text field returns only the contents that are considered when verifying the signature. Finally, re-armoring a CleartextMessage object (using armor() will also result in a "sanitised" version, with the extraneous text being removed. Because of this, we consider the vulnerability impact to be very limited when the CleartextMessage is processed programmatically; this is reflected in the Severity CVSS assessment, specifically in the scope's score ("Unchanged").

Patches
  • v5.10.1 (current stable version) will reject messages when calling openpgp.readCleartextMessage()
  • v4.10.11 (legacy version) will reject messages when calling openpgp.cleartext.readArmored()
Workarounds

Check the contents of verificationResult.data to see what data was actually signed, rather than visually trusting the contents of the armored message.

References

Similar CVE: https://sec-consult.com/vulnerability-lab/advisory/cleartext-message-spoofing-in-go-cryptography-libraries-cve-2019-11841/

NVD (es)

OpenPGP.js es una implementación JavaScript del protocolo OpenPGP. En las versiones afectadas, los Mensajes Firmados en Texto Claro de OpenPGP son mensajes firmados criptográficamente donde el texto firmado es legible sin herramientas especiales. Estos mensajes suelen contener una cabecera 'Hash: ...' que declara el algoritmo hash utilizado para calcular el resumen de la firma. OpenPGP.js hasta la v5.9.0 ignoraba cualquier dato que precediera a los textos 'Hash: ...' al verificar la firma. Como resultado, partes maliciosas podrían añadir texto arbitrario a un Mensaje Firmado en Texto Claro de terceros, para hacer creer a la víctima que el texto arbitrario estaba firmado. Un usuario o aplicación es vulnerable a dicho vector de ataque si verifica el CleartextMessage comprobando únicamente la propiedad `verified` devuelta, descartando la información `data` asociada, y en su lugar _confiando visualmente_ en el contenido del mensaje original. Dado que `verificationResult.data` siempre contendría los datos firmados reales, los usuarios y las aplicaciones que comprueban esta información no son vulnerables. De manera similar, dado un objeto CleartextMessage, la recuperación de los datos utilizando `getText()` o el campo `text` devuelve solo el contenido que se considera al verificar la firma. Finalmente, volver a 'armar' un objeto CleartextMessage (utilizando `armor()`) también resultará en una versión 'sanitizada', con el texto extraño eliminado. Este problema se ha solucionado en la versión 5.10.1 (versión estable actual) que rechazará los mensajes al llamar a `openpgp.readCleartextMessage()` y en la versión 4.10.11 (versión heredada) que rechazará los mensajes al llamar a `openpgp.cleartext.readArmored()`. Se aconseja a los usuarios que actualicen. Los usuarios que no puedan actualizar deberían comprobar el contenido de `verificationResult.data` para ver qué datos fueron realmente firmados, en lugar de confiar visualmente en el contenido del mensaje 'armado'.

References

Sources

SourceRecordLicence
CVE ListCVE-2023-41037 changed 2024-09-30CVE Terms of Use
GitHub Advisory DatabaseGHSA-ch3c-v47x-4pgp changed 2023-11-08CC-BY-4.0
NVDCVE-2023-41037 changed 2026-06-17Public domain