Redis Lua sandbox escape
The Lua sandbox in Redis could be escaped by loading malicious bytecode, allowing arbitrary code execution. An attacker with access to the Redis server could run system commands, though the response is not readable due to same-origin policy.
benmmurphy.github.io
Published on benmmurphy.github.io
It is possible to break out of the Lua sandbox in Redis and execute arbitrary code. This vulnerability is not new and is heavily based on Peter Cawley’s work with Lua bytecode type confusion.
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 Lua loadstring function allowed loading unsafe bytecode that bypassed the sandbox's type checks, leading to type confusion and arbitrary memory read/write.
Impact
An attacker could execute arbitrary code on the Redis server, but reading the response is blocked by the same-origin policy; DNS rebinding might bypass this, though the response is not valid HTTP.
What the attacker needed
Redis server reachable via HTTP; No password authentication; Victim visits malicious website
How it was found
- Run a browser console command to send a POST request to the Redis server on localhost.
- Observe that the Redis server executes the EVAL command and prints 'hello'.
- Use the same technique to send a malicious Lua script that exploits the sandbox escape.
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 run small scripts written in the Lua language. Normally these scripts are kept in a safe 'sandbox' so they cannot harm the computer. This report shows that a specially crafted script could break out of that sandbox and run any command on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.