
Exploit for Redis 8.2.1 Lua sandbox escape via deprecated APIs and mutable metatables, enabling cross-user command execution.
Sandbox escape via deprecated Lua APIs and mutable metatables on Redis 8.2.1.
Redis 8.2.1 keeps deprecated Lua builtins (getfenv, setfenv, newproxy) exposed to scripts and fails to lock metatables for basic types. An attacker can inject methods into shared metatables, capture privileged environments, and run commands with another user's permissions.
redis-cliCVE-2025-46818.lua – verifies deprecated builtins are present, patches the string metatable, and exposes a helper.# Setup
redis-cli -h localhost -p 6379 --eval CVE-2025-46818.lua
# Invoke the injected helper (assuming the victim user has higher privileges):
redis-cli -h localhost -p 6379 EVAL "return ('test').escalate()" 0
Expected result:
On 8.2.1 the initial script reports the deprecated APIs as true and confirms the metatable modification. The follow-up call returns the output of ACL WHOAMI (or whichever privileged command you swap in). Redis 8.2.2 removes the APIs by default, makes basic metatables read-only, and logs attempts.
Upgrade to Redis 8.2.2 or later, or disable Lua for untrusted users or run with lua-enable-deprecated-api no.