Possible Duplicates:
How can I limit lua possibilities (calling OS functions, modules, etc.)
How can I create a secure Lua sandbox?
luaL_openlibs(m_pState);
I use this function to load all the libs.I would like to skip all the dangerous libs like IO but I just cant find any documentation on how to disable a lib.
How do I disable certain libs? Are there more dangerous libs that can gain the script access to the system?
LuaSandbox is an extension for PHP 7 and PHP 8 to allow safely running untrusted Lua 5.1 code from within PHP, which will generally be faster than shelling out to a Lua binary and using inter-process communication.
This means that all values can be stored in variables, passed as arguments to other functions, and returned as results. There are eight basic types in Lua: nil, boolean, number, string, function, userdata, thread, and table.
The lua_State is basically a way to access what's going on in the Lua "box" during execution of your program and allows you to glue the two languages together.
Add a copy of linit.c
to your project and remove any libraries that you deem dangerous. To remove individual functions, set them to nil. See also the source of the Lua demo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With