[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua sandbox from c/c++
- From: Coda Highland <chighland@...>
- Date: Thu, 19 Apr 2012 09:22:10 -0500
On Thu, Apr 19, 2012 at 9:00 AM, Alex Queiroz <asandroq@gmail.com> wrote:
> Hallo,
>
> On Thu, Apr 19, 2012 at 3:57 PM, Coda Highland <chighland@gmail.com> wrote:
>>
>> I personally use "packages['io'] = true" so that subsequent calls to
>> "require('io')" won't import the module. But that can be thwarted by a
>> script that knows that this is done by calling "packages['io] = nil;
>> require('io')" so this isn't all that secure; in my project, it's
>> sufficient to remind my scripters that they're not supposed to be
>> doing that.
>>
>
> What's wrong with just not opening the 'io' library?
>
> --
> -alex
> http://www.artisancoder.com/
>
What if you need to expose CERTAIN functions out of a package?
Besides, io was just an example. In my app, I've got to require('ffi')
in order to expose C functions, but I don't want scripts to have
access to ffi.cdef() or any of the memory management functions. So I
load the library, cdef() my functions, put a reference to ffi.C in the
global environment, and then remove the ffi symbol from the
environment and intentionally break require()ing it again.
Currently I don't NEED anything more secure, since the only scripts
are coming from internal developers; this is more a sanity check than
anything else. I'll probably lock down the environment a little
tighter later when we start accepting user scripts.
/s/ Adam