Currently, I am writing a sandbox in Lua. It's working so far, but I could use getfenv
for that function to get the scope outside the sandbox. For my sandbox, I filled an empty table with trusted functions and libraries. However, with functions such as print
, you could use getfenv
to get the global variable(s) in that scope. For example:
asd = "asd"
assert(pcall(assert(load([[
print(getfenv(print).asd) -- "asd"
]], nil, "t", {print = print, getfenv = getfenv}))))
This can obviously allow the "adversary" to bypass the sandbox.