Into the rabbit hole: Exploitation process of Redis and RabbitMQ
An unauthenticated Redis instance allowed arbitrary file writes, which the author combined with a Windows binary-hijacking weakness in RabbitMQ to place a malicious batch file that the service executed. This gave remote command execution and a reverse shell running as the SYSTEM account.
medium.com
Published on medium.com
In this article, I will walk you through the technical aspects and the exploitation steps I took to compromise the Redis server to remote command execution when the obvious or published information online did not provide the answer. while conducting this research my college Tomer Hadad and I have found and responsibly…
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
Root cause
Likely the combination of an unauthenticated Redis instance permitting arbitrary file writes and RabbitMQ's unqualified search for an executable in a user-writable directory, which let a planted batch file be executed by the service.
Impact
An attacker could write arbitrary files and, by planting a batch file in the RabbitMQ directory, gain remote command execution and a reverse shell as the SYSTEM account; the author notes that write locations depend on the permissions of the user running Redis.
What the attacker needed
Network access to Redis port; Redis runs without authentication; RabbitMQ installed on Windows; attacker can write to RabbitMQ directory
The fix
Redis should require authentication and bind to trusted interfaces, and RabbitMQ should not search for executables in user-writable directories.
How it was found
- Scan the remote hosts to identify the operating system and exposed services.
- Connect to the Redis instance and confirm no authentication is required.
- Use Redis commands to set the target directory and filename and save attacker-controlled content to disk.
- Return to reconnaissance and find RabbitMQ with its management plugin exposed.
- Build a lab with the same versions and use Process Monitor to see which files the service searches for.
- Plant a batch file in the RabbitMQ directory via Redis and obtain a reverse shell.
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 fast database that normally listens on a network port; here it accepted connections with no password at all. Redis can also save its data to a file on disk, so an attacker could choose the folder and filename and write almost any content there. RabbitMQ, a message queue service, looked for a helper program in a folder the attacker could write to, so the planted file was run automatically as the service's own user.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.