Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Unified Diff: Source/core/frame/csp/ContentSecurityPolicy.cpp

Issue 822483002: CSP 'self' is not interpreted correctly for iframes, Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/csp/ContentSecurityPolicy.cpp
diff --git a/Source/core/frame/csp/ContentSecurityPolicy.cpp b/Source/core/frame/csp/ContentSecurityPolicy.cpp
index ba5235d9515eaadf96442b21c6efc137753c865a..74ae698abfccc7a1de0bd3d555e82aa0ec4c2872 100644
--- a/Source/core/frame/csp/ContentSecurityPolicy.cpp
+++ b/Source/core/frame/csp/ContentSecurityPolicy.cpp
@@ -155,9 +155,18 @@ void ContentSecurityPolicy::bindToExecutionContext(ExecutionContext* executionCo
void ContentSecurityPolicy::applyPolicySideEffectsToExecutionContext()
{
ASSERT(m_executionContext);
- // Ensure that 'self' processes correctly.
- m_selfProtocol = securityOrigin()->protocol();
- m_selfSource = adoptPtr(new CSPSource(this, m_selfProtocol, securityOrigin()->host(), securityOrigin()->port(), String(), CSPSource::NoWildcard, CSPSource::NoWildcard));
+ // Ensure that 'self' processes correctly. Note that this uses the URL of
+ // the context, not the security origin. That's because in the sandbox
+ // case, the origin is 'unique' (which, in practice, gives an empty scheme,
+ // host, and port). However, regarding matching the 'self' source, the CSP
+ // spec
+ // (https://w3c.github.io/webappsec/specs/content-security-policy/#match-source-expression)
+ // reads: "Return does match if the URL has the same scheme, host, and port
+ // as the protected resource’s URL". Thus, if Chrome were to store the
+ // 'unqiue' origin in m_selfSource, it would match nothing, even though it
+ // should match resources that are loaded at the same URL it loaded from.
+ m_selfProtocol = m_executionContext->url().protocol();
+ m_selfSource = adoptPtr(new CSPSource(this, m_selfProtocol, m_executionContext->url().host(), m_executionContext->url().port(), String(), CSPSource::NoWildcard, CSPSource::NoWildcard));
// If we're in a Document, set the referrer policy, mixed content checking, and sandbox
// flags, then dump all the parsing error messages, then poke at histograms.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698