Skip to content

turing completeness leak #4

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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