mlua
mlua copied to clipboard
Is it possible to sandbox lua functionalities?
I am working on a plugin system and would like to explicitly whitelist permissions to access any native functionality. By default, lua should not access anything external (no network, I/O) unless permission has been granted. Is this possible?
https://docs.rs/mlua/latest/mlua/struct.Lua.html#method.new_with you already can limit which stdlib code is loaded when creating Lua object. and then you can simply provide custom host bindings which will add custom limitations etc..
Lua does have api's for this however sandboxing is, as always hard to get right. You can probably use https://github.com/kikito/lua-sandbox as a starting point if nothing else. It is a single lua file so you should be able to just embed it in your rust binary and go from there.
No need for mlua to do anything else.