Skip to content

Commit 42e5b8a

Browse files
author
epriestley
committedMar 2, 2018
Include the primary domain in the Content-Security-Policy explicitly if there's no CDN
Summary: Ref T4340. If you don't configure a CDN and visit a custom site (like a Phame blog site, or a CORGI sandbox internally) we serve resources from the main site. This violates the Content-Security-Policy. When there's no CDN, include the primary domain in the CSP explicitly. Test Plan: Loaded `local.www.phacility.com`, got resources. Maniphest Tasks: T4340 Differential Revision: https://secure.phabricator.com/D19170
1 parent 2121f2d commit 42e5b8a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎src/aphront/response/AphrontResponse.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,14 @@ private function newContentSecurityPolicyHeader() {
109109
if ($cdn) {
110110
$default = $this->newContentSecurityPolicySource($cdn);
111111
} else {
112-
$default = "'self'";
112+
// If an alternate file domain is not configured and the user is viewing
113+
// a Phame blog on a custom domain or some other custom site, we'll still
114+
// serve resources from the main site. Include the main site explicitly.
115+
116+
$base_uri = PhabricatorEnv::getURI('/');
117+
$base_uri = $this->newContentSecurityPolicySource($base_uri);
118+
119+
$default = "'self' {$base_uri}";
113120
}
114121

115122
$csp[] = "default-src {$default}";

0 commit comments

Comments
 (0)
Failed to load comments.