# GnuPG Security Advisory for GPGME (T8557,CVE-2026-129975)

Crafted OpenPGP key with very long user ID triggers double free in GPGME status-line/key-listing readers, enabling data exfiltration and possible RCE.

- Payout: Research
- Severity: critical
- Program: GPGME
- Found by (vendor credit): Johan Carlsson (joaxcar)
- Write-up by: Johan Carlsson
- Disclosed: 2026-11-21
- CVE: CVE-2026-129975
- Write-up quality: 7/10
- Original: https://lists.gnupg.org/pipermail/gnupg-announce/2026q4/000517.html
- Library page: https://bugbountylibrary.com/r/blog%3Alists-gnupg-org-pipermail-gnupg-announce-2026q4-000517-html
- Tags: area:oss domain:oss impact:data-leak impact:rce kind:research platform:research sev:critical tech:linux tech:windows technique:source-review vuln:memory-corruption

**Target:** GPGME internal status-line and key-listing reader functions
**Root cause:** Two GPGME internal functions reading status lines and key listings from gpg realloc a 1024-byte buffer but only assign the new pointer back to the context at function end; an early return on read error leaves the context holding a stale pointer to freed memory, causing a double free at context release.
**Steps:**
1. Craft an OpenPGP key with a very long user ID exceeding the initial 1024-byte buffer.
2. Feed the key to an application using GPGME so the status-line/key-listing reader reallocates the buffer.
3. Cause the function to return early (read error or other event) before the new pointer is stored in the context.
4. Context retains stale pointer to freed memory; on context release the memory is freed a second time.
5. Intervening allocations may evade allocator double-free checks; use the corruption to exfiltrate data (e.g. via signed data) or attempt RCE.
**How found:** Discovered by Johan Carlsson and reported via GitLab on 2026-11-12; root cause identified in the buffer reallocation/early-return logic of the status-line and key-listing reader functions.
**Exploitation:** Attacker supplies a signed message or key containing a crafted very long user ID to a GPGME-using application; the reader reallocates, hits an early-return path, and the stale pointer causes a double free at context teardown. The resulting heap corruption can be used to exfiltrate data from the application (e.g. by sending signed data) and RCE cannot be ruled out.
**Escalation:** Heap corruption from the double free could potentially be escalated to remote code execution, though the advisory only states this cannot be ruled out.
**Insight:** When auditing C libraries that realloc growable buffers, check whether the new pointer is written back to the owning context immediately or only at function exit — early-return error paths leave stale pointers that become double frees at teardown, and intervening allocations can hide them from allocator checks.

