Heap Buffer Overflow in PostgreSQL pgcrypto
CVE-2026-2005 is a heap-based buffer overflow in PostgreSQL's pgcrypto extension, specifically in public-key decryption handling within the function pgp_parse_pubenc_sesskey in contrib/pgcrypto/pgp-pubdec.c. During parsing of a decrypted PGP public-key encrypted session key packet, the code sets ctx->sess_key_len = msglen - 3 and then copies that many bytes with memcpy(ctx->sess_key, msg + 1, ctx->sess_key_len) into ctx->sess_key, a fixed-size buffer limited to PGP_MAX_KEY (32 bytes). Because the accepted plaintext length is not properly bounded after PKCS#1 v1.5 unpadding and control_cksum() does not enforce an upper limit, a crafted ciphertext and matching key can cause ctx->sess_key_len to exceed 32 bytes, resulting in an out-of-bounds heap write. PostgreSQL states that a ciphertext provider can exploit this flaw to execute arbitrary code as the operating system user running the database. Affected versions are PostgreSQL before 18.2, 17.8, 16.12, 15.16, and 14.21.
Are you exposed to this one?
Mallory correlates every CVE against your assets, your vendors, and active adversary campaigns. Know which vulnerabilities matter for you, not just which ones are loud.
Impact, mitigation & remediation
What it means. What to do now. Patch path, mitigations, and the assume-compromise checklist.
Impact
What an attacker gets, and what they’ve been doing with it.
Mitigation
If you can’t patch tonight, do this now.
Remediation
Patch, then assume compromise.
Exploits
1 valid exploit after Mallory filtered fakes, detection scripts, and README-only repos (1 hidden).
This repository is a real Python proof-of-concept exploit for CVE-2026-2005, a heap-based buffer overflow in PostgreSQL's pgcrypto extension during PGP session key parsing. The repo is small and focused: README.md documents the vulnerability and exploitation stages, poc.py contains the full exploit logic, and requirements.txt lists dependencies (psycopg2-binary, pwntools, pycryptodome). The exploit is not part of a larger framework. Its main entry point is poc.py, which connects to a PostgreSQL server using supplied credentials and crafts malicious OpenPGP data to trigger the overflow. Based on the README and visible code, the exploit performs a multi-stage chain: generate RSA material and PGP packets, trigger a heap corruption to leak a heap pointer, use a second corruption to obtain an arbitrary read primitive, scan leaked memory for candidate code pointers, compute/vote on possible PIE bases using symbol offsets from a locally supplied postgres ELF binary, validate the recovered base by reading CurrentUserId, then build an arbitrary write primitive that overwrites CurrentUserId with bootstrap superuser OID 10. Once elevated, it executes an arbitrary OS command through PostgreSQL COPY FROM PROGRAM and prints the output. Operationally, this is more than a simple crash PoC: it includes end-to-end exploitation and post-exploitation command execution, but the payload is still basic and operator-supplied rather than modular, so OPERATIONAL is the best fit. The exploit requires a matching vulnerable PostgreSQL build, pgcrypto enabled, valid DB connectivity, and likely an AArch64 target/build environment due to the explicit pwntools architecture setting. Fingerprintable targets/endpoints are primarily the PostgreSQL host/port and the local postgres binary path used for symbol resolution; there are no hardcoded C2 endpoints or exfiltration destinations.
Affected products & vendors
Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.
Vendor-confirmed product mapping. Mallory continuously reconciles this list against your asset inventory.
Recent activity
50 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.
A heap buffer overflow in PostgreSQL's pgcrypto extension that can allow arbitrary code execution as the operating system user running the database process when attacker-controlled ciphertext is parsed by pgcrypto decryption routines.
A critical remote code execution vulnerability in PostgreSQL's pgcrypto extension caused by a heap-based buffer overflow in PGP session key parsing logic, enabling arbitrary memory read/write, privilege escalation to PostgreSQL superuser, and operating system command execution under the PostgreSQL service account.
A heap-based buffer overflow in PostgreSQL's pgcrypto extension that can be triggered with specially crafted input, potentially leading to remote code execution on the database server.
A critical heap-based buffer overflow in PostgreSQL's pgcrypto extension during public-key decryption that can allow a user with basic create privileges to chain memory corruption primitives into privilege escalation and command execution as the database owner.
The version that knows your environment.
Query your assets running an affected version, and investigate the blast radius.
Every observed campaign linking this CVE to a named adversary.
Malware families riding this exploit, with evidence and IOCs.
YARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.
Cross-references every affected SKU, including bundled OEM variants.
Community discussion across Reddit, Mastodon, and other social sources.