question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bypass nx-compile 2.0 with hoisting

See original GitHub issue

In the proposal at: https://github.com/RisingStack/nx-compile/issues/2#issuecomment-241438171 and https://github.com/RisingStack/nx-compile/pull/3 you talk about “Early closing the with block with a single ‘}’ character is now not possible.”

It looks like the idea for the fix was based on the fact that even if you break out of the “with” statement you are after the return statement, and code after the return is assumed unreachable. However a functions declared after the return statements are hoisted into scope(above the with statement). If we name that function “sandbox” we replace the Proxy with our function bypassing the sandbox.

resulting in the following code in the new Function(

// this gets hoisted 
function sandbox(){}// }) }

with (sandbox) { 
    return (() => { 
        'use strict'; global.isSecure=false
    })
};

I created the following failing test as a POC:

it('should protect against "early mustache closing" string manipulation and hoisting', () => {
    const code = compiler.compileCode('global.isSecure=false})};function sandbox(){}//', {})
    code()
    expect(global.isSecure).to.be.true
})

Tested against https://github.com/RisingStack/nx-compile/pull/3

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
matt-commented, Sep 5, 2016

Don’t mind at all!

0reactions
solkimicrebcommented, Sep 5, 2016

Great (:

I think the issues are fixed with the pre-compiling function. I am going to close this now. (I opened a few fresh issues for v2.0.0)

Read more comments on GitHub >

github_iconTop Results From Across the Web

So called "secure" sandbox isn't secure at all · Issue #2 - GitHub
I don't use eval, I use new Function in both v1 and v2 and I 'use strict' in v2. ... Bypass nx-compile 2.0...
Read more >
使用Python的NLP模块来提取单词,从 - 编程入门自学教程
... a-b-chi-2.0.0 abcing abcing-0.0.3 abcjs-rails ABCLogger abcrunch ... byod by_params bypass bypass-0.0.7 bypassable bypassed byr byr-0.1 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found