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.

Include default content security policy or guidance?

See original GitHub issue

I have just gotten the boilerplate up and running. Not surprisingly, I ran into two security warnings:

image

Surprisingly, I haven’t bumped into any detailed articles (outside of the docs) that discuss best practices for dealing with these security issues.

I also find the electron doc’s recommendations to be a bit vague when it comes to understanding what should be placed where: Both the meta tag and the http header? Is 'default-src \'none\'' fine for apps that don’t need to access websites? (Perhaps that is an issue to take up there?)

Prerequisites

  • Using yarn
  • Using an up-to-date master branch
  • Using latest version of devtools. See wiki for howto update
  • Link to stacktrace in a Gist (for bugs)
  • For issue in production release, devtools output of DEBUG_PROD=true yarn build && yarn start
  • Tried solutions mentioned in #400

Expected Behavior

The app starts running in dev mode and you are off to the races with no warnings, etc.

Current Behavior

Two warnings flash up right away about security.

Possible Solution

  1. Add default behavior for dealing with the content security policy. For example, based on what comes up in the electron docs, it might be sufficient to add this snippet to main?
  2. Clarify whether the insecure resources warning is anything to be concerned about in the docs.

Steps to Reproduce (for bugs)

  1. Clone the repo.
  2. Run yarn run dev
  3. Open devtools to see the warnings.

Context

This just creates a little wormhole that I need to travel down every time I start a new electron app (using the boilerplate or otherwise).

The only change I made to the boilerplate was the addition of scss.

Your Environment

  • Node version : 10.13.0
  • Version or Branch used : Master (as of 10/19/18)
  • Operating System and version : Windows 10
  • Link to your project : NA

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
michaelwooleycommented, Dec 2, 2018

Well, I think that it is a feature, not a bug for general use of electron. They are real security issues that are especially relevant for electron due to its ability to access the user’s file systems.

I think it would be good to demonstrate how to do this in a boilerplate so that it isn’t just ignored, etc.

0reactions
michaelwooleycommented, Aug 7, 2020

@tsemerad sorry it has been so long that I don’t really recall what I ended up doing. Basically, these errors seem to be semi-electron specific warnings that should be considered with any client/server interaction. I see that there is an explicit http mention in app/app.html. But that’s your localhost so no worries.

Maybe look to see if there are any patterns in the showcase apps? Sorry couldn’t be more helpful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content Security Policy (CSP) - HTTP - MDN Web Docs
Chrome Edge Content‑Security‑Policy Full support. Chrome25. more. Toggle history Full sup... base‑uri Full support. Chrome40. Toggle history Full sup... block‑all‑mixed‑content. Deprecated Full support. ChromeYes. Toggle history...
Read more >
How to Set Up a Content Security Policy (CSP) in 3 Steps
Follow our guide on how to set up a Content Security Policy (CSP) for your website. We'll include common directives for you to...
Read more >
Content security policy - web.dev
Content Security Policy can significantly reduce the risk and impact of cross-site scripting attacks in modern browsers.
Read more >
Content Security Policy Level 3 - W3C
This document defines Content Security Policy (CSP), a tool which developers can use to lock down their applications in various ways, mitigating ...
Read more >
Content Security Policy - OWASP Cheat Sheet Series
By injecting the Content-Security-Policy (CSP) headers from the server, the browser is aware and capable of protecting the user from dynamic calls that...
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