PostgreSQL 18.7 update: 52 CVEs, and the indexes you must rebuild after updating
PostgreSQL 18.7, 17.12, 16.16, 15.20 and 14.25 fix 52 CVEs, 32 rated 8.8. Updating is not enough: queries to find the GIN, pg_trgm and bpchar indexes to rebuild.
On this page
- Who can exploit the 52 CVEs
- Step 1: update the binaries
- Step 2: find what needs work
- GIN indexes (reindex if you suspect corruption)
- pg_trgm GiST indexes (reindex all of them)
- B-tree indexes on bpchar without a length (reindex)
- “missing chunk number” errors (reindex the table)
- Incremental backups (take a new full backup)
- NOT NULL NO INHERIT on partitioned tables (find and repair)
- Step 3: rebuild without blocking writes
- The checklist
- And PostgreSQL 19?
- FAQ
- Sources
On 2026-11-12 the PostgreSQL project released 18.7, 17.12, 16.16, 15.20 and 14.25 (announcement). Minor releases are normally the boring kind of update: stop the server, swap the binaries, start it again. This one is different in two ways:
- It closes 52 security vulnerabilities. 32 of them are rated CVSS 8.8, and most of those let any role that can log in run code as the database server’s operating-system user.
- Several of the bug fixes stop new corruption but do not repair existing indexes. You have to find those indexes and rebuild them yourself, after the update.
It is also the last release of PostgreSQL 14, which is now end-of-life.
The announcement says what to do in general terms (“if you have B-tree indexes on bpchar columns…”). This post turns that into something you can run: who is exposed to the CVEs, catalog queries that list exactly the indexes and constraints that need work, and the order to do it in. Everything comes from the announcement and the 18.7 release notes. I have not run these queries against a vulnerable server; they only read the system catalogs and change nothing.
Who can exploit the 52 CVEs
The announcement lists a CVSS v3.1 vector for each CVE. Grouping them by the privileges an attacker needs (the PR and UI fields) gives a clearer picture than the raw count:
| What the attacker needs | CVEs | Rated 7.0 or higher |
|---|---|---|
Any role that can log in (PR:L) |
44 | 32 |
A privileged role, such as a database owner or an extension installer (PR:H) |
3 | 3 |
No login, but you restore their dump or subscribe to their publisher (PR:N, UI:R) |
3 | 3 |
No login and no help from you (PR:N, UI:N) |
2 | 0 |
The two that need nothing are the mildest: a pre-authentication cancel request that can leak a spinlock (5.3, denial of service) and a pg_basebackup format-string bug that needs unusual file names in the data directory (3.7). Nothing here is an “anyone on the internet” remote code execution.
What should worry you is the first row. 31 of the 52 CVE titles say the bug executes code: type confusion, use-after-free and integer wraparound bugs in PL/Perl, PL/Tcl, PL/pgSQL, the planner, statistics import and more. If everyone who can log in to your database is someone you would trust with a shell on the server, these are ordinary bugs. If you hand out logins more widely (a shared analytics database, per-tenant roles, BI tools, scripts or AI agents that run generated SQL), the boundary between a SQL role and the server’s OS account is exactly what these CVEs break. Patch those servers first.
Two other details matter in practice:
- Six CVEs are in client programs, not the server:
pg_restore(CVE-2026-116314),pg_dump’s tar-formatrestore.sql(CVE-2026-116330), the not-null constraint name inpg_dump(CVE-2026-116318),reindexdb(CVE-2026-116325),vacuumdb(CVE-2026-116313) andpg_basebackup(CVE-2026-16240). Upgrading the server package does nothing for thepg_dumpon a laptop, in a CI image or in a backup container. Update those too, and don’t restore dumps from sources you don’t trust with older client binaries. - Logical replication: CVE-2026-120145 lets a malicious publisher write to the subscriber’s system catalogs and execute code there. If you subscribe to a publisher run by someone else (a vendor or a partner team), update the subscriber.
The 18.7 release notes credit 20 of these vulnerabilities to reports from Anthropic’s OSS program, often together with other researchers. That is a sign of how much automated vulnerability research now reaches mature C code bases. Expect more large security releases like this one.
Step 1: update the binaries
As always for a minor release, no dump/restore or pg_upgrade is needed: stop the server, install the new packages, start it (announcement, “Updating”). Do the index work after this step. The fixes stop new damage. If you rebuild first, the old binaries can damage the index again.
If you skipped earlier minor releases, also read the “Migration” note of each one you skipped. The 18.7 notes point to 18.6 for anyone coming from an earlier 18.x.
Step 2: find what needs work
GIN indexes (reindex if you suspect corruption)
The release fixes several GIN bugs that “could lead to index corruption, causing queries to miss rows or to return unrelated rows”. One of them, from the release notes: when a single VACUUM had to scan an index more than once (it was removing more dead rows than fit in its memory), some GIN entries were not removed. That “would eventually lead to a corrupt index with entries pointing at unrelated table rows”. So the GIN indexes most at risk sit on large tables with heavy deletes or updates, vacuumed with a small maintenance_work_mem / autovacuum_work_mem.
List them with their sizes:
SELECT i.indexrelid::regclass AS index_name,
i.indrelid::regclass AS table_name,
pg_size_pretty(pg_relation_size(i.indexrelid)) AS index_size
FROM pg_index i
JOIN pg_class c ON c.oid = i.indexrelid
JOIN pg_am am ON am.oid = c.relam
WHERE am.amname = 'gin'
ORDER BY pg_relation_size(i.indexrelid) DESC;
PostgreSQL 18’s amcheck has a gin_index_check() function. Its documentation describes it as checking the tree structure (parent-child relations and the page graph). It does not say it verifies that entries point to the right table rows, which is the damage described above. So a clean gin_index_check() does not prove the index is fine. If an index is on a table matching the risk profile, or if a query using it ever returned a row that didn’t match, rebuild it.
pg_trgm GiST indexes (reindex all of them)
This one is not optional. A pg_trgm GiST bug could “lose the flag identifying their format, so that subsequent index searches could miss matching rows”, and “this fix does not repair existing indexes”. Every index using the gist_trgm_ops operator class should be rebuilt. GIN trigram indexes (gin_trgm_ops) are not part of this fix, but they are GIN indexes, so the previous section applies to them:
SELECT DISTINCT i.indexrelid::regclass AS index_name,
i.indrelid::regclass AS table_name
FROM pg_index i
JOIN pg_opclass oc ON oc.oid = ANY (i.indclass)
WHERE oc.opcname = 'gist_trgm_ops';
B-tree indexes on bpchar without a length (reindex)
B-tree deduplication (on by default since PostgreSQL 13) is unsafe for bpchar declared without a length. As the release notes explain, “bpchar equality ignores trailing spaces, values of different lengths can compare equal”, and index-only scans could then return “subtly wrong results”. The fix turns deduplication off for new entries only, so existing indexes need a rebuild. char(n) columns are not affected, because the length makes equal values bitwise equal.
A column is “bpchar without a length” when its type is bpchar and atttypmod is −1:
SELECT DISTINCT i.indexrelid::regclass AS index_name,
i.indrelid::regclass AS table_name,
a.attname AS column_name
FROM pg_index i
JOIN pg_class c ON c.oid = i.indexrelid
JOIN pg_am am ON am.oid = c.relam AND am.amname = 'btree'
JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY (i.indkey)
WHERE a.atttypid = 'bpchar'::regtype
AND a.atttypmod = -1;
This catches plain column indexes. It does not catch expression indexes that produce bpchar or columns with a domain over bpchar. Unusual, but check by hand if you use either.
“missing chunk number” errors (reindex the table)
A bug let later index updates go missing after REINDEX CONCURRENTLY had rebuilt an index on a TOAST table. The symptom is missing chunk number … for toast value … when reading the table. If you have seen that error, run REINDEX TABLE on the table after updating; it also rebuilds the TOAST table’s index. If you never saw the error, there is nothing to do.
Incremental backups (take a new full backup)
PostgreSQL 17 added incremental backups (pg_basebackup --incremental, which needs summarize_wal = on). The release notes say existing incremental backup files “should not be trusted” because of “several ways that they could become corrupt”. If SHOW summarize_wal; returns on, you are probably using them. Take a new full backup after updating and base later incremental backups on it. The chain you have now is still a backup, just not one to rely on.
NOT NULL NO INHERIT on partitioned tables (find and repair)
PostgreSQL 18 records NOT NULL constraints in pg_constraint, and it allowed NO INHERIT ones on partitioned tables. In that case a partition could contain NULLs in a column the parent declares NOT NULL. The update forbids it, but existing constraints stay. The announcement gives this query:
SELECT conrelid::regclass, conname
FROM pg_constraint
WHERE contype = 'n' AND connoinherit
AND conrelid IN (SELECT oid FROM pg_class WHERE relkind = 'p');
For each row, either drop the constraint (ALTER TABLE … DROP CONSTRAINT …) or make it inherit (ALTER TABLE … ALTER CONSTRAINT … INHERIT). The second fails if a partition already holds NULLs, which is how you find out it did.
Step 3: rebuild without blocking writes
A plain REINDEX INDEX blocks writes to the table while it runs. On a busy production table, use REINDEX INDEX CONCURRENTLY name; (docs). It takes longer and needs room for a second copy of the index, but reads and writes continue. Rebuild one index at a time; each concurrent rebuild waits for transactions that are already running, so check for long-running transactions first. If a concurrent rebuild fails, it leaves an index marked INVALID (named with the suffix _ccnew), which you drop and retry.
To generate the commands from any of the queries above, wrap them, for example:
SELECT format('REINDEX INDEX CONCURRENTLY %s;', i.indexrelid::regclass)
FROM pg_index i
JOIN pg_opclass oc ON oc.oid = ANY (i.indclass)
WHERE oc.opcname = 'gist_trgm_ops'
GROUP BY i.indexrelid;
The checklist
| Action | Who | Required? |
|---|---|---|
| Update server binaries to 18.7 / 17.12 / 16.16 / 15.20 / 14.25 | Everyone | Yes, especially if untrusted roles can log in |
Update client tools (pg_dump, pg_restore, psql, reindexdb, vacuumdb, pg_basebackup) |
Laptops, CI images, backup jobs | Yes |
Reindex gist_trgm_ops indexes |
pg_trgm users |
Yes |
Reindex B-tree indexes on length-less bpchar |
Anyone with such columns | Yes |
| New full backup | Incremental backup users (17+) | Yes |
Fix NOT NULL NO INHERIT on partitioned tables |
PostgreSQL 18 | If the query returns rows |
| Reindex GIN indexes | Heavy-churn tables, or any sign of wrong results | If in doubt |
REINDEX TABLE |
Tables that showed “missing chunk number” | If you saw it |
| Plan the move off 14 | PostgreSQL 14 users | 14 is now end-of-life |
And PostgreSQL 19?
The same release is 19 RC 2, and general availability is planned for 2026-11-19. One fix matters if you have been testing 19. A change that allowed JSON_ARRAY() and JSON_OBJECT() over arrays, composite and range types in expression indexes, generated columns and partition keys was reverted, because those indexes could go stale. If you created such objects in a test database, drop or redefine them before upgrading; dump/restore and pg_upgrade will fail to recreate them. Also, if you use pg_upgrade to move to 19 and have full-text search, pg_trgm or fuzzystrmatch indexes, read the 19 migration notes: you may need to reindex those too.
FAQ
Do I need pg_upgrade or a dump/restore for 18.7? No. It is a minor release: replace the binaries and restart. The extra steps are reindexing specific indexes and, for incremental backups, a new full backup.
Which PostgreSQL CVEs in this release are the most serious? 32 are rated CVSS 8.8, almost all “any role that can log in can execute arbitrary code”. None lets an unauthenticated attacker run code without help: the three no-login code-execution bugs need you to restore their dump or subscribe to their publisher.
Do I really need to reindex after a minor update?
For gist_trgm_ops indexes and B-tree indexes on length-less bpchar, yes: the fixes don’t repair existing entries. For GIN indexes, only if you suspect corruption, and gin_index_check() alone can’t rule it out.
Can I reindex without downtime?
Yes, with REINDEX INDEX CONCURRENTLY, one index at a time, after the update.
Is PostgreSQL 14 still supported? No. 14.25 is its last release. Plan the upgrade; 19 is due on 2026-11-19.
Sources
- PostgreSQL 18.7, 17.12, 16.16, 15.20, 14.25, and 19 RC 2 Released! (2026-11-12): CVE list with CVSS vectors, the “Updating” section and the NOT NULL query.
- Release notes for 18.7: details of the GIN, pg_trgm, bpchar and incremental-backup fixes, and the CVE credits.
- amcheck, REINDEX, versioning policy.