CVE-2026-2005: Heap Buffer Overflow in PostgreSQL pgcrypto PGP Session Key Parsing
- Vendor
- Postgresql
CVE-2026-2005 is a heap buffer overflow in the PostgreSQL pgcrypto extension's public-key decryption handling. In pgp_parse_pubenc_sesskey(), decrypted RSA or ElGamal session-key material is copied into a fixed-size, 32-byte buffer without validating the copy length. After PKCS#1 v1.5 unpadding, the function derives the session-key length from the decrypted message length; the checksum validation does not enforce an upper bound. A crafted ciphertext and matching key can therefore cause an out-of-bounds heap write, potentially enabling arbitrary code execution as the operating system user running PostgreSQL. Affected releases are PostgreSQL 18 before 18.2, 17 before 17.8, 16 before 16.12, 15 before 15.16, and 14 before 14.21.
Impact, mitigation & remediation
What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.
Impact
What an attacker gets, and what they’ve been doing with it.
Successful exploitation can compromise database confidentiality, integrity, and availability through arbitrary code execution under the PostgreSQL service account. Memory corruption can also crash database backend processes. A demonstrated exploitation chain obtains arbitrary memory read/write and elevates the database session to PostgreSQL superuser before executing operating-system commands. Host-level access remains bounded by the service account's operating-system permissions and any container or sandbox restrictions; operating-system root access is not an inherent outcome.
Mitigation
If you can’t patch tonight, do this now.
Until patched, prevent untrusted ciphertext from reaching pgcrypto public-key decryption operations. Restrict access to affected functions and application interfaces that invoke them, and audit callers accepting user-controlled ciphertext or keys. Limit database network access to trusted clients and apply least-privilege operating-system permissions to the PostgreSQL service account to reduce post-exploitation impact. These controls reduce exposure but do not repair the memory corruption flaw.
Remediation
Patch, then assume compromise.
Upgrade to PostgreSQL 18.2, 17.8, 16.12, 15.16, or 14.21, or a later release in the applicable major-version branch. Alternatively, install the distribution's vendor-patched packages, including the affected pgcrypto component. These cumulative minor updates require updating binaries and restarting PostgreSQL, but do not require dump/reload or pg_upgrade. For embedded PostgreSQL deployments, apply the corresponding product vendor update.
Exploits
2 exploits validated by Mallory's analysis. Hidden: 1 rejected by Mallory's analysis as not a working exploit.
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.
References
Frequently asked questions
- Is CVE-2026-2005 exploited in the wild?
- As of Nov 7, 2026, Mallory has no reports of CVE-2026-2005 being exploited in the wild. It is not listed in CISA KEV.
- Is there a public exploit for CVE-2026-2005?
- Yes. Mallory tracks 2 public exploits or proofs of concept for CVE-2026-2005, the earliest disclosed May 13, 2026.
- Is there a patch for CVE-2026-2005?
- Upgrade to PostgreSQL 18.2, 17.8, 16.12, 15.16, or 14.21, or a later release in the applicable major-version branch. Alternatively, install the distribution's vendor-patched packages, including the affected pgcrypto component.
- What products are affected by CVE-2026-2005?
- Postgresql.
- How severe is CVE-2026-2005?
- CVE-2026-2005 has a CVSS v3.1 score of 8.8 (High) and an EPSS score of 1.4% (72nd percentile) as of Nov 7, 2026.
Recent activity
67 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.