Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dealing with infinite loop, blocking errors, alert(""), XSS and other JavaScript annoyances #18

Open
juliendorra opened this issue Oct 28, 2015 · 2 comments

Comments

@juliendorra
Copy link
Collaborator

XSS is probably not of concern for Paysage, as we have no sessions or user information,

But I tested with alert() and it's hugely annoying, especially as it goes off 60 times per second (in the draw loop) on the Playground.

Infinite loop and other errors that block the tab/browser are also an issue.

Very interesting podcast by CodePen on executing arbitrary javascript :
http://blog.codepen.io/2015/07/07/045-javascript-security/

Some practical implementation tips here:
https://github.com/jsbin/jsbin/wiki/Best-practices-for-building-your-own-live-paste-bin
For alert (and prompt confirm print open) the fix is to redefine windows.alert = function () {} so the function is empty. But there's other sort of popups and modals possible :-( like camera access, geoloc, etc. that we can't access and we would need to clean the code itself…

Content Security Policy would allow us to be sure that (modern) browsers only load codes from trusted servers, while still allowing images to be loaded from anywhere on the web, for example.
http://www.html5rocks.com/en/tutorials/security/content-security-policy/

@juliendorra
Copy link
Collaborator Author

Interesting talk from Pamela Fox of Khan Academy on how they manage ProcessingJS code on their live code editor:
https://www.youtube.com/watch?v=EzHsLt9vLbk&feature=youtu.be&t=26m49s

(infinite loop, slow programs, hints, content origin policy, etc.)

@juliendorra juliendorra changed the title Do we need to sandbox more to deal with alert(""), XSS and other JavaScript annoyances? Sandboxing to deal with inifinite loop, blocking errors, alert(""), XSS and other JavaScript annoyances Dec 24, 2015
@juliendorra juliendorra changed the title Sandboxing to deal with inifinite loop, blocking errors, alert(""), XSS and other JavaScript annoyances Dealing with infinite loop, blocking errors, alert(""), XSS and other JavaScript annoyances Oct 11, 2017
@juliendorra
Copy link
Collaborator Author

Both JS Bin and CodePen have an open source implementation of infinite loop management/stopping:

JS Bin's Loop Protect rewrite the JavaScript with timers and test without building an AST. There's an implementation example. It's extracted from the JS Bin code base, which is fully open source.
https://github.com/jsbin/loop-protect

CodePen's Infinite Loop Buster build an AST using Esprima, and then add the checks to the AST, which could be more robust and cover more cases. As Code Pen is not open source, we can only infer that it is the version used on their site.
https://github.com/CodePen/InfiniteLoopBuster

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

No branches or pull requests

1 participant