A public proof-of-concept exploit has been released for CVE-2026-2005, a critical heap-based buffer overflow in PostgreSQL’s pgcrypto extension that enables full remote code execution and privilege escalation to database superuser.
The vulnerable code has silently existed since pgcrypto was first contributed to PostgreSQL in 2005, over two decades ago, a fully autonomous AI-powered security analysis tool, at the Wiz-hosted ZeroDay.Cloud 2025 hacking event in London on December 10–11, 2025.
The upstream patch was committed on February 8, 2026, and shipped across all supported PostgreSQL major versions on February 12, 2026.
PoC Released for 20-Year-Old PostgreSQL Flaw
The vulnerability received a CVSS score of 8.8 (High), and its severity is amplified by the scale of exposure analysis, which found that 80% of cloud environments run PostgreSQL, with 45% directly exposing PostgreSQL to the internet.
The vulnerability resides in pgp_parse_pubenc_sesskey() inside contrib/pgcrypto/pgp-pubdec.c.

When parsing a PGP public-key-encrypted session key packet, the code derives a session key length as msglen - 3 and copies that many bytes into ctx->sess_key a buffer bounded by PGP_MAX_KEY (32 bytes) with no bounds check whatsoever.
An attacker controlling the PGP message can push the session key length to hundreds of bytes, far exceeding the 32-byte limit of the destination.
The pgcrypto extension is a trusted extension, meaning any database role with CREATE privilege can install it without requiring superuser access drastically lowering the barrier to exploitation.
The PoC, published on GitHub by researcher var77, chains three exploit primitives:
- Information Leak — A crafted PGP message partially overwrites
dst->datawith two null bytes, pointing it to a lower heap address. Whendecrypt_internalreturns,mbuf_steal_data(dst)dumps a window of heap memory containing PIE text pointers and heap addresses, leaking both the PIE base and a heap reference in a single call - Arbitrary Write — A second connection (inheriting an identical ASLR layout via PostgreSQL’s
fork()model) triggers the overflow again, this time forging all fourdstfields (data,data_end,read_pos,buf_end) to enable arbitrary write to any known address - Privilege Escalation to RCE — The exploit targets
CurrentUserId, a global in PostgreSQL’s.datasection, overwriting it to10(BOOTSTRAP_SUPERUSERID). With superuser privileges,COPY (SELECT ...) TO PROGRAMexecutes arbitrary OS commands as the PostgreSQL system user
A critical detail that makes this reliably exploitable: PostgreSQL forks a new backend per connection, inheriting the parent’s address space.
This means ASLR layout is identical across all connections to the same postmaster; any address leaked on one connection is valid on the next.
Affected Versions & Patches
The flaw affects every supported major version of PostgreSQL before the February 2026 releases. Patched versions are: 18.2, 17.8, 16.12, 15.16, and 14.21.
Notably, this vulnerability was disclosed alongside a second PostgreSQL flaw, CVE-2026-2006 (CVSS 9.0), also found at ZeroDay.Cloud 2025 “, patched in the same update cycle.
Mitigation
- Upgrade immediately to PostgreSQL 18.2, 17.8, 16.12, 15.16, or 14.21
- Restrict
CREATEprivilege on databases to prevent untrusted roles from loadingpgcrypto - Block direct internet exposure of PostgreSQL port 5432; limit to trusted application subnets only
- Rotate database credentials across apps, CI/CD pipelines, and secrets stores
- Audit
COPY FROM PROGRAMusage and restrict via role-level controls - Cloud-managed PostgreSQL users should verify their provider has deployed patched engine versions
Follow us on Google News , LinkedIn and X to Get More Instant Updates. Set Cyberpress as a Preferred Source in Google.