Databases

PostgreSQL 18.7 Security Update: 52 CVEs, How to Patch 14 to 18

Thirty-two of the 52 CVEs fixed in the November PostgreSQL update releases score CVSS 8.8. Most of them let a logged-in role run code as the operating system user behind the database, and six need nothing more than a login. The fixed builds are 18.7, 17.12, 16.16, 15.20 and 14.25, and the last one is the final PostgreSQL 14 release. Any cluster with a login role you don’t fully trust is exposed until the binaries are replaced.

Original content from computingforgeeks.com - post 189398

Below is the CVE list sorted by the component you actually run, the patch on PGDG apt and dnf, the order for a primary with standbys, and the index and backup work the update leaves behind. Every command here ran in November 2026 on Ubuntu 26.04 and 24.04 with the PGDG apt repository and on Rocky Linux 10.2 with SELinux enforcing, so no step relaxes it.

Exposure and patch priority

Every supported branch is affected, and the fix is a minor update: stop the server, replace the binaries, start it again. No dump, reload or pg_upgrade is needed. The PostgreSQL project rates 32 of the 52 CVEs at 8.8, two at 8.1, one at 8.0 and three at 7.2. The remaining 14 sit between 3.1 and 6.5: privilege and row security gaps, small memory disclosures and a pre-authentication spinlock leak.

Most of the 8.8 entries share one vector: AV:N/AC:L/PR:L/UI:N. For most, the attacker is a role that can create a table, function or type and uses it to trigger a type confusion or use-after-free, ending in code execution as the postgres OS account. Six (the text search overflows, parallel RECORD typmod, generation context and tuple-size wraparounds, materialized SRF) only need a database user, so a read-only login without CREATE is enough. Three need no database login at all, only a victim who processes attacker data, which is why these setups go to the front of the queue:

  • Any cluster that accepts logins from roles you don’t fully trust, read-only ones included, is patched today.
  • Shared clusters where application teams, tenants or analysts hold CREATE on any schema are patched today.
  • Servers with plperl, pltcl or dblink installed in any database are patched today, because seven of the 8.8 bugs live there.
  • Subscribers whose logical replication subscription is owned by a superuser are patched before the publisher is trusted again (CVE-2026-120145).
  • Hosts that run pg_restore or psql on dumps from another party get the new client package first (CVE-2026-116314, CVE-2026-116330).

A single-tenant database whose only role is the application owner is still affected, but an attacker needs that role’s credentials first. Patch it in the next maintenance window, not next quarter. PostgreSQL 14 is end of life with this release, so 14.25 closes these holes and nothing after it will.

The high-severity CVEs by component

The table lists the 38 CVEs rated 7.0 or higher, grouped by where the bug lives. Scores and affected branches come from the CVE records the PostgreSQL CNA published on CVE.org, and every ID below resolves on NVD. “All” means 14 through 18, fixed in 18.7, 17.12, 16.16, 15.20 and 14.25.

ComponentCVECVSSFlawBranches affected
PL/PerlCVE-2026-1163078.8Prepared-query use-after-freeAll
PL/PerlCVE-2026-1163098.8Blessed-reference type confusionAll
PL/PerlCVE-2026-1163198.8Reentrant return_next() use-after-freeAll
PL/PerlCVE-2026-1163208.8Array and hash conversion use-after-freeAll
PL/PerlCVE-2026-1163268.8Tied-object exceptions follow a stale sigjmp_bufAll
PL/TclCVE-2026-1163238.8Reentrant result conversion use-after-freeAll
PL/pgSQLCVE-2026-1201518.8Record-field type confusionAll
dblink, subscriptionsCVE-2026-146618.1sslkeylogfile appends to a file the user picks18, and older servers loading libpq 18
dblinkCVE-2026-1201478.8Reentrant disconnect use-after-freeAll
Logical replicationCVE-2026-1201458.8Publisher can write to subscriber system catalogsAll
Foreign data wrappersCVE-2026-1201498.8Batch-insert mismatchAll
pg_restoreCVE-2026-1163148.8Missing validation of non-plain archivesAll
pg_dumpCVE-2026-1163308.8Tar-format restore.sql lets psql commands throughAll
pg_dumpCVE-2026-1163188.8Not-null constraint name allows SQL injection18 only
reindexdbCVE-2026-1163258.0Index name quoting allows SQL injection with –jobs and –index17 and 18
vacuumdbCVE-2026-1163137.2–missing-stats-only runs a database owner’s operators18 only
Text searchCVE-2026-1163158.8tsvector_delete() heap overflowAll
Text searchCVE-2026-1163178.8ts_rank_cd() heap overflowAll
Extension scriptsCVE-2026-64677.2Schema mishandling runs arbitrary SQLAll
Extension scriptsCVE-2026-1201537.2Substitutions allow SQL injection through object namesAll
Core serverCVE-2026-64608.8Type confusion after ALTER … SET DATA TYPE (how to check for and patch CVE-2026-6460)All
Core serverCVE-2026-184478.8Output parameter type confusionAll
Core serverCVE-2026-1163048.8Parallel RECORD typmod use-after-freeAll
Core serverCVE-2026-1163068.8Composite-type change during field assignmentAll
Core serverCVE-2026-1163168.8Security-restricted operations create types in pg_tempAll
Core serverCVE-2026-1163288.8Generation memory context integer wraparound16 to 18
Core serverCVE-2026-1163298.8Statistics import type confusion18 only
Core serverCVE-2026-1163318.8min/max aggregate type confusionAll
Core serverCVE-2026-1163328.8Portal setup use-after-freeAll
Core serverCVE-2026-1163358.8Commutator or negator result-type confusionAll
Core serverCVE-2026-1163368.8REINDEX CONCURRENTLY does not block DROP INDEXAll
Core serverCVE-2026-1201398.8Tuple-size integer wraparoundAll
Core serverCVE-2026-1201418.8Materialized set-returning function type confusionAll
Core serverCVE-2026-1201428.8Dropped-column type confusion17 and 18
Core serverCVE-2026-1201438.8Transition-table cursor use-after-freeAll
Core serverCVE-2026-1201448.8Type-cache invalidation gap18 only
Core serverCVE-2026-1201508.8Expanded-record domain-check use-after-freeAll
Core serverCVE-2026-1201488.1Extended-statistics pseudo-type confusionAll

Two rows deserve a second look. CVE-2026-14661 also reaches a 15, 16 or 17 server when that host loads libpq from the 18 packages, which is common on PGDG apt hosts where one shared libpq5 package tracks the newest major. CVE-2026-116313 matters to anyone finishing an upgrade to 18, because the pg_upgrade docs recommend the exact vacuumdb --missing-stats-only call it abuses. The 14 lower-scored CVEs include row security bypasses through INSERT … ON CONFLICT and DROP OWNED, an auto-updatable view WHERE bypass, MERGE putting the wrong row in a trigger transition table, a pg_basebackup format string bug, a pre-authentication cancel request that can leak a spinlock on 18 (CVE-2026-116322), and memory disclosure through unterminated names and pg_show_all_settings(). The full list is on the PostgreSQL release announcement and the project’s security page.

The minor version each cluster runs

The package version tells you what is installed on disk. The server version tells you what is running, and the two differ whenever a package was upgraded without a restart. Check both, on every host, starting with the cluster list on Debian and Ubuntu:

pg_lsclusters
sudo -u postgres psql -p 5432 -Atc "SELECT version();"
apt list --installed 'postgresql-1*' 2>/dev/null

Our Ubuntu 26.04 primary ran two clusters before the update. The 18 cluster reported 18.6 (the same query on port 5433 returned 17.11 for the 17 cluster), and apt already marked both as upgradable to the fixed builds:

Ver Cluster Port Status Owner    Data directory              Log file
17  main    5433 online postgres /var/lib/postgresql/17/main /var/log/postgresql/postgresql-17-main.log
18  main    5432 online postgres /var/lib/postgresql/18/main /var/log/postgresql/postgresql-18-main.log
PostgreSQL 18.6 (Ubuntu 18.6-1.pgdg26.04+2) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 15.2.0-16ubuntu1) 15.2.0, 64-bit
Listing...
postgresql-17/resolute-pgdg,now 17.11-1.pgdg26.04+2 amd64 [installed,upgradable to: 17.12-1.pgdg26.04+1]
postgresql-18/resolute-pgdg,now 18.6-1.pgdg26.04+2 amd64 [installed,upgradable to: 18.7-1.pgdg26.04+2]

Any server that prints a version below 18.7, 17.12, 16.16, 15.20 or 14.25 is in scope for every CVE marked “All” in the table above. The capture below shows both clusters on the primary before anything changed.

pg_lsclusters and SELECT version() showing PostgreSQL 18.6 and 17.11 with apt marking 18.7 and 17.12 as upgradable

Watch for one trap on Ubuntu 26.04: the distro archive carries its own postgresql-18 build (18.6-0ubuntu0.26.04.1 at the time of testing), and apt-cache policy lists it next to the PGDG one. If apt-cache policy postgresql-18 shows no apt.postgresql.org line as the candidate, you’re on the distro package and the fix arrives when Ubuntu ships it, not today. The PostgreSQL 18 install guide for Ubuntu 26.04 sets up the PGDG repository if you want to follow upstream directly.

Ubuntu and Debian patching with PGDG apt

An unpatched server stays exploitable until the postmaster restarts on the new binaries, so the restart is the control, not the package install. On Debian and Ubuntu the postgresql-common maintainer scripts restart every cluster of an upgraded major for you. Refresh the index and confirm which packages the PGDG repo is offering first:

sudo apt update
apt list --upgradable 2>/dev/null | grep -i postgres

Then upgrade only the server and client packages, so this window does not drag in an unrelated kernel or OpenSSL update you haven’t planned for:

sudo apt install --only-upgrade postgresql-18 postgresql-17 postgresql-client-18 postgresql-client-17

Name only the majors that are installed on the host. Upgrading the client packages matters as much as the server here, because the pg_dump, pg_restore, reindexdb and vacuumdb fixes ship in postgresql-client-NN. Prove the restart happened by comparing pg_postmaster_start_time() before and after:

sudo -u postgres psql -p 5432 -Atc "SELECT version(), pg_postmaster_start_time();"

On our primary the 18 cluster had been up since 16:20:07. After the upgrade it answered as 18.7 with a start time two minutes later, and the 17 cluster moved to 17.12 at the same second:

PostgreSQL 18.7 (Ubuntu 18.7-1.pgdg26.04+2) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 15.2.0-16ubuntu1) 15.2.0, 64-bit|2026-11-12 16:22:14.682326+00

needrestart printed “No services need to be restarted” during the same run. That line is easy to misread: it means the maintainer script had already restarted the clusters, not that the old binaries are still acceptable. Trust the start time, not the needrestart summary. The same steps apply on plain Debian with the PGDG repository on Debian.

Rocky, Alma and RHEL patching with PGDG dnf

The PGDG RPMs install one versioned package set per major (postgresql16-server, postgresql15-server), so the exposure check is a plain rpm query. Our Rocky Linux 10.2 box ran 16.15 and 15.19 side by side with SELinux in enforcing mode:

rpm -q postgresql16-server postgresql15-server

Both packages came back on the vulnerable builds:

postgresql16-server-16.15-4PGDG.rhel10.2.x86_64
postgresql15-server-15.19-4PGDG.rhel10.2.x86_64

Upgrade every package of each major together. Mixing a new -server with an old -libs or -contrib leaves extension libraries such as dblink built for the old minor:

sudo dnf upgrade -y 'postgresql16*' 'postgresql15*'

Unlike Debian, nothing tells you a restart happened. The postgresql16-server package carries a systemctl try-restart in its post-upgrade scriptlet, and the journal shows both services cycling at 16:25:22 and 16:25:23 while dnf was still running. SELECT version() reported 16.16 and 15.20 straight after dnf returned, before any manual restart.

dnf upgrade of PGDG postgresql16 and postgresql15 on Rocky Linux 10 with journal showing the try-restart scriptlet restarting both services

That automatic restart is a risk of its own on a primary: run dnf upgrade casually during the day and your connections drop without warning. Treat the dnf command as the restart and schedule it the same way. sudo ausearch -m avc -ts recent returned no matches afterwards, so the update needs no SELinux change. One thing that did fail: dnf -qy module disable postgresql, a step many EL8 and EL9 guides carry, errors on Rocky 10 with “missing groups or modules: postgresql” because the module no longer exists. Drop it from your EL10 runbooks.

Patch order for streaming replicas and Patroni

The PostgreSQL documentation tells you to update standbys first, because a newer minor is more likely to read WAL written by an older one than the reverse. So the order is standbys first, primary last, and never the other way round. We tested it with an 18 primary on Ubuntu 26.04 and an 18 streaming standby on Ubuntu 24.04, both starting on 18.6:

  1. Every standby is upgraded and back in recovery before the primary is touched.
  2. pg_stat_replication on the primary shows each standby as streaming again.
  3. The primary is upgraded last, during a window where a short connection drop is acceptable.

The standby took the update with the same apt install --only-upgrade command. It came back as 18.7, still in recovery (t), with a new start time 22 seconds after the old one:

Patching the PostgreSQL standby first with apt install --only-upgrade postgresql-18, standby restarts on 18.7 still in recovery

Check the primary’s view of the standby before you go further. If this query returns no row, the standby did not reconnect and you have lost your failover target at the exact moment you’re about to restart the primary:

sudo -u postgres psql -c "SELECT application_name, client_addr, state FROM pg_stat_replication;"

Ours reconnected without help:

 application_name | client_addr |   state
------------------+-------------+-----------
 18/replica       | 10.132.0.55 | streaming
(1 row)

Only then did we upgrade the primary. Its clusters restarted on 18.7 and 17.12, and the patched standby was streaming again by the time the next query ran.

Primary upgraded to PostgreSQL 18.7 and 17.12 with new postmaster start times and the patched standby still streaming

Patroni was not part of this lab, so take the next part as the order to follow rather than a tested run. Patroni changes who restarts PostgreSQL, not the order. Its postmaster is usually not a postgresql@ unit, so the package scripts may leave it running the old binary. Upgrade the packages on one replica, restart only that member with patronictl restart <cluster> <member>, and confirm SELECT version() before moving on. Then move the leader to a patched replica with patronictl switchover --candidate and upgrade the old leader last. The node layout we use for that is in the Patroni, etcd and HAProxy cluster guide.

Index rebuilds and a fresh full backup

The new binaries stop new damage, but they do not repair what older builds already wrote. The release notes name four kinds of index that may hold bad entries, and this is what the announcement asks you to check after the update:

  • GIN indexes you suspect of corruption are rebuilt.
  • GiST indexes that use the gist_trgm_ops operator class from pg_trgm are rebuilt.
  • B-tree indexes on bpchar columns declared without a length are rebuilt; char(n) columns are not affected.
  • A table that throws “missing chunk number” errors gets REINDEX TABLE, which also rebuilds its TOAST index.

Finding those by hand across many databases is slow. We wrote one catalog query that prints a ready-to-run REINDEX INDEX CONCURRENTLY line for each candidate. It flags every GIN index on purpose, because nothing in the catalog tells you which ones were hit. Save it as find-reindex.sql:

SELECT format('REINDEX INDEX CONCURRENTLY %s;', i.indexrelid::regclass) AS fix,
       am.amname AS method,
       CASE WHEN am.amname = 'gin' THEN 'GIN corruption fixes'
            WHEN am.amname = 'gist' THEN 'pg_trgm gist_trgm_ops'
            ELSE 'btree on unbounded bpchar' END AS reason
FROM pg_index i
JOIN pg_class ic ON ic.oid = i.indexrelid
JOIN pg_am am ON am.oid = ic.relam
WHERE am.amname = 'gin'
   OR (am.amname = 'gist' AND EXISTS (
        SELECT 1 FROM pg_opclass oc
        WHERE oc.oid = ANY (i.indclass::oid[]) AND oc.opcname = 'gist_trgm_ops'))
   OR (am.amname = 'btree' AND EXISTS (
        SELECT 1 FROM pg_attribute a
        WHERE a.attrelid = i.indrelid AND a.attnum = ANY (i.indkey::int2[])
          AND a.atttypid = 'bpchar'::regtype AND a.atttypmod = -1))
ORDER BY 2, 1;

Run it against each database. Our test schema had one index of each kind, and the query found all four on 18.7, 17.12, 16.16, 15.20 and 14.25 alike:

sudo -u postgres psql -d appdb -f find-reindex.sql

The output is the work list:

                     fix                     | method |          reason
---------------------------------------------+--------+---------------------------
 REINDEX INDEX CONCURRENTLY docs_code_btree; | btree  | btree on unbounded bpchar
 REINDEX INDEX CONCURRENTLY docs_body_gin;   | gin    | GIN corruption fixes
 REINDEX INDEX CONCURRENTLY docs_tags_gin;   | gin    | GIN corruption fixes
 REINDEX INDEX CONCURRENTLY docs_title_trgm; | gist   | pg_trgm gist_trgm_ops
(4 rows)

Use CONCURRENTLY on a live primary so writes keep flowing; a plain REINDEX takes a lock that blocks them for the whole rebuild. Piping the query output back into psql runs the list in one pass, and on our 20,000-row table all four rebuilds finished in 0.35 seconds:

sudo -u postgres psql -d appdb -Atf find-reindex.sql | cut -d"|" -f1 | sudo -u postgres psql -d appdb -e

Real tables take far longer, and a concurrent rebuild needs roughly the index’s size in free disk until it swaps. Run large ones one at a time outside peak hours. A concurrent rebuild that fails or is cancelled leaves an invalid index ending in _ccnew, which still slows every write; drop it before you retry. One ending in _ccold means the rebuild itself succeeded, so drop that one and don’t retry.

REINDEX INDEX CONCURRENTLY run on the GIN, pg_trgm GiST and bpchar B-tree indexes after the PostgreSQL 18.7 update

Partitioned tables on 18 need one more check. The announcement ships a query for NOT NULL NO INHERIT constraints on partitioned tables, which should not exist; drop the ones you don’t want with ALTER TABLE ... DROP CONSTRAINT and repair the rest with ALTER TABLE ... ALTER CONSTRAINT ... INHERIT, which fails if a partition holds NULLs. Save the query as find-noinherit.sql:

SELECT conrelid::regclass, conname FROM pg_constraint WHERE contype = 'n' AND connoinherit AND conrelid IN (SELECT oid FROM pg_class WHERE relkind = 'p');

It returned zero rows on every cluster we patched. We tried to plant a bad constraint first and could not: both 18.6 and 18.7 refused with “not-null constraints on partitioned tables cannot be NO INHERIT”. That does not prove a cluster is clean: the announcement says this release closes the remaining path “in all cases, including CREATE TABLE … LIKE”, which our test did not try. Run the query on every 18 database.

PostgreSQL 18.7 NOT NULL NO INHERIT audit query returning zero rows and the server refusing the constraint on a partitioned table

Finally, the backup chain. If you use incremental backups, the project recommends a new full backup after the update as the base for every later incremental. Take it once the reindex is done so the base holds the rebuilt indexes; our PostgreSQL backup and PITR guide covers the pg_basebackup side. If a host skipped earlier minor releases, also run the post-update steps from those releases’ notes, because the announcement says they may still apply.

PostgreSQL 14 end of life and the way off it

14.25 is the final PostgreSQL 14 release. The next CVE that lands in the core server will stay open on 14 for good, so the 14.25 update is a stopgap that buys time for a major upgrade, nothing more. Apply it now, with the same apt or dnf commands as the other majors:

sudo apt install --only-upgrade postgresql-14 postgresql-client-14

Our Ubuntu 24.04 cluster went from 14.24 to 14.25 in place, and the same four indexes showed up in the reindex query afterwards. Then plan the jump. On Debian and Ubuntu, pg_upgradecluster wraps pg_upgrade and moves the cluster, its configuration and its port in one command, but only run it once the target major’s packages are on the fixed build:

sudo pg_upgradecluster -m upgrade 14 main

Ours moved 14 to 18 with the data intact and left the old cluster down on port 5434. Note the two vacuumdb lines in its output: the first one is the --missing-stats-only call from CVE-2026-116313, so run it only from 18.7 binaries or later.

pg_upgradecluster moving an end of life PostgreSQL 14 cluster to PostgreSQL 18 on Ubuntu 24.04

pg_upgrade does not rebuild indexes, so the reindex query from the previous section still matters on the new cluster: it listed the same four candidates on 18.7 straight after the upgrade. Pre-flight checks, extension handling and the RPM-side commands for this move are in our guide to upgrade PostgreSQL 14 to 18. PostgreSQL 19 is due on 19 November 2026, but a fresh major is a poor landing spot for a box that has to leave 14 in a hurry; 18 has a year of minor fixes behind it.

Audit checklist for a patched fleet

Close the change only when every line holds on every host, standbys included. Each one is a check you can run, not an intention:

  1. SELECT version() reports 18.7, 17.12, 16.16, 15.20 or 14.25 on every running cluster.
  2. pg_postmaster_start_time() is later than the package upgrade on every cluster.
  3. The installed postgresql-client-NN or postgresqlNN package matches the server minor on every host that runs pg_dump, pg_restore, reindexdb or vacuumdb.
  4. Every standby shows streaming in pg_stat_replication on the primary.
  5. The find-reindex.sql work list has been run in every database, with CONCURRENTLY on live primaries.
  6. The NOT NULL NO INHERIT query returns zero rows on every 18 database.
  7. A new full backup exists, taken after the reindex, and incremental chains start from it.
  8. No superuser owns a logical replication subscription unless the publisher is fully trusted.
  9. plperl, pltcl and dblink exist only in databases that need them (SELECT extname FROM pg_extension;).
  10. Every PostgreSQL 14 cluster has a dated upgrade plan to 18.

Items 8 and 9 outlast this release. Many of the 8.8 bugs need a role that can create objects, and seven sit in a procedural language or dblink, so trimming CREATE rights and unused extensions narrows part of the next advisory. The bugs any login can reach are only closed by patching on time.

Keep reading

Java4Shell (CVE-2026-114938): Find and Patch Vulnerable JVMs Security Java4Shell (CVE-2026-114938): Find and Patch Vulnerable JVMs UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 Security UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 nginx HTTP/2 RCE CVE-2026-123007: Check, Disable HTTP/2, Patch Security nginx HTTP/2 RCE CVE-2026-123007: Check, Disable HTTP/2, Patch WP Rocket CVE-2026-125812: Check, Patch and Hunt Planted Files Security WP Rocket CVE-2026-125812: Check, Patch and Hunt Planted Files Enable Post-Quantum TLS in Nginx, Apache, HAProxy and OpenSSH Security Enable Post-Quantum TLS in Nginx, Apache, HAProxy and OpenSSH Patch Java4Shell (CVE-2026-114938) on RHEL, Rocky Linux and AlmaLinux Rocky Linux Patch Java4Shell (CVE-2026-114938) on RHEL, Rocky Linux and AlmaLinux

Leave a Comment

Press ESC to close