GPGME CVE-2026-129975: Anatomy of a 24-Year-Old Double Free

The CyberSec Guru

CVE-2026-129975

If you like this post, then please share it:

Buy me A Coffee!

Support The CyberSec Guru’s Mission

🔐 Fuel the cybersecurity crusade by buying me a coffee! Why your support matters: Zero paywalls: Keep the main content 100% free for learners worldwide.

“Your coffee keeps the servers running and the knowledge flowing in our fight against cybercrime.”☕ Support My Work

Buy Me a Coffee Button

Late on Friday, 20 November 2026, Werner Koch posted an advisory to the gnupg-announce list that skipped the hedging. GPGME, the library applications use to hand OpenPGP work to the gpg engine, had a “critical security bug” present in every prior release. An OpenPGP key with a deliberately oversized user ID can trigger a double free in the library’s status-parsing code. The project says the bug “can be used exfiltrate data from applications by sending for example signed data,” and that remote code execution “can’t be ruled out.” The recommendation fit in one sentence: “Thus an immediate update is highly suggested.”

The flaw is tracked as CVE-2026-129975, and as T8557 on the GnuPG bug tracker. The fixed release is GPGME 2.3.1, dated 19 November in its release notes and published the next day. The legacy 1.x branch got its own fix in 1.24.4, and the Windows stack shipped as Gpg4win 5.1.2.

The bug’s biography is more interesting than its severity label. Koch’s commit message says the defective code was introduced 24 years ago, in July 2002, and first shipped in GPGME 0.3.9 that August. A thread on the oss-security list later pointed out that Red Hat’s tooling had flagged the same code in 2021. The fix existed downstream, filed as a memory-leak cleanup, and never reached upstream.

What follows is a close reading of what broke, why it survived, and what updating has to cover.

GnuPG Logo
GnuPG Logo

What GPGME is and who depends on it

GPGME (GnuPG Made Easy) is glue. Applications that want to sign, verify, encrypt, decrypt, or manage keys mostly do not implement OpenPGP themselves, and many would rather not parse gpg output either. GPGME spawns the gpg binary as a subprocess, wires up pipes, and translates the machine-readable output into C structures and callbacks.

The advisory lists the consumers this design has collected: Gpg4win, GnuPG Desktop, GnuPG VS-Desktop, “most mail clients,” “many XMPP clients,” Samba, and Flatpak. KDE’s mail and certificate stack reaches gpg through GPGME via Kleopatra’s libraries. Claws Mail’s privacy plugin uses it. Flatpak’s OSTree-based remotes are GPG-verified through it.

The gpg binary itself is unaffected. The vulnerable code lives in the library that reads gpg’s output, so tools that call gpg directly and parse the output themselves (Mutt, for example), or that use a different OpenPGP implementation entirely (Thunderbird’s built-in RNP-based support), never execute it.

How GPGME parses gpg output

Two output channels matter here. The first is the status stream: GPGME launches the engine with --status-fd, and gpg emits lines prefixed [GNUPG:] with keywords like GOODSIG, ERRSIG, KEY_CONSIDERED, and IMPORT_OK plus arguments. The second is the colon-delimited key listing produced by --with-colons, where each line is a record (pub, uid, fpr, sub) with colon-separated fields. GnuPG documents both formats in doc/DETAILS, and GPGME parses both inside src/engine-gpg.c, in the two functions at the center of this advisory: read_status() and read_colon_line().

The bookkeeping is plain C. The engine object (struct engine_gpg) holds two near-identical sub-structures, status and colon, each with a pipe descriptor pair, a buffer, a bufsize, a readpos, an EOF flag, and callback pointers. gpg_new() allocates the status buffer at 1,024 bytes. Both readers grow their buffers when a line does not fit, and the comment above read_status() says outright that this is expected behavior: “Of course we have to buffer the lines to cope with long lines e.g. with a large user ID.” In the 2.2.0 source, the growth policy is to check whether fewer than 256 bytes of headroom remain and, if so, add another 1,024 bytes with realloc(). Lines accumulate across reads until a newline arrives, then go to the operation’s status handler or colon-line handler.

The code anticipated large user IDs. It did not anticipate what happens to the buffer’s ownership when a read does not finish cleanly.

📬 Stay Ahead of Cyber Threats

Get the latest cybersecurity news, critical vulnerabilities, threat intelligence, tutorials, and exclusive giveaways delivered straight to your inbox. No spam. Unsubscribe anytime.

Root cause: a deferred write-back after realloc()

Both functions copy the engine’s buffer state into local variables, work on the locals, and copy the results back into the engine object only at the very end. Here is the opening of read_status() as it stood in GPGME 2.2.0, the last public release before the fix:

c

size_t bufsize = gpg->status.bufsize;
char *buffer = gpg->status.buffer; /* local copy */
size_t readpos = gpg->status.readpos;
if (bufsize - readpos < 256)
{
bufsize += 1024;
buffer = realloc (buffer, bufsize); /* may move the block,
freeing the old one */
if (!buffer)
return gpg_error_from_syserror ();
}
nread = _gpgme_io_read (gpg->status.fd[0],
buffer + readpos, bufsize - readpos);
if (nread == -1)
return gpg_error_from_syserror ();

realloc() is allowed to relocate the allocation: it copies the contents to a new block and frees the old one. When that happens, gpg->status.buffer still holds the address of the freed block, because the new address exists only in the local buffer. In the pre-fix code the write-back sat at the bottom of the function, after all line processing:

c

  /* Update the gpg object.  */
  gpg->status.bufsize = bufsize;
  gpg->status.buffer = buffer;
  gpg->status.readpos = readpos;
  return 0;

Between the realloc() and that write-back the function has several early exits, and each one skips it:

  • A read error on the status pipe returns immediately.
  • If the application installed a status monitor callback (mon_cb) and it returns an error, the function returns.
  • If the per-operation status handler (gpg->status.fnc) returns an error while processing a completed line, the function returns.
  • A failed strdup() of a command keyword returns.
  • The end-of-file branch, when gpg closes the status pipe, returned directly without the write-back.

read_colon_line() has the same structure, plus its own early exit when the colon preprocessing callback (gpg->colon.preprocess_fnc, used among other things for keyserver search results) signals an error. The GnuPG tracker’s root-cause analysis states the consequence plainly: on those paths “the engine’s buffer field is left pointing at the already-freed old block; the newly reallocated block leaks, and the stale pointer is freed a second time when the engine is released.”

The second free happens in gpg_release(), the engine destructor, which unconditionally calls free (gpg->status.buffer) and free (gpg->colon.buffer) when the engine object is torn down. The sequence is: grow, relocate, bail out early, keep a dangling pointer in a long-lived object, free it again at teardown, and leak the fresh block in the meantime.

Why allocator double-free checks may not catch it

Koch’s advisory adds the detail that turns this from a crash bug into something worse: “Due to other allocations in between the common double free checks of memory allocators may not be triggered.”

The cheap consistency checks in allocators like glibc’s, such as comparing a chunk against the head of its free-list bin or checking the marker a per-thread cache stamps into freed chunks, are stateful. They catch a second free only while the heap is still in the state the first free left behind. If an allocation between the two frees hands the chunk back out and the application writes into it, that state is gone, and the second free() goes through as if it were legitimate. The corruption then proceeds silently.

How a crafted OpenPGP key triggers the double free

The attacker-controlled input is the user ID. In the OpenPGP packet format a user ID is UTF-8 text with no small fixed size cap, and it flows straight into the channels GPGME buffers. The GOODSIG, BADSIG, EXPSIG, EXPKEYSIG, and REVKEYSIG status lines all carry the signer’s primary user ID as their last argument, “encoded in UTF-8 and %XX escaped,” an escaping that can inflate the byte count up to threefold. In colon listings, field 10 of a uid record is the user ID itself, C-style quoted.

A key whose user ID runs to several kilobytes therefore produces status and listing lines far beyond the initial 1,024-byte buffer, which forces the growth path where the bug lives. Because the readers grow in 1,024-byte steps whenever headroom drops below 256 bytes, one very long line can drive several reallocations.

For the double free to fire, an early exit has to happen in the same call as a relocation, after realloc() has moved the block and before the write-back. The advisory describes this as the function returning “early due to an read error or other events” and offers signed data sent to an application as an example delivery vector. It does not list which programs pass such material through without a manual key-import step, and that reticence is fair, because reachability depends on the application.

GPGME’s verify path can be configured to fetch and import keys automatically. The engine code adds --auto-key-import and --auto-key-retrieve when the matching context flags are set, so a signed message can cause key material the recipient never explicitly imported to be processed and listed. Whether a given mail client, chat client, or gateway exposes that path to untrusted input, and whether an attacker can reliably line up a buffer relocation with a callback or read error, are questions the advisory leaves to each application’s maintainers. No proof-of-concept exploit has been published, and the project has not reported any attacks exploiting the flaw.

Exploit impact: what a double free allows

The primitive itself is settled. A double free means the allocator eventually believes a chunk is available while another part of the program still owns it. The next allocation of that size class can hand the same memory to a second owner, and the usual consequences of the bug class follow: two live objects aliasing one region, and application data overwritten by library data or the reverse. The bytes GPGME writes into its buffers are largely attacker-chosen (the crafted user ID text), which makes it plausible that an attacker could influence what lands in the aliased memory.

The advisory’s claim that the bug can exfiltrate application data, and its refusal to rule out RCE, fit that mechanism. Debian’s advisory phrases the impact as “information disclosure, denial of service and potentially the execution of arbitrary code.” Neither the GnuPG project nor any distributor has demonstrated code execution. At the time of writing the CVE had not been populated in the NVD, so no CVSS score exists yet. The severity assessment here rests on the vendor’s wording and the bug class, not on a public exploit.

The fix: ten lines, 24 years late

The security fix is almost embarrassingly small: five lines added and five removed in each of the two functions. The relocated pointer and its new size are written back to the engine object right after realloc() succeeds, instead of at the end of the function:

diff

       buffer = realloc (buffer, bufsize);
       if (!buffer)
 	return gpg_error_from_syserror ();
-    }
+      gpg->status.bufsize = bufsize;
+      gpg->status.buffer = buffer;
+   }

The matching assignments are deleted from the tail of the function, leaving only readpos to update there. read_colon_line() gets the same treatment for gpg->colon. With the write-back moved, every early return leaves the engine holding a valid pointer, and the destructor frees exactly what it should.

The public repository shows two commits with the same message and the same ten-line diff. Commit 14499348b966, which Debian’s security tracker records as the fixing commit on the way to the 2.3 series, and commit b4358e92e33a, its counterpart committed five days later, were both authored by Koch on 14 November.

The released 2.3.1 tarball goes a step beyond the minimal patch. Both readers were restructured so every exit, error or not, runs through a single leave: label, with the error code initialized up front and returned at the end. The side-by-side diff of engine-gpg.c between 2.2.0 and 2.3.1 shows it, and it removes the whole category of “one more early return forgot the bookkeeping” regressions.

The commit message is where the 24 years show up:

Fix a double free in the status line read code.
* src/engine-gpg.c (read_status): Immediately assign the realloced
buffer to the context and not just at the end.
(read_colon_line): Ditto.
--
This fixes a 24 years old bug introduced with
Fixes-commit: f12433c1e476f52c92496a885c1ffcd10fa2a322
GnuPG-bug-id: T8557
Reported-by: Johan Carlsson (https://hackerone.com/joaxcar?type=user)

The referenced commit is a change by Marcus Brinkmann dated 28 July 2002, part of the work that added an interactive edit operation to GPGME and reworked read_status() along the way. It shipped in GPGME 0.3.9, released 21 August 2002. Every public release since, across the 0.3.x and 1.x lines and the 2.x line that split out the language bindings, carried the pattern.

Disclosure timeline for CVE-2026-129975

  • 28 July 2002: Marcus Brinkmann’s commit introduces the defective code. It ships in GPGME 0.3.9 on 21 August 2002.
  • July 2021: Red Hat’s Jiri Kucera moves the write-back in a CentOS Stream 9 / RHEL 9 patch titled “src/engine-gpg.c: Fix memleaks.” It never goes upstream.
  • 12 November 2026: GitLab notifies the GnuPG project of a report from Johan Carlsson (joaxcar on HackerOne).
  • 13 November: NIIBE Yutaka opens T8557, noting that the reporter supplied a patch.
  • 14 November: Koch authors the fix commits.
  • 16 November: Koch moves the ticket to testing.
  • 19 November: The 2.3.1 tarball is built. The announcement had been planned for the 25th.
  • 20 November: Koch posts the advisory, and 2.3.1 and 1.24.4 are published.

Carlsson found the bug through GitLab, which sits on a large dependency surface.

The Ruby2Shell collision that moved the disclosure

The planned 25 November announcement was a conventional coordinated-disclosure window, and it collapsed for reasons that had nothing to do with GPGME. On 19 November the Ruby team disclosed ruby2shell, CVE-2026-132825, a one-byte heap overflow in string case conversion. In fourteen legacy single-byte encodings, uppercasing the German sharp s (ß) writes two bytes where the code checks room for one. Ruby rates the flaw critical, with known proofs of concept achieving RCE. Default Rails and classic Sinatra applications reach it before authentication, because Rack’s MethodOverride middleware upcases the attacker-supplied _method parameter while routing the request.

GitLab was among the products bundling an affected Ruby and had to ship updates early. In Koch’s words: “due to the new Ruby2Shell bug GitLab had to update earlier and thus we also disclosed the GPGME bug on 2026-11-20.” Two unrelated memory-safety bugs, one in Ruby’s string handling and one in GPGME’s pipe readers, ended up on the same disclosure calendar, and defenders absorbed both within roughly twenty-four hours.

The disclosure was rough in other ways. Bernhard Reiter noticed on gnupg-devel that the patch promised in the advisory “did not make the announcement mail,” because Mailman had stripped the attachment, and that the GitHub mirror did not yet show the fix. The advice circulating was to take the patch from the T8557 ticket, where the reporter’s version had been attached from the start. The advisory as forwarded on oss-security does carry the attachment, named 0001-Fix-a-double-free-in-the-status-line-read-code.patch.

Red Hat patched the same bug in 2021 and never sent it upstream

In the same oss-security thread, Todd Zullinger pointed out that Red Hat Enterprise Linux 9 had patched this double free years earlier, after a Coverity scan flagged the code. The CentOS Stream 9 patch file confirms it: a July 2021 change by Jiri Kucera titled “src/engine-gpg.c: Fix memleaks” moves the buffer and size write-back to right after realloc() in both read_status() and read_colon_line(), with the comment “Update buffer and bufsize here to prevent memory leaks.” It is line for line the 2026 security fix.

It was classified as a leak cleanup. The leaked reallocated block was the symptom the scanner surfaced, while the stale pointer freed at teardown, the dangerous half, went unrecognized as a security issue. The patch shipped in RHEL 9 and was never submitted upstream. Zullinger notes it was not even shared with Fedora, so it did not carry into later RHEL releases either.

A static analyzer found the defect five years before disclosure, and the process around it discarded the finding’s significance. The incident has things to say about fuzzing coverage of parser code, but the sharper lesson concerns downstream fixes that never travel. A correctness patch in a distro’s patch queue does not fix the ecosystem.

Affected versions and fixed releases

The advisory says all software using GPGME “prior to 2.3.0” is affected, “either as shared libary, DLL, or statically linked.” Version 2.3.0 was never publicly released, so in practice every public release before 2.3.1 is vulnerable. The remediation map follows the linkage, not the application.

Shared-library installs

Update the system GPGME to 2.3.1. One package update covers every dynamically linked consumer. Distributions moved quickly:

  • Debian issued DSA-6646-1 on 20 November, fixing trixie in 1.24.2-3+deb13u1.
  • Debian bookworm is covered by DLA-4924-1 in 1.18.0-3+deb12u1, and unstable carries 2.3.1-1.
  • Alpine shipped 2.3.1-r0.

Debian’s fixed versions say 1.24.2, not 1.24.4, because distributions backported the ten-line patch onto their existing snapshots instead of rebasing. That is why checking a package’s changelog for the CVE matters more than matching upstream version strings.

Windows: Gpg4win 5.1.2

Gpg4win 5.1.2 bundles GPGME 2.3.1 alongside GnuPG 2.5.24. Its release notes are blunt: “It fixes a severe security issue. Update ASAP.” The advisory also points Windows users who need a standalone DLL at the updated Gpg4win package, and refreshed GnuPG Desktop and GnuPG VS-Desktop builds shipped in the same wave.

The legacy 1.x branch: GPGME 1.24.4

GPGME 1.24.4 is the fixed release for the legacy line, published on 20 November next to the 2.3.1 tarball. Its readme frames the branch’s future honestly: “This version is from a legacy branch of gpgme created just before we split out the C++, Qt, and Python bindings to separate repositories and bumped the version number up to 2.0. We can’t guarantee that it will see all security patches.” Treat 1.24.4 as a bridge, not a destination.

For anything that cannot move at all, the advisory says its attached patch “likely applies cleanly even to very old versions.” Given that the code has barely changed since 2002, that is believable, and the RHEL episode shows the patch survives a decade and a half of drift.

C++ and Qt bindings

The C++ and Qt bindings, GPGMEPP and GPGMEQT, need no update themselves. They have been separate packages since 2.0.0 and do not contain the vulnerable C parser. They sit on top of the core library, though, so the underlying GPGME still has to be fixed.

Static and bundled copies: the inventory problem

Routine patching will miss the population the advisory explicitly names: statically linked and bundled copies. Updating libgpgme.so on a host does nothing for an application that compiled GPGME into its own binary. A Flatpak application or runtime that carries its own GPGME needs a rebuild from its vendor, not a host package update. The same logic applies to container images whose application layers embed the library.

How to check whether you are exposed

Verifying exposure takes more than pkg-config --modversion gpgme or a package-manager query. Inspect the dynamic dependencies of the binaries that actually run (ldd and friends). For anything that shows no libgpgme dependency but demonstrably does OpenPGP work, check the build manifest or ask the vendor which GPGME it embeds.

Mitigations if you cannot update yet

The advisory offers no workaround for software that cannot update: no configuration flag, no input filter it endorses. For the gap period the only honest mitigations are architectural. Keep untrusted OpenPGP material away from affected processing paths where the application allows it, and isolate the services that cannot avoid it. That is containment, not remediation, and the project does not pretend otherwise.

What CVE-2026-129975 says about C glue code

It is tempting to file this under “another C memory bug” and move on, but the specifics resist that. The cryptographic core did not fail. The failure was in the glue that parses a subprocess’s output, code whose entire job is to accept variable-length, partly attacker-controlled text and buffer it safely. The vulnerable idiom, a local pointer copy with a success-only write-back, is ordinary C, and the code even documented the hostile input it expected: long user IDs.

The bug survived 24 years of releases, got rediscovered by a scanner in 2021, was patched downstream under a label that hid its security relevance, and was finally reported in 2026 by a researcher arriving through GitLab’s dependency surface. At each of those stages the ecosystem’s defenses worked as designed and still produced a 24-year exposure window.

For defenders the operational takeaway is narrower than the story. The fix is ten lines, fixed releases exist on both branches, and the patch ports to anything. The work is in the inventory: knowing every place GPGME lives in your estate, shared, bundled, or static, and knowing which applications feed untrusted keys or signed messages into it without a human in the loop. The advisory cannot answer the second question for you, and package updates do not substitute for it. Teams that treat this as a routine library bump will patch the copies they can see. Teams that treat it as a supply-chain question will find the rest, and if the RHEL story is any guide, the rest is where the interesting failures have been hiding.

Buy me A Coffee!

Support The CyberSec Guru’s Mission

🔐 Fuel the cybersecurity crusade by buying me a coffee! Your contribution powers free tutorials, hands-on labs, and security resources.

Why your support matters:
  • Writeup Access: Get complete writeup access within 12 hours
  • Zero paywalls: Keep the main content 100% free for learners worldwide

Perks for one-time supporters:
☕️ $5: Shoutout in Buy Me a Coffee
🛡️ $8: Fast-track Access to Live Webinars
💻 $10: Vote on future tutorial topics + exclusive AMA access

“Your coffee keeps the servers running and the knowledge flowing in our fight against cybercrime.”☕ Support My Work

Buy Me a Coffee Button

If you like this post, then please share it:

Uncategorized

Discover more from The CyberSec Guru

Subscribe to get the latest posts sent to your email!

Related Posts

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.