Page MenuHomePhabricator

Add gerrit.wikimedia.org to the Phabricator CSP
Closed, DeclinedPublic

Description

As of Chrome 73, the Pherrit Chrome extension is broken 😭

In Phabricator, open up the developer console and run

fetch("https://gerrit.wikimedia.org/r/changes/?pp=0&o=TRACKING_IDS&o=DETAILED_LABELS&q=bug:T210653+OR+bug:T195482+OR+bug:T212465+OR+bug:T216495+OR+bug:T210658+OR+bug:T195478+OR+bug:T217102+OR+bug:T186737+OR+bug:T213847+OR+bug:T150377+OR+bug:T217298+OR+bug:T215477+OR+bug:T201339+OR+bug:T218173+OR+bug:T217296+OR+bug:T216198+OR+bug:T204627+OR+bug:T213352+OR+bug:T217820+OR+bug:T168861+OR+bug:T216264+OR+bug:T139317+OR+bug:T212961+OR+bug:T208605", {
			"headers":{"accept":"application/json",
				'Content-Type': 'application/json',
				'Access-Control-Allow-Origin': '*'},"method":"GET"}).then((e)=>e.text()).then((e)=>console.log(e));

Expected: Request goes through
Actual: VM581:1 Refused to connect to 'https://gerrit.wikimedia.org/r/changes/?pp=0&o=TRACKING_IDS&o=DETAILED_LABELS&q=bug:T210653+OR+bug:T195482+OR+bug:T212465+OR+bug:T216495+OR+bug:T210658+OR+bug:T195478+OR+bug:T217102+OR+bug:T186737+OR+bug:T213847+OR+bug:T150377+OR+bug:T217298+OR+bug:T215477+OR+bug:T201339+OR+bug:T218173+OR+bug:T217296+OR+bug:T216198+OR+bug:T204627+OR+bug:T213352+OR+bug:T217820+OR+bug:T168861+OR+bug:T216264+OR+bug:T139317+OR+bug:T212961+OR+bug:T208605' because it violates the document's Content Security Policy.

This used to work in Chrome 72, it no longer does.

Event Timeline

(and to be clear I'm only interested in read only requests here)

I don't see allowOriginRegex in our Gerrit config at all. That should mean "By default, unset, denying all cross-origin requests." applies. I could only see that if the default changed in the latest Gerrit upgrade.

It should be the CSP on the Phabricator side.

Jdrewniak renamed this task from No longer possible to make CORS requests from Phabricator to Gerrit to Add gerrit.wikimedia.org to the Phabricator CSP.Mar 15 2019, 7:51 AM
Jdrewniak updated the task description. (Show Details)
Jdrewniak added subscribers: mmodell, Jdrewniak.
jijiki triaged this task as Medium priority.Mar 19 2019, 6:10 PM

So.. the value for $csp is set to the $altdom / $alt_host setting which is in Hiera as hiera('phabricator_altdomain', 'phab.wmfusercontent.org'),. We can't simply set multiple altdoms. So this would indeed need a hack in AphrontResponse.php afaict.

Isn't this a problem with the extension? Content scripts are subject to the document's CSP but the main extension code isn't, so the fetch should be done by the extension and then postMessage'd to the content script.

hashar subscribed.

Closing this since it is an old task. Either Pherrit got fixed or nobody uses it at all. If there is a need for a specific CSP please mention it and it should be trivial to add. Gerrit and Phabricator each use Apache as a frontend so it is all about adding an apache conf (Header always set Content-Security-Policy "xxxx").

FWIW I stopped using Pherrit because I couldn't get it to work without this fix. I don't think that's a great reason to decline this task. There will be future attempts at browser extensions which hit exactly the same problem.

I don't know enough about the problem described in T218308#5758494 to know how to suggest fixing that.

Yeah, I would also use Pherrit if not for this issue. Nevertheless, I don't think a CSP exemption is the right way to fix it.