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

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

Closed
pitsi opened this issue Jun 5, 2021 · 18 comments · Fixed by brave/brave-core#9053

Comments

@pitsi
Copy link

pitsi commented Jun 5, 2021

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.

@ryanbr
Copy link

ryanbr commented Jun 5, 2021

I think this is related too #16156

@pitsi
Copy link
Author

pitsi commented Jun 5, 2021

Maybe. If the devs judge that the issues are the same, feel free to close this one.
I forgot to mention that it started happening after the upgrade to 1.25.x, so it must have appeared at the same time as yours. However, I noticed the problem on cockpit yesterday, so I decided to investigate it more and then I opened this issue report here.

@ryanbr
Copy link

ryanbr commented Jun 5, 2021

Can you check if Chrome is affected? we've had reports Chrome had similar issues. @pitsi

@pitsi
Copy link
Author

pitsi commented Jun 5, 2021

I have chromium and chrome, both on v91.0.4472.77, but on my windows partition. I will later transfer my page there and check.
On linux, as I have mentioned above, chrome unstable (v93.0.4530.5) is not affected.

@pitsi
Copy link
Author

pitsi commented Jun 5, 2021

And no, chromium and chrome from windows are not affected. Both pages load with no issues and no errors in the console.

@ask1234560
Copy link

ask1234560 commented Jun 5, 2021

Can confirm. Quora is breaking, if the site is opened in the same tab. But it works when the site is opened in new tab.
Version 1.25.70 Chromium: 91.0.4472.77 (Official Build) (64-bit)

@pitsi
Copy link
Author

pitsi commented Jun 5, 2021

I do not have a quora account, thus I am not logged in to the site. I added it to my simple page, and it opens up as usual, asking for credentials. If you do have an account in quora, can you please check the console for similar errors?

The forementioned sites (facebok and cockpit) cause the issue whether they are lauched on the same tab or in a new one.

---edit
I retried quora just now and indeed it does fail to open, even without credentials. There is just a red Q in the middle of the page and nothing happens. The error in the console is identical to the one mentioned at the top of the issue report.

@pitsi
Copy link
Author

pitsi commented Jun 7, 2021

One very minor discovery I just made. Pressing f5 to refresh that broken page (= any of the pages mentioned above) does not resolve the issue. The same errors appear on the console too.
One has to click in the address bar and press enter, as if he typed the full url in the first place, as a workaround.

@ryanbr
Copy link

ryanbr commented Jun 8, 2021

Okay looked into this. Bisected to a

  • Create a basic .html file
  • <html><body><a href="https://duckduckgo.com/">Link</a></body></html>
  • Open html, and click on href link in Brave
  • Fails from Nightly v1.25.17 onwards.
Nightly v1.25.46   Bad
Nightly v1.25.34   Bad
Nightly v1.25.17   Bad
Nightly v1.25.16   Good
Nightly v1.25.15   Good

v1.25.16...v1.25.17

error-links

@antonok-edm
Copy link
Collaborator

@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

@pitsi
Copy link
Author

pitsi commented Jun 8, 2021

It worked for me!

@ask1234560
Copy link

Thanks @antonok-edm it works for me too.

@antonok-edm
Copy link
Collaborator

@kjozwiak I added QA/No here since there's already a QA/Yes label on #16283, which is tied to the same PR - feel free to update that if necessary

@pitsi
Copy link
Author

pitsi commented Jun 11, 2021

When 1.27.x reaches stable and this thing is resolved, can someone please post here and let us know to change the flag back?

@antonok-edm
Copy link
Collaborator

@pitsi This change has been uplifted to the next 1.25.x hotfix release, which is actually scheduled for later today as far as I'm aware.

@pitsi
Copy link
Author

pitsi commented 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.

@pitsi
Copy link
Author

pitsi commented Sep 16, 2021

Sorry for bringing up a 3 month old issue, but I have to ask before opening a new one. A page I visit shows up blank since the 2 weeks ago and this is what the console says

Access to internal resource at 'https://www.e-shop.gr/site.webmanifest' from origin 'https://e-shop.gr' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Is it the same as above? I do not mean the error, because it obviously isn't, I mean the reason. If it is not the same, I will open a new issue.

@ask1234560
Copy link

@pitsi the CORS error is not related to brave. CORS or cross origin request sharing error happens when CORS header is not present usually this is done in the backend.

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

Successfully merging a pull request may close this issue.

5 participants