Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable the risky functions in lua the easiest way possible? [duplicate]

Tags:

c++

security

lua

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?

like image 995
Milkman Avatar asked Aug 08 '11 04:08

Milkman


People also ask

What is Lua sandbox?

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.

How many functions does Lua have?

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.

What are Lua States?

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.


1 Answers

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.

like image 128
lhf Avatar answered Oct 19 '22 23:10

lhf