CVE-2025-46818 – Redis Lua Sandbox Cross-User Escape# CVE-2025-46818 – Redis Lua Sandbox Cross-User Escape
Sandbox escape via deprecated Lua APIs and mutable metatables on Redis 8.2.1.
## Overview
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.
## Environment
- Redis server 8.2.1 (or any vulnerable release before 8.2.2)
- `redis-cli`
- Local network access to the Redis instance
## Files
- [`CVE-2025-46818.lua`](/CVE-2025-46818.lua) – verifies deprecated builtins are present, patches the string metatable, and exposes a helper.
## Usage
```bash
# 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.
## Mitigation
Upgrade to Redis 8.2.2 or later, or disable Lua for untrusted users or run with `lua-enable-deprecated-api no`.
[4.0K] /data/pocs/7f2c9e1dddbc10e856ac55dbb588c700c7d9a38d
├── [1.5K] CVE-2025-46818.lua
└── [1.4K] README.md
1 directory, 2 files