From efa162bcd7ab1477c07d8ee85537e27c0cb1524b Mon Sep 17 00:00:00 2001 From: meir Date: Tue, 15 Feb 2022 20:18:49 +0200 Subject: Protect any table which is reachable from globals and added globals white list. The white list is done by setting a metatable on the global table before initializing any library. The metatable set the `__newindex` field to a function that check the white list before adding the field to the table. Fields which is not on the white list are simply ignored. After initialization phase is done we protect the global table and each table that might be reachable from the global table. For each table we also protect the table metatable if exists. --- src/script_lua.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/script_lua.h') diff --git a/src/script_lua.h b/src/script_lua.h index e6ca4f730..4c2b34804 100644 --- a/src/script_lua.h +++ b/src/script_lua.h @@ -68,7 +68,9 @@ typedef struct errorInfo { void luaRegisterRedisAPI(lua_State* lua); sds luaGetStringSds(lua_State *lua, int index); void luaRegisterGlobalProtectionFunction(lua_State *lua); -void luaSetGlobalProtection(lua_State *lua); +void luaSetErrorMetatable(lua_State *lua); +void luaSetAllowListProtection(lua_State *lua); +void luaSetTableProtectionRecursively(lua_State *lua); void luaRegisterLogFunction(lua_State* lua); void luaRegisterVersion(lua_State* lua); void luaPushErrorBuff(lua_State *lua, sds err_buff); -- cgit v1.2.1