lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Josh Simmons wrote:
>> - Code may loop forever, especially a 3rd party untrusted code, which you may want to run by loading scripts
> You cannot stop this from Lua (without removing _all_ C functions from
> the sandbox), you need to use threading or processes at the OS level
> to limit access to resources.

I guess it is not too hard to review the C functions from the integrated
libraries for this.  Besides the functions you obviously wouldn't put in
a sandbox (file access, debug functions, etc.) the pattern matching and
string repetition come to my mind as being potentially dangerous for
consuming lots of time or memory without triggering Lua hooks.

An alternative to using Lua hooks might be to copy the Lua parser into
an own library and patch it to include a call to yield at the end of any
loop (and in Lua 5.2 for any goto that jumps backwards).  The debug
hooks might be more efficient for small loops with high repetition
counts though.

Best regards,

David Kolf