---
id: "CVE-2026-120149"
page: "https://infrastack.ai/live/CVE-2026-120149"
kind: "vulnerability"
aliases: ["CVE-2026-120149"]
title: "PostgreSQL: foreign batch inserts overflow heap, letting a foreign server run code"
severity: "high"
cvss: 8.8
epss: null
exploited: false
status: "open"
category: "runtime"
products: []
ecosystems: []
tags: ["database", "postgres_fdw", "postgresql", "runtime", "self-hosted"]
not_affected_if: ["fixed-version", "no-postgres-fdw"]
published_at: "2026-11-12T15:17:43+00:00"
first_seen_at: "2026-11-12T15:41:56+00:00"
updated_at: "2026-11-12T15:43:11+00:00"
sources: [{"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-120149", "first_seen_at": "2026-11-12T15:41:56+00:00"}]
exploit_sources: []
---

# PostgreSQL: foreign batch inserts overflow heap, letting a foreign server run code

Link for people: https://infrastack.ai/live/CVE-2026-120149 (this .md is for agents)

PostgreSQL's postgres_fdw extension mishandles the row count returned by a remote server during batch inserts, causing a heap buffer overflow. A malicious or compromised foreign server can use this to execute arbitrary code on the PostgreSQL instance that connects to it.

_Summary, check and fix written by a model from the sources; labelled as such._

## How to check

- Check the server version with `psql -c "SHOW server_version;"`, then compare against the fixed versions below.
- Check whether the postgres_fdw extension is installed with `psql -c "\dx postgres_fdw"`.

## Fix

- PostgreSQL 18: move to `18.7`
- PostgreSQL 17: move to `17.12`
- PostgreSQL 16: move to `16.16`
- PostgreSQL 15: move to `15.20`
- PostgreSQL 14: move to `14.25`

## Timeline

- 2026-11-12T15:41:56+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-120149

## From the sources

Heap-based buffer overflow in PostgreSQL foreign batch inserts allows a foreign server to execute arbitrary code, via reporting that it inserted more rows than the server supplied.  postgres_fdw can legitimately encounter this when a rule on the remote table expands an INSERT into additional rows.  Versions before PostgreSQL 18.7, 17.12, 16.16, 15.20, and 14.25 are affected.

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
