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

Javascript security #962

Closed
conceivable opened this issue Jun 1, 2017 · 10 comments
Closed

Javascript security #962

conceivable opened this issue Jun 1, 2017 · 10 comments
Assignees

Comments

@conceivable
Copy link

Browsers are known to have a big attack surface around JavaScript, often leading to user tracking (loss of anonymity), cookie hijacking and even remote code execution. Projects like the Tor Browser disable js by default for this reason.
Executing js from anonymous websites presents much higher risk than traditional well known sites.

Can you please clarify how ZeroNet handle the security of js? Thanks

@HelloZeroNet
Copy link
Owner

HelloZeroNet commented Jun 1, 2017

The problem is if you want dynamic sites, then have to deploy and run the site logic in some way.
It could be possible to write a non-javascript cilent in python/java/php/etc, but javascript offers the best and most battle tested sandboxing enviroment.

@MuxZeroNet
Copy link
Contributor

MuxZeroNet commented Jun 1, 2017

Static websites

It is perfectly fine to create static ZeroNet sites that work without JavaScript. Static site generators work very well in this case.

Dynamic websites

There is no backend. Computation, if necessary, must be done on the client side. We use JavaScript (browser side) and ZeroFrame APIs (restricted Python side computation) to make dynamic sites. It is impossible to display dynamic content while keeping things decentralized without running some algorithms on the client side to handle dynamic data.

Attack vector

Yes, JavaScript is a major attack vector. There is no extra protection except a sandbox iframe. Seriously, you should run ZeroNet in a virtual machine or in Whonix.

There are a few people asking us to implement PHP support. Keep in mind that "backend" code written by someone else will be executed on your computer. ZeroNet does not and will not support Flask, PHP, Node.js etc. that allows one to run totally unsandboxed code on your computer.

@anoadragon453
Copy link
Contributor

Perhaps there could be an 'Execute Javascript on this site' toggle in the slide-over menu, and the user can choose whether this setting is on or off by default for all sites.

Of course Javascript will by default be globally on for the best user experience.

@conceivable
Copy link
Author

"you should run ZeroNet in a virtual machine or in Whonix" - perhaps this should be written on the homepage or in the install instructions.

How does the Same-origin policy ties into serving content-addressed sites from localhost? Is it being circumvented?

@HelloZeroNet
Copy link
Owner

ZeroNet running content in sandboxed iframe that allows the content to be treated as being from the same origin.
https://www.w3schools.com/tags/att_iframe_sandbox.asp

@MuxZeroNet
Copy link
Contributor

MuxZeroNet commented Jul 6, 2017 via email

@HelloZeroNet
Copy link
Owner

Is there a particular reason why the src attribute of the inner iframe is assigned by Javascript code?

Without it the back button does not works, because the browser restores the old iframe url (at least in chrome) with expired nonce even if the wrapper html reloaded due no-cache header.

My ideas on JS-less mode:
Add support for /raw/siteaddress/any.html where the files are served without wrapper, but disabled js using Content Security Policy

Adding SSH tunnel to documentation would be a good idea and we could also enable the UiPassword plugin by default if someone start it with --ui_ip "*"

@MuxZeroNet
Copy link
Contributor

disabled js using Content Security Policy

Using the HTML/iframe sandbox to disable JS is a good idea.

@HelloZeroNet
Copy link
Owner

  • Should we use keep the wrapper and use iframe sandbox argument to disallow JS or use Content Security Policy headers and render it without wrapper?
  • Should we check and care about browsers that does not support Content Security Policy? (IE9)

@HelloZeroNet
Copy link
Owner

HelloZeroNet commented Jul 11, 2017

It's landed in Rev2137 (with some fixes in 2141 & 2144) using the /raw/ prefix. Eg.: http://127.0.0.1:43110/raw/1AsRLpuRxr3pb9p3TKoMXPSWHzh6i7fMGi/en.tar.gz/index.html

It will serve the files without any wrapper, but adding Content-Security-Policy: default-src 'none'; sandbox allow-top-navigation; img-src 'self'; font-src 'self'; media-src 'self'; style-src 'self' 'unsafe-inline'; header.

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

5 participants