Skip to content
Crypto Write-up Advanced

GPGme used confusion, it's super effective !

The GPGME library's signature verification function can return a non-NULL result containing zero signatures when a detached signature is checked and the signing key is not in the keychain. Downstream software that loops over the signature list without checking for an empty list treats this as a successful verification, allowing an attacker to bypass signature checks on repository metadata and potentially downgrade packages to vulnerable versions.

synacktiv.com

Published on synacktiv.com

Rédigé par Lucas Georges - 16/02/2021 - dans Pentest - Téléchargement

The author, on synacktiv.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the API design of gpgme_op_verify_result, which returns a non-NULL result with an empty signature list for detached signatures when the signing key is absent, combined with downstream code that does not check for a zero-signature result before treating it as success.

Impact

An attacker could bypass the signature check on repository metadata when the optional repogpgcheck plugin is enabled, potentially forcing a downgrade of a package to a version containing a known vulnerability.

What the attacker needed

Attacker controls a repository; victim adds the repository; repogpgcheck plugin is enabled

The fix

The issue was fixed by VMware in tdnf.

How it was found

  1. Add a repository configuration pointing to an attacker-controlled server.
  2. Build and enable the tdnf repogpgcheck plugin.
  3. Serve a repomd.xml file signed with a throwaway GPG key not present in the victim's keychain.
  4. Run tdnf repolist and observe that the repository is accepted despite the invalid signature.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

GPGME is a helper library that programs use to check PGP signatures, which are like digital seals proving that a file has not been tampered with. The library has a confusing behaviour: when it cannot find the key that made the signature, it still returns a result object, but that object contains an empty list of signatures. If a program only checks that the result object exists and then loops over the list, the loop does nothing and the program wrongly concludes that the signature is valid.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.