Multiple Vulnerabilities in OpenPGP.js

Project Description

In the course of a project aimed at improving the browser plugin “Mailvelope” SEC Consult was tasked by the German Bundesamt für Sicherheit in der Informationstechnik (BSI) with conducting a security audit of the Mailvelope and OpenPGP.js software. During this engagement several vulnerabilities were found, that e.g. in specific scenarios could have allowed an attacker to steal a victim’s private key.


Vendor description

“This project aims to provide an Open Source OpenPGP library in JavaScript so it can be used on virtually every device. Instead of other implementations that are aimed at using native code, OpenPGP.js is meant to bypass this requirement (i.e. people will not have to install gpg on their machines in order to use the library). The idea is to implement all the needed OpenPGP functionality in a JavaScript library that can be reused in other projects that provide browser extensions or server applications. It should allow you to sign, encrypt, decrypt, and verify any kind of text – in particular e-mails – as well as managing keys.”

Source: https://openpgpjs.org

 

Business recommendation

SEC Consult was tasked by the German Bundesamt für Sicherheit in der Informationstechnik (BSI) with conducting a security audit of the Mailvelope browser extension as well as the parts of OpenPGP.js used by Mailvelope. During the course of this audit multiple security vulnerabilities with severities ranging from minor to critical have been identified. Some of the vulnerabilities with higher severity are published as an advisory. A more detailed description of the vulnerabilities as well as a description of other vulnerabilities found during this project can be found in the report that has been made available by the BSI:

https://www.bsi.bund.de/[…]/Publications/Studies/Mailvelope_Extensions/Mailvelope_Extensions_pdf.html

 

Vulnerability overview/description

1) Message Signature Bypass (CVE-2019-9153)

OpenPGP defines several types of signatures with each type carrying a different semantic. Signatures are implemented as packets and each signature packet can contain subpackets.

To indicate a message signature (e.g. a signed e-mail), the signature type “text” is used. The text signature packet verifies both its subpackets as well as the signed text.

During verification of a message signature, OpenPGP.js does not verify that the signature is of type text. An attacker could therefore construct a message that, instead of a text signature, contains a signature of another type. As the input required for the verification process depends on the signature type, an attacker could use a signature with a type that only verifies its subpackets and does not require additional input.

An attacker could construct a message that contains a valid “standalone” or “timestamp” signature packet signed by another person. OpenPGP.js would incorrectly assume this message to be signed by that person.

2) Information from Unhashed Subpackets is Trusted (CVE-2019-9154)

OpenPGP signature subpackets contain information related to a signature (e.g. the creation timestamp). These subpackets may appear in a “hashed” and “unhashed” subpacket container. While the information in the hashed subpackets is signed, the unhashed subpackets are not cryptographically protected. OpenPGP.js however does not distinguish between these subpackets. When parsing a signature packet, the signed information is parsed first. When the unhashed packets are read, the information from the hashed packets is overwritten.

An attacker could arbitrarily modify the contents of e.g. a key certification signature or revocation signature. As a result, the attacker could e.g. convince a victim to use an obsolete key for encryption.

3) Invalid Curve Attack (CVE-2019-9155)

The implementation of the Elliptic Curve Diffie-Hellman (ECDH) key exchange algorithm does not verify that the communication partner’s public key is valid (i.e. that the point lies on the elliptic curve). This causes the application to implicitly calculate the resulting secret key not based on the specified elliptic curve but rather an altered curve. By carefully choosing multiple altered curves (and therefore the resulting public key), and observing whether decryption fails, an attacker can extract the victim’s private key.

This attack requires the attacker to be able to provide multiple manipulated messages and to observe whether decryption fails.

Proof of concept

1) Message Signature Bypass (CVE-2019-9153)

The script message_signature_bypass.js (see below) demonstrates this issue. The function fakeSignature reads a signed message and replaces its content. It then replaces the signature with a standalone signature of the victim.

Source code (SEC_Consult_BSI_Mailvelope-signature_bypass.js)

2) Information from Unhashed Subpackets is Trusted (CVE-2019-9154)

The script unsigned_subpackets.js demonstrates this issue. It parses an expired key and adds additional unhashed subpackets that specify a different key expiration. When this newly-created key is parsed, it can be used for encrypting messages.

Source code (SEC_Consult_BSI_Mailvelope-unsigned_subpackets.js)

3) Invalid Curve Attack (CVE-2019-9155)

The script in invalid_curve_attack.js demonstrates this issue. Note that since OpenPGP uses only the x-coordinate of the secret point, the oracle succeeds both when it calculates the same point as the attacker or when it calculates its inverse point. Therefore, the Chinese Remainder Theorem cannot be directly applied to the result. Instead, the script demonstrates that the remainders of the private key matches the corresponding gathered remainder. In order to fully implement this attack, an attacker could verify the results using other public key points with a non-prime order.

Source code (SEC_Consult_BSI_Mailvelope-invalid_curve_attack.js)

Vulnerable / tested versions:

The version 4.1.2 was found to be vulnerable. The Invalid Curve attack is also viable against version 4.2.0.

Vendor contact timeline

Vendor communication was conducted by the BSI as well as their contractors.

Solution

Upgrade to the latest version of OpenPGP.js.

Workaround

None.

 

Advisory URL

https://www.sec-consult.com/en/vulnerability-lab/advisories/index.html

 

EOF Wolfgang Ettlinger / @2019

 

Interested to work with the experts of SEC Consult? Send us your application.
Want to improve your own cyber security with the experts of SEC Consult?
Contact our local offices.

Project Details

  • TitleMultiple vulnerabilities
  • ProductOpenPGP.js
  • Vulnerable version<=4.2.0
  • Fixed version4.3.0
  • CVE numberCVE-2019-9153, CVE-2019-9154, CVE-2019-9155
  • Impactcritical
  • Homepagehttps://openpgpjs.org
  • Found2018-2019
  • ByWolfgang Ettlinger (Office Vienna) | SEC Consult Vulnerability Lab

Cookie Preference

Please select an option. You can find more information about the consequences of your choice at Help.

Select an option to continue

Your selection was saved!

Help

Help

To continue, you must make a cookie selection. Below is an explanation of the different options and their meaning.

  • Accept all cookies:
    All cookies such as tracking and analytics cookies.
  • Accept first-party cookies only:
    Only cookies from this website.
  • Reject all tracking cookies:
    No cookies except for those necessary for technical reasons are set.

You can change your cookie setting here anytime: Blog. Blog

Back