Percona PMM Authenticated RCE via PostgreSQL COPY TO PROGRAM (CVE-2026-25212)
by 5170 (5170Temp) · 2026-07-05
- Severity
- Critical
- CVE
- CVE-2026-25212
- Category
- web
- Affected product
- Percona Monitoring and Management (PMM)
- Affected versions
- PMM < 3.7
- Disclosed
- 2026-07-05
- Patch status
- patched
Tags
References
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-06 |
| Author / Researcher | 5170 (5170Temp) |
| CVE / Advisory | CVE-2026-25212 |
| Category | web |
| Severity | Critical |
| CVSS Score | 9.9 |
| Status | PoC |
| Tags | rce, percona-pmm, postgresql, copy-to-program, grafana, privilege-escalation, command-execution |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | Percona Monitoring and Management (PMM) |
| Versions Affected | PMM < 3.7 |
| Language / Platform | Python 3 (PoC), targets PMM’s bundled Grafana web interface |
| Authentication Required | Yes (low-privilege pmm-admin account) |
| Network Access Required | Yes |
Summary
CVE-2026-25212 arises because PMM’s internal PostgreSQL user retains SUPERUSER privileges instead of being restricted. An attacker authenticated with only pmm-admin rights can use Grafana’s “Add data source” feature to register an arbitrary PostgreSQL data source pointed back at PMM’s own database, then submit a query via Grafana’s datasource-query API. Because the internal user is a superuser, the attacker can execute COPY (...) TO PROGRAM '<command>', which runs arbitrary OS commands on the PMM server and writes the output to a temp file that is then read back via a second COPY ... FROM query. This escalates a low-privileged authenticated web session directly to full server-side command execution.
Vulnerability Details
Root Cause
PMM’s internal PostgreSQL service account is over-privileged (retains SUPERUSER), which allows any authenticated user who can register a data source to abuse PostgreSQL’s COPY TO/FROM PROGRAM feature for OS command execution.
Attack Vector
- Authenticate to PMM/Grafana with a low-privilege
pmm-adminaccount and obtain thegrafana_sessioncookie. - Create a new PostgreSQL data source via
POST /graph/api/datasourcespointing atlocalhost:5432. - Use
POST /graph/api/ds/queryto runCOPY (SELECT 1) TO PROGRAM '<cmd> > /tmp/output 2>&1', executing an arbitrary shell command. - Run a second query to
COPYthe output file back into a temp table andSELECTit, exfiltrating command results through the query response. - Delete the temporary data source and remove the temp file to clean up traces.
Impact
Full remote code execution on the PMM server as the database service user, exposing all monitored infrastructure credentials and configuration accessible from that host.
Environment / Lab Setup
Target: Percona PMM instance < 3.7 with Grafana web UI reachable
Attacker: Python 3, `requests` library, valid grafana_session cookie
Proof of Concept
PoC Script
See
poc.pyin this folder.
| |
The script logs in with the supplied session cookie, registers a throwaway PostgreSQL data source, uses COPY ... TO PROGRAM to run the requested command and capture its output to a temp file, reads that output back through a second query, prints it, and then deletes the data source and temp file to clean up.
Detection & Indicators of Compromise
Signs of compromise:
- Unexpected
postgrestype data sources named likepoc_<timestamp>appearing and disappearing quickly - Files matching
/tmp/pwned_*or similar transient temp files on the PMM host - PostgreSQL query logs containing
TO PROGRAMorFROM PROGRAMfrom the internal monitoring account
Remediation
| Action | Detail |
|---|---|
| Primary fix | Upgrade to PMM 3.7 or later, which restricts the internal PostgreSQL user’s privileges |
| Interim mitigation | Restrict which users can create Grafana data sources; monitor/alert on COPY ... TO PROGRAM usage by the PMM internal database account |
References
Notes
Mirrored from https://github.com/5170Temp/CVE-2026-25212 on 2026-07-05.
| |