Skip to content

turing completeness leak #4

@dominictarr

Description

@dominictarr

hey I found a gap where you can get at Function and then create code full non static code.

var evaluate = require('./');
var parse = require('esprima').parse;

var src = '(function () {}).constructor("var l = 3; while(l--) console.log(l); console.log(Date.now()); arguments.callee()")()';
var ast = parse(src).body[0].expression;
var res = evaluate(ast); //RangeError from stack overflow

console.log(res)

here is the output:

2
1
0
1426154732632
2
1
0
1426154732632
2
1
...
RangeError: Maximum call stack size exceeded

as you would expect.

It's somewhat harder to prevent turing completeness than it is to create it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions