Proof of Concept: PostgreSQL CVE-2025–8714
PostgreSQL's psql client executed meta commands embedded in a plain-format dump during restore, so a crafted dump file could run operating system commands on the machine performing the restore. An attacker who could get a malicious dump restored could achieve code execution, for example a reverse shell.
medium.com
Published on medium.com
The vulnerability has a severity score (CVSS 3.1) of 8.8 (High) and affects all PostgreSQL versions before 17.6, 16.10, 15.14, 14.19 and 13.22. The updates have been released, and all users are advised to upgrade.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely psql processed backslash meta commands, including shell escapes, found inside a plain-format dump during restore instead of treating the file purely as data.
Impact
An attacker could achieve code execution on the restoring system, potentially obtaining a reverse shell or damaging the system.
What the attacker needed
Attacker-supplied dump file; victim restores it with psql
The fix
It was fixed in PostgreSQL 17.6, 16.10, 15.14, 14.19 and 13.22, and users should also prefer custom-format dumps restored with pg_restore.
How it was found
- Create a database and generate a plain-format dump with pg_dumpall, or write a minimal dump file by hand.
- Append a psql meta command that runs an operating system command to the dump file.
- Place the tampered dump on the target machine.
- Restore it with psql, which executes the embedded command and writes the payload file.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A database dump is a text file holding a copy of a database, and psql is the tool that loads it back in. This dump format also allows special lines starting with a backslash that tell psql to run things, including operating system commands. Because psql trusted those lines in a file that may come from someone else, restoring a tampered dump could run the attacker's commands on your machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.