Looks insecure as hell. I can still eval using the Function constructor, parsing code with regexes is an awful idea, it's still possible to use the constructors of stuff passed into the vm to get the outside Function thingie and I can probably still crawl up the caller chain. This is a bad approach anyway. The new process shouldn't be a node process, it should be a v8 process.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
withwhile(true) {}
But I will try uglifyJS.while(true) { if(timeout.excceded()) break; }
What about (function(){}).constructor? Really, this is the wrong approach, please stop this.
Am 23.10.2011 14:44 schrieb "arunoda.s...@gmail.com" <arunoda.s...@gmail.com>:
Hi,I've done measures to prevent Function Constructor [0]See whether it is working or not.cheers.
On Sun, Oct 23, 2011 at 5:18 PM, arunoda.s...@gmail.com <arunoda.s...@gmail.com> wrote...
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
> remove ALL globals from node by setting them to undefined (not null)
Why undefined not null ?
--
Jorge.
> remove ALL globals from node / everything reasonable to lock down the environment.
Which are the reasonable ones ?
Object.getOwnPropertyNames(function(){return this}())
[
** 'clearInterval',
'TypeError',
'decodeURI',
** 'Buffer',
'parseFloat',
'Number',
'URIError',
'encodeURIComponent',
'RangeError',
'ReferenceError',
'RegExp',
'Array',
'isNaN',
** 'setTimeout',
** 'console',
'Date',
'Infinity',
'Uint32Array',
'Boolean',
'Float32Array',
'Error',
** 'root',
'NaN',
** 'module',
'Uint8Array',
'DataView',
** 'require',
'Int32Array',
'String',
'Function',
'Math',
'undefined',
'encodeURI',
'Int16Array',
'escape',
'unescape',
** 'process',
'decodeURIComponent',
'EvalError',
** 'clearTimeout',
** 'GLOBAL',
'Int8Array',
** 'setInterval',
'Float64Array',
'SyntaxError',
'Object',
'eval',
** 'global',
'Uint16Array',
'parseInt',
'ArrayBuffer',
'JSON',
'isFinite' ]
The ones marked with ** ?
--
Jorge.
> I think that instead of launching a new node process and then try to disable all its node-specific functionality, perhaps you could just launch a plain vanilla JS whose only io were nothing but a print() (such as d8 or jsc), and receive its output by reading its stdout.
Forget jsc, it's got debug, run and load. (and a nice readline). Perhaps node would need a switch to launch it in plain-vanilla-js mode: node --plainVanillaJS srcFile.js ?
$ jsc
> Object.getOwnPropertyNames(function(){return this}()).toString().replace(/\,/g,'\n')
Math
NaN
undefined
Infinity
JSON
Object
Function
Array
Boolean
String
Number
Date
RegExp
Error
EvalError
RangeError
ReferenceError
SyntaxError
TypeError
URIError
eval
** debug
print
quit
gc
version
** run
** load
** checkSyntax
readline
preciseTime
arguments
encodeURIComponent
decodeURIComponent
unescape
isFinite
parseFloat
isNaN
parseInt
encodeURI
escape
decodeURI
--
Jorge
Just run the code in a child process, as a user with no privileges, in
a chroot (or better yet, a vm/zone/jail), monitor the memory usage and
kill it after a timeout, and if you must, communicate with it through
message-passing only. It's not perfect, but you can be damn sure that
your operating system is a lot better at this sort of thing than any
of us are, and it's a lot easier than the hoops that everyone is
trying to jump through here.
All the stuff about restricting globals or whatever is kind of
pointless at that point. Just lock down the underlying system, and
then it doesn't matter.
It's been bradl...@joyent.com who suggested that.
In any case, it does not matter what functionality node provides as long as you don't have access to it.
And given that all of node functionality comes from a bunch of globals (afaics), if you just delete them soon enough, the game of node is over, and you're left with a plain vanilla JS vm.
Or not?
--
Jorge.
Not necessarily. arguments.callee.caller.caller.arguments for example even can get out of the jail context.
Am 24.10.2011 16:00 schrieb "Jorge" <jo...@jorgechamorro.com>:
On 24/10/2011, at 10:12, Isaac Schlueter wrote:
>
> All the stuff about restricting globals or what...
It's been bradl...@joyent.com who suggested that.
In any case, it does not matter what functionality node provides as long as you don't have access to it.
And given that all of node functionality comes from a bunch of globals (afaics), if you just delete them soon enough, the game of node is over, and you're left with a plain vanilla JS vm.
Or not?
--
Jorge.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mail...
It should be a strict mode function as your communication channel, this will break the caller chain as well as avoid argument injection.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
> All globals are reasonable to remove. The child context will get new built-ins, except setTimeout/setInterval.
setTimeout/setInterval leak some (and perhaps it's something to worry about) internal details:
setTimeout(Array,22222)
{ _idleTimeout: 22222,
_onTimeout: [Function: Array],
_idlePrev: { repeat: 22, _idleNext: [Circular], _idlePrev: [Circular], callback: [Function] },
_idleNext: { repeat: 22, _idleNext: [Circular], _idlePrev: [Circular], callback: [Function] },
_idleStart: Mon, 24 Oct 2011 16:04:25 GMT }
> Set it to undefined instead of null (this could be using the delete operator it does not really matter). Object.getPrototypeOf(null) gets the object prototype
Not in my book:
Object.getPrototypeOf(null)
TypeError: Object.getPrototypeOf called on non-object
at Function.getPrototypeOf (native)
at repl:1:8
at Interface.<anonymous> (repl.js:168:22)
at Interface.emit (events.js:67:17)
at Interface._onLine (readline.js:153:10)
at Interface._line (readline.js:408:8)
at Interface._ttyWrite (readline.js:585:14)
at ReadStream.<anonymous> (readline.js:73:12)
at ReadStream.emit (events.js:88:20)
at ReadStream._emitKey (tty_posix.js:306:10)
> , and allows prototype attacks should someone get a reference to the parent context (possible if leaking closure from type coersion etc. via your communication layer).
>
> If you really need the globals for later, just cache a reference to them.
Exactly.
But, how would it (the node child process) write to stdout without node's functionality ?
--
Jorge.
> You realize that what you're discussing here is a blacklist, which has
> been shown again and again to be an ineffective approach to security?
> If you have any thread back to the original context at all, it's going
> to be a hole. You'll never plug all of them. The only effective
> security is a small whitelist of allowed behaviors, in an isolated
> environment, where every message coming out is scrutinized by the
> parent process.
>
> Just run the code in a child process, as a user with no privileges, in
> a chroot (or better yet, a vm/zone/jail), monitor the memory usage and
> kill it after a timeout, and if you must, communicate with it through
> message-passing only. It's not perfect, but you can be damn sure that
> your operating system is a lot better at this sort of thing than any
> of us are, and it's a lot easier than the hoops that everyone is
> trying to jump through here.
Isaac,
Would you mind to explain a little bit more how would one do that, step by step :-) please ?
What exactly would not work when run as a user with no privileges ?
Is it really better to leave broken functionality there and let things fail (e.g. get an error on createServer()) than to make things unavailable (e.g., a node that did not require any of its core modules, and does not provide require() nor a way to require them) ?
Thanks in advance,
--
Jorge.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
This is not a use case node.js was made for. The opposite is true. Node.js creates a powerful environment where everything is accessible and controllable via JS. Several posts here referred to Rhino and I agree that this is the way to go. Rhino runs isolated on the JVM. You can use class shutters to restrict access to every function you want to forbid. For instance without IO classes you can never reach the file system out of the VM. You have access to the byte code counter where you can abort execution after a specified number of VM cycles.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
var compartment1 = makeMembrane(cajaVM.eval);
var eval1 = compartment1.wrapper;
var gate1 = compartment1.gate;
var badCode = //... obtain potentially malicious code from somewhere ...
var result = eval1(badCode);
//... use result ...
gate1.revoke();
//... contents of compartment gone and collectible ...