RCE Exploits of Redis Based on Master-Slave Replication
An attacker can abuse Redis master-slave replication to load a malicious module on a victim Redis instance, leading to remote code execution. The attack involves setting the victim as a slave of a rogue master that sends a malicious .so file, which is then loaded as a module.
paper.seebug.org
Published on paper.seebug.org
On the WCTF2019 Final, which ends on July 7, 2019, the LC/BC member --Pavel Toporkov introduced a new RCE exploits of Redis at the showcase. Compared with the previous exploits, this one is more general and more harmful.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could execute arbitrary commands on the Redis server, leading to full compromise.
What the attacker needed
Redis instance accessible over network; Redis version 4.x or later (supports modules); Attacker can reach Redis port
How it was found
- Set up a rogue Redis server that will act as the master.
- Configure the victim Redis instance to replicate from the rogue server using SLAVEOF.
- The rogue server responds to the replication handshake with a FULLRESYNC and sends a malicious .so file.
- The victim saves the .so file (e.g., as exp.so) via CONFIG SET dbfilename.
- The victim loads the module with MODULE LOAD ./exp.so.
- The attacker connects to the victim and executes commands using the newly loaded module (e.g., system.exec).
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Redis is a database that can be set up so one server copies data from another (master-slave replication). An attacker can pretend to be the master and send a malicious file that Redis loads as a module, giving the attacker the ability to run commands on the victim server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.