Automated Threat Modeling

Overview of CVE 2026 116304: PostgreSQL Parallel RECORD Typmod Use After Free Leading to Code Execution

A brief summary of CVE 2026 116304, a race condition in PostgreSQL's shared tuple descriptor management for parallel workers. A database user can trigger a use after free and execute code as the database OS user. Includes patch details and fixed versions.

CVE Analysis

7 min read

Gaurav Sarraf
Gaurav Sarraf

2026-11-12

Overview of CVE 2026 116304: PostgreSQL Parallel RECORD Typmod Use After Free Leading to Code Execution

Introduction

A race in how PostgreSQL parallel workers agree on the meaning of anonymous RECORD types allowed an ordinary database user to run arbitrary code as the operating system account that owns the database server. The attacker only needs a database login, and the flaw lives in core server code used by parallel query. Deployments where less trusted users can run SQL should treat this as a path to server compromise rather than a simple crash.

The issue is tracked as CVE 2026 116304 and carries a CVSS 3.1 score of 8.8 with the vector AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H. It is classified as CWE 416 (use after free) and CWE 843 (access of a resource using an incompatible type). PostgreSQL fixed it on 12 November 2026 in releases 18.7, 17.12, 16.16, 15.20 and 14.25.

Technical information

Background: shared RECORD typmods

When a query runs in parallel, the leader and its workers need a consistent view of what an anonymous RECORD typmod means. PostgreSQL handles this with two dshash tables stored in the per-session DSA area:

  • shared_typmod_table maps typmod to a shared TupleDesc.
  • shared_record_table maps a TupleDesc to its typmod, so other processes can reuse an existing typmod for an identical descriptor.

Registration happens in find_or_make_matching_shared_tupledesc() in src/backend/utils/cache/typcache.c. A backend copies the descriptor into DSA memory (shared_dp), inserts it into shared_typmod_table, and then tries to insert it into shared_record_table. If that second insert finds that another process already registered an identical descriptor, the backend discards its own copy and returns the existing one.

Root cause: the entry lock was released too early

The vulnerable code released the typmod_table_entry lock immediately after filling in the entry, before deciding whether to keep the new descriptor. That made the new typmod and its TupleDesc visible to other backends while its owner might still free it.

The commit message describes the race in four steps:

  1. Process A puts a new typmod into shared_typmod_table.
  2. Process B looks up that typmod and keeps a pointer to its TupleDesc.
  3. Process A finds a duplicate in shared_record_table and frees its TupleDesc.
  4. Process B later reads the freed memory as a TupleDesc and uses it to deform a tuple.

Both CWE classifications apply at step 4, where memory that has been returned to the DSA allocator is dereferenced as if it were still a valid tuple descriptor. The maintainers note that an attacker could likely control what gets written into the freed memory, which is why the project rates this as a code execution bug and not only a crash.

Attack flow

Based on the advisory and the commit description, exploitation looks like this at a high level:

  1. The attacker authenticates as a database user (the CVSS vector requires low privileges, so this is not an unauthenticated attack).
  2. The attacker causes parallel workers to register anonymous RECORD typmods such that one process creates a duplicate descriptor while another process looks up the newly published typmod.
  3. The creating process discovers the duplicate and frees its copy, leaving the other process with a dangling pointer into DSA memory.
  4. If the attacker can influence what is subsequently placed in that freed region, the victim process interprets attacker-influenced bytes as a TupleDesc while deforming a tuple, which the advisory states can lead to arbitrary code execution as the operating system user running PostgreSQL.

The public sources describe the concurrency failure and impact but do not include a reproducible exploit procedure or code.

Exploitation status

The official advisory and CVE record do not report active exploitation, a public exploit, or named threat actors, and the CISA Known Exploited Vulnerabilities catalog checked during our research did not list this CVE. We treat in-the-wild exploitation as unconfirmed, not ruled out.

Patch information

The fix was written by Robert Haas, reviewed by Andrew Dunstan, committed by Noah Misch, and reported by Peter Geoghegan. It was backpatched to every supported branch back to 14. The 18.7 release notes describe it as "Fix race condition leading to use after free in shared tupledesc management" and link to commit 861b5a869. Two back-branch commits, ba00c3576 and 49521f66d, carry a Security tag naming this CVE and contain the same diff. The diff touches a single function, find_or_make_matching_shared_tupledesc().

The patch keeps the typmod_table_entry lock held across the entire check-and-discard sequence. First, the early release is removed and a lock ordering rule is documented in the code:

typmod_table_entry->typmod = typmod; typmod_table_entry->shared_tupdesc = shared_dp; - dshash_release_lock(CurrentSession->shared_typmod_table, - typmod_table_entry); /* * Finally create an entry in the record table so others with matching * tuple descriptors can reuse the typmod. + * + * Note that we're still holding the lock on typmod_table_entry. Any code + * that needs both locks must acquire them in this order. */

Second, when a duplicate is found, the code deletes the entry it still holds locked with dshash_delete_entry instead of looking it up again by key with dshash_delete_key. Since the lock was never released, no other backend can have read shared_dp, so freeing it is safe:

- /* Might as well free up the space used by the one we created. */ - found = dshash_delete_key(CurrentSession->shared_typmod_table, - &typmod); - Assert(found); + /* + * In general, it's unsafe to delete a TupleDesc once it's referenced + * from either hash table, because other backends might already be + * accessing it. However, since we haven't released the lock on + * typmod_table_entry, no one can have seen it yet, and thus no one + * can have a pointer to shared_dp. + */ + dshash_delete_entry(CurrentSession->shared_typmod_table, + typmod_table_entry); dsa_free(CurrentSession->area, shared_dp);

Third, on the normal path where the new descriptor is kept, the typmod lock is released only at the very end, after the record table entry has been published:

dshash_release_lock(CurrentSession->shared_record_table, record_table_entry); + dshash_release_lock(CurrentSession->shared_typmod_table, + typmod_table_entry);

Why the fix works

Under the old code, a TupleDesc was reachable through shared_typmod_table before its owner decided to keep it. With the fix, a typmod entry becomes readable by other backends only once its descriptor is permanent. A descriptor that loses the race is deleted and freed while still private to the backend that created it, so no other process can hold a dangling pointer to it.

The patch also fixes a lock order: the shared_typmod_table lock is taken first, then the shared_record_table lock, which prevents the two locks from deadlocking against each other. The change is small (one file, about a dozen lines), adds no new data structures, and needs no on-disk or catalog changes. A minor version update is enough to apply it.

Affected systems and versions

The affected component is the PostgreSQL core server. According to the PostgreSQL advisory:

PostgreSQL major versionAffected versionsFixed release
18Before 18.718.7
17Before 17.1217.12
16Before 16.1616.16
15Before 15.2015.20
14Before 14.2514.25 (final PostgreSQL 14 release)

Exploitation requires an authenticated database user able to cause the described parallel worker interaction. PostgreSQL 14.25 is the final release of the 14 branch. The project states PostgreSQL 14 is end of life and will receive no further security or bug fixes, and recommends planning an upgrade to a newer supported major version. The official advisory does not specify a separate workaround.

Vendor security history

PostgreSQL is an open-source object-relational database whose origins go back to the POSTGRES project at the University of California at Berkeley in 1986. The project acts as its own CNA, runs a security team that validates reports and coordinates fixes, supports each major version for five years, and ships bug and security fixes in minor releases. The 12 November 2026 release that resolved this issue (18.7, 17.12, 16.16, 15.20 and 14.25) fixed 52 security vulnerabilities and more than 140 bugs in total. For context on deployment footprint, the DB Engines popularity ranking for November 2026 places PostgreSQL fourth with a score of 689.69. That figure is a popularity index, not a measured market share.

References

Detect & fix
what others miss

Works with
  • GitHub
  • GitLab
  • Bitbucket
  • Azure DevOps Services
  • Gerrit
  • CVS
  • Jira
  • Linear
  • Slack
  • Security Compass
Explore integrations
Security magnifying glass visualization