Skip to content

Content Security Policy (CSP) #1672

Description

@tanx

Chrome Packaged Apps have CSP enabled by default to protects users against code injection attacks. In runtimes such as PhoneGap this isn't enabled by default, but developers can set the meta tag in the html document head. Like so:

<meta http-equiv="Content-Security-Policy" content="script-src 'self';">

This blocks inline scripts and other sources and only allows locally loaded scripts. E.g. the following code should not allowed to be executed:

<script type="text/javascript">
  alert('xss');
</script>

Chrome blocks this code while node-webkit doesn't. Is there a reason for this?

The reason I'm asking is that we are porting our PGP mail client (https://whiteout.io) from chrome packaged apps to node-webkit. But this issue is basically a showstopper for us, as it could allow an attacker to get a hold of the user's private key should he be able to inject code somehow.

Thanks

Activity

  1. jamesmortensen commented on Mar 8, 2014

    @jamesmortensen

    I was under the impression that Chrome blocks it because Google was trying to assert its will on other developers to make them code their way. I'm a big fan of good coding practices, but I'm not a fan of having them be forced.

    One thing I really like about node-webkit is the flexibility and control it gives me as a developer. If I need to do something a certain way, I can.

    In short, I don't have a problem with CSP being enabled by default. I generally don't do things that avoid it being turned off. But the difference between Google Chrome and node-webkit is that in Chrome you as a developer have no power to turn it off.

    image

  2. tanx commented on Mar 8, 2014

    @tanx
    Author

    I'm not suggesting that CSP be enforced, just that it is supported at all. Default or not.

    As for Google. There are legitimate reasons to enforce CSP when privileged Apis are exposed as most developers understandably choose the path with the least friction, even if they sacrifice security along the way. It is the platform maker's responsibility to protect its users and good design often requires making the hard choice for others. Firefox Packaged Apps do this as well by the way: https://developer.mozilla.org/en-US/Marketplace/Publishing/Packaged_apps#Types_of_packaged_apps

  3. xekoukou commented on Jun 14, 2014

    @xekoukou

    I concur with @tanx that this issue is a showstopper for application that require maximum security, for example financial services. Is this going to be resolved soon or is there a reason not to?

  4. tanx commented on Aug 5, 2014

    @tanx
    Author

    Any progress on this? I've tested the recent v0.10.1 of node-webkit but CSP is still not possible. Do you guys explicitly deactivate it to get the node apis working or what is the logic behind this?

  5. rdsubhas commented on Sep 10, 2014

    @rdsubhas

    +1 definitely helps when building node-webkit based apps, and being sure that no XSS will happen when dealing with untrusted content

  6. tanx commented on Sep 10, 2014

    @tanx
    Author

    Joe Marini from the Chrome team confirmed in the JavaScript Jabber Podcast, that Chrome Packaged Apps will soon be deployable without users having Chrome installed, basically packaging the chrome runtime with your app. We will be using this solution instead of node-webkit due to the missing CSP support

  7. xekoukou commented on Sep 10, 2014

    @xekoukou

    Nice.

    2014-09-10 23:50 GMT+03:00 Tankred Hase notifications@github.com:

    Joe Marini from the Chrome team confirmed in the JavaScript Jabber
    Podcast, that Chrome Packaged Apps will soon be deployable without users
    having Chrome installed, basically packaging the chrome runtime with your
    app. We will be using this solution instead of node-webkit due to the
    missing CSP support

    —
    Reply to this email directly or view it on GitHub
    #1672 (comment)
    .

    ,

     Apostolis Xekoukoulotakis
    
  8. self-assigned this
    on Sep 11, 2014
  9. rogerwang commented on Sep 11, 2014

    @rogerwang
    Member

    @tanx overlooked this; will fix it soon in the next version.

  10. rdsubhas commented on Sep 11, 2014

    @rdsubhas

    @rogerwang Thanks! So does this mean all normal frames now automatically have CSP enabled?

  11. added a commit that references this issue on Sep 25, 2014
    74a1343
  12. rogerwang commented on Jan 18, 2015

    @rogerwang
    Member

    @rdsubhas yes. Normal frames should work in the same way as in browser.

  13. added a commit that references this issue on Jan 28, 2015
    0e671b4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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