# CVE-2025-12818: PostgreSQL libpq undersizes allocations, via integer wraparound

> An attacker can cause a segmentation fault in applications using libpq by triggering an integer wraparound that leads to undersized memory allocations.

- **Severity:** Medium 5.9 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 13 Nov 2025
- **Updated:** 13 Nov 2025
- **Also known as:** ALPINE-CVE-2025-12818, ALSA-2026:0458, ALSA-2026:0525, ALSA-2026:0594, ALSA-2026:0695, AZL-70166, AZL-70202, AZL-74900, BELL-CVE-2025-12818, BIT-postgresql-2025-12818, CLEANSTART-2026-DY00588, CLSA-2026-1768413370, CLSA-2026-1768565904, CLSA-2026-1768910677, DEBIAN-CVE-2025-12818, ECHO-a3a3-6a88-8e40, GHSA-pr6x-gg24-6wfp, MINI-6rc9-w57h-93mp, MINI-m9v4-qwcc-xx36, MINI-mh59-cgg3-mhrq, MINI-vj32-phj6-h22m, MINI-w86v-w9v2-8787, MINI-xhv4-5wf9-mpf7, RHSA-2025:23123, RHSA-2025:23124, RHSA-2025:23157, RHSA-2025:23158, RHSA-2026:0458, RHSA-2026:0594, RHSA-2026:0695, RHSA-2026:0744, RHSA-2026:0745, RHSA-2026:0746, RHSA-2026:0835, RHSA-2026:0865, RLSA-2026:0458, RLSA-2026:0525, RLSA-2026:0594, RLSA-2026:0695, UBUNTU-CVE-2025-12818

## What is CVE-2025-12818?

CVE-2025-12818 is a medium-severity vulnerability in PostgreSQL, published on 13 Nov 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Integer wraparound in multiple PostgreSQL libpq client library functions allows an application input provider or network peer to cause libpq to undersize an allocation and write out-of-bounds by hundreds of megabytes.  This results in a segmentation fault for the application using libpq.  Versions before PostgreSQL 18.1, 17.7, 16.11, 15.15, 14.20, and 13.23 are affected.

Weakness: CWE-190 (Integer Overflow or Wraparound)

## Which versions are affected by CVE-2025-12818?

1 open source package ship an affected version, including postgresql.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `postgresql` | Bitnami | All versions | 13.23.0, 14.20.0, 15.15.0, 16.11.0, 17.7.0, 18.1.0 |
| `libpq` | AlmaLinux:10 | All versions | 16.11-3.el10_1 |
| `libpq-devel` | AlmaLinux:10 | All versions | 16.11-3.el10_1 |
| `postgresql-test-rpm-macros` | AlmaLinux:10 | All versions | 16.11-1.el10_1 |
| `libpq` | AlmaLinux:8 | All versions | 13.23-1.el8_10 |
| `libpq-devel` | AlmaLinux:8 | All versions | 13.23-1.el8_10 |
| `libpq` | AlmaLinux:9 | All versions | 13.23-1.el9_7 |
| `libpq-devel` | AlmaLinux:9 | All versions | 13.23-1.el9_7 |
| `libpq` | Red Hat:enterprise_linux:10.1 | All versions | 0:16.11-3.el10_1 |
| `libpq-debuginfo` | Red Hat:enterprise_linux:10.1 | All versions | 0:16.11-3.el10_1 |
| `libpq-debugsource` | Red Hat:enterprise_linux:10.1 | All versions | 0:16.11-3.el10_1 |
| `libpq-devel` | Red Hat:enterprise_linux:10.1 | All versions | 0:16.11-3.el10_1 |
| `libpq-devel-debuginfo` | Red Hat:enterprise_linux:10.1 | All versions | 0:16.11-3.el10_1 |
| `libpq` | Red Hat:enterprise_linux:8::appstream | All versions | 0:13.23-1.el8_10 |
| `libpq-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:13.23-1.el8_10 |
| `libpq-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:13.23-1.el8_10 |
| `libpq-devel` | Red Hat:enterprise_linux:8::appstream | All versions | 0:13.23-1.el8_10 |
| `libpq-devel-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:13.23-1.el8_10 |
| `libpq` | Red Hat:enterprise_linux:9::appstream | All versions | 0:13.23-1.el9_7 |
| `libpq-debuginfo` | Red Hat:enterprise_linux:9::appstream | All versions | 0:13.23-1.el9_7 |
| `libpq-debugsource` | Red Hat:enterprise_linux:9::appstream | All versions | 0:13.23-1.el9_7 |
| `libpq-devel` | Red Hat:enterprise_linux:9::appstream | All versions | 0:13.23-1.el9_7 |
| `libpq-devel-debuginfo` | Red Hat:enterprise_linux:9::appstream | All versions | 0:13.23-1.el9_7 |
| `libpq` | Red Hat:enterprise_linux_eus:10.0 | All versions | 0:16.11-1.el10_0 |
| `libpq-debuginfo` | Red Hat:enterprise_linux_eus:10.0 | All versions | 0:16.11-1.el10_0 |
| `libpq-debugsource` | Red Hat:enterprise_linux_eus:10.0 | All versions | 0:16.11-1.el10_0 |
| `libpq-devel` | Red Hat:enterprise_linux_eus:10.0 | All versions | 0:16.11-1.el10_0 |
| `libpq-devel-debuginfo` | Red Hat:enterprise_linux_eus:10.0 | All versions | 0:16.11-1.el10_0 |
| `libpq` | Red Hat:rhel_aus:8.2::appstream | All versions | 0:12.7-1.el8_2.3 |
| `libpq-debuginfo` | Red Hat:rhel_aus:8.2::appstream | All versions | 0:12.7-1.el8_2.3 |
| `libpq-debugsource` | Red Hat:rhel_aus:8.2::appstream | All versions | 0:12.7-1.el8_2.3 |
| `libpq-devel` | Red Hat:rhel_aus:8.2::appstream | All versions | 0:12.7-1.el8_2.3 |
| `libpq-devel-debuginfo` | Red Hat:rhel_aus:8.2::appstream | All versions | 0:12.7-1.el8_2.3 |
| `libpq` | Red Hat:rhel_aus:8.4::appstream | All versions | 0:13.23-1.el8_4 |
| `libpq-debuginfo` | Red Hat:rhel_aus:8.4::appstream | All versions | 0:13.23-1.el8_4 |
| `libpq-debugsource` | Red Hat:rhel_aus:8.4::appstream | All versions | 0:13.23-1.el8_4 |
| `libpq-devel` | Red Hat:rhel_aus:8.4::appstream | All versions | 0:13.23-1.el8_4 |
| `libpq-devel-debuginfo` | Red Hat:rhel_aus:8.4::appstream | All versions | 0:13.23-1.el8_4 |
| `libpq` | Red Hat:rhel_aus:8.6::appstream | All versions | 0:13.23-1.el8_6 |
| `libpq-debuginfo` | Red Hat:rhel_aus:8.6::appstream | All versions | 0:13.23-1.el8_6 |

## How do I fix CVE-2025-12818?

Upgrade postgresql to a fixed version for your release line: 13.23.0, 14.20.0, 15.15.0 or 16.11.0.

## Is CVE-2025-12818 being exploited?

There is no known exploitation of CVE-2025-12818 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-12818 and fix it if it is affected.

What it is: CVE-2025-12818 is a medium-severity vulnerability in PostgreSQL, published on 13 Nov 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2025-12818 in the wild and no public exploit code.

Affected packages and fixed versions:
- postgresql (Bitnami): affected all versions; fixed in 13.23.0, 14.20.0, 15.15.0, 16.11.0, 17.7.0, 18.1.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-12818/ (Markdown: https://insights.sbomify.com/CVE-2025-12818/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-12818
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-12818
- OSV: https://osv.dev/vulnerability/CVE-2025-12818

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-12818/
Summaries are generated and may contain mistakes; the official description above is the record.
