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.

CSP (content security policy) breaks some sites when they are launched from an existing web page

See original GitHub issue

Description

As mentioned in the title, csp (content security policy) breaks some sites when they are launched from an existing page. I use a simple page as my new tab and launch the 20+ sites I mostly visit from there. Right now, facebook and cockpit (local page, web console for linux servers) are affected. The error output in brave’s console (f12 > console) always looks similar to this

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src *". Either the 'unsafe-inline' keyword, a hash ('sha256-random numbers and letters'), or a nonce ('nonce-...') is required to enable inline execution.

This can also be considered a followup of #13929

Steps to Reproduce

  1. Create a simple web page locally, e.g.
<html>
<head>
<title>a simple page</title>
</head>
<body>
<a href="https://www.facebook.com/">Facebook</a>
<a href="https://192.168.1.5:9090">Cockpit</a>
</body>
</html>
  1. Open it in brave.
  2. Click on any of the 2 links mentioned.
  3. Notice that the pages appear broken.
  4. The errors appear in the console (f12 > console)

Actual result:

Facebook’s page appears completely blank. Cockpit’s appears like so

2021-06-05-135106_1278x720_scrot

Expected result:

I assume everyone knows how facebook’s main page looks. Cockpit’s should appear like so, prompting the user for credentials.

2021-06-05-135112_1278x720_scrot

Reproduces how often:

Easily.

Brave version (brave://version info)

Brave 1.25.68 Chromium: 91.0.4472.77 (Official Build) (64-bit) Revision 1cecd5c8a856bc2a5adda436e7b84d8d21b339b6-refs/branch-heads/4472@{# 1246} OS Linux

Version/Channel Information:

  • Can you reproduce this issue with the current release? Yes
  • Can you reproduce this issue with the beta channel? Probably
  • Can you reproduce this issue with the nightly channel? Probably

Other Additional Information:

  • Does the issue resolve itself when disabling Brave Shields? No
  • Does the issue resolve itself when disabling Brave Rewards? No
  • Is the issue reproducible on the latest version of Chrome? No. Tested on chrome unstable, v93.0.4530.5 as of today.

Miscellaneous Information:

In order for facebook to appear blank, the user must be already logged in in facebook. If not, it shows the usual facebook login page but the same errors on the console.

Moreover, if the forementioned link leads to any of facebook’s subpages, e.g.

facebook.com/messages
facebook.com/bravesoftware

the page appears blank as well and the same errors appear on the console.

Last but not least, if instead of pressing the link, the user types the url in the address bar, each page opens with no issues and no errors in the console.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18

github_iconTop GitHub Comments

3reactions
pitsicommented, Jun 12, 2021

Thanks! I got the upgrade a few minutes ago, switched #brave-adblock-csp-rules back to default and now works as it should.

2reactions
antonok-edmcommented, Jun 8, 2021

@pitsi @ask1234560 I’m investigating a fix for this; in the meantime you should be able to work around it by disabling #brave-adblock-csp-rules under brave://flags

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to break your site with a content security policy - Troy Hunt
My CSP aligned fully with the spec but because Safari doesn't recognise the agreed standard, it broke. Usually I tell people not to...
Read more >
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 fix 'because it violates the following content security ...
Content Security Policy blocks all resources that don't match it's policy. To view the policy for a specific website use the CSP Evaluator....
Read more >
Recording and spy problems caused by Content Security ...
The basic symptom is that Squish for Web will not function correctly, recording will not record anything, picking will not work and replaying ......
Read more >
Content Security Policy Level 3 - W3C
This document defines Content Security Policy (CSP), a tool which ... as cross-site scripting, and reducing the privilege with which their ...
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 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