A vulnerability in LibKSBA allows code execution in GnuPG

vulnerability

If exploited, these flaws can allow attackers to gain unauthorized access to sensitive information or generally cause problems

It was recently announced that a critical vulnerability (already cataloged under CVE-2022-3515 and for which a solution has been found) was identified in the LibKSBA library , developed by the GnuPG project and which provides functions for working with X.509 certificates.

The flaw found causes an integer overflow and the writing of arbitrary data outside the allocated buffer when parsing ASN .1 structures used in S/MIME, X.509 and CMS.

What makes this vulnerability "critical" is that the problem is exacerbated by the fact that the Libksba library is used in the GnuPG package, and the vulnerability could lead to remote execution of the attacker's code when GnuPG (gpgsm) processes encrypted or signed data from files or email messages using S/MIME. In the simplest case, to attack a victim using an email client that supports GnuPG and S/MIME, it is enough to send an email with a special format.

A serious bug has been found in Libksba , the library used by GnuPG to parse ASN.1 structures as used by S/MIME. 

The vulnerability could also be used to attack dirmngr servers that download and parse certificate revocation lists (CRLs) and verify certificates used in TLS. A web server controlled by an attacker can carry out a dirmngr attack by returning specially crafted CRLs or certificates.

It should be noted that publicly available exploits for gpgsm and dirmngr have not yet been identified , but the vulnerability is typical and nothing prevents skilled attackers from preparing an exploit of their own.

The main user of Libksba is gpgsm , the S/MIME cousin of gpg . There it is used to analyze all kinds of input data, in particular, signed or encrypted data in files or emails. Therefore, feeding a user malicious data can be easily achieved.

A second user of Libksba is dirmngr , which is responsible for loading and parsing certificate revocation lists (CRLs) and verifying certificates used by TLS (ie https connections). Mounting an attack is a bit more complex, but it can still be easily done by using a rogue web server to serve a Directory of web keys, certificates, or CRLs.

The following areas are reported as affected by the vulnerability:

  • Most software using Libksba versions up to 1.6.1
  • All versions of Gpg4win from version 2.0.0 to 4.0.3
  • All versions of GnuPG VS-Desktop® from 3.1.16 to 3.1.24
  • All GnuPG installers for Windows from version 2.3.0 to 2.3.7
  • All GnuPG LTS installers for Windows from version 2.1.0 to 2.2.39

As mentioned at the beginning, the vulnerability has already been fixed in Libksba version 1.6.2 and in the GnuPG 2.3.8 binary builds, since a grace period is given after the flaw was reported so that the necessary corrections can be made before its disclosure.

On Linux distributions, the Libksba library is usually provided as a separate dependency, but on Windows builds it is integrated into the main GnuPG installation package.

It is worth mentioning that for users who have already performed the relevant updates, it is recommended that they do not forget to restart the background processes with the command “gpgconf –kill all”. Also, to check for a problem in the output of the “gpgconf –show-versions” command, you can evaluate the value of the “KSBA ….” line, which should indicate a version of at least 1.6.2.

Updates for the distributions have not yet been released, but you can track their availability on the following pages: Debian , Ubuntu , Gentoo , RHEL , SUSE , Arch , and FreeBSD . The vulnerability is also present in MSI and AppImage packages with GnuPG VS-Desktop and in Gpg4win.

Finally, for those interested in learning more , you can find the details at the following link.


Add as preferred source in Google