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

Unified Diff: third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp

Issue 1923273002: CSP: Allow hashed inline event handlers only with 'unsafe-hashed-attributes' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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
Index: third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp
diff --git a/third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp b/third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp
index 8f74b664be50e5de9490b4f64b5248047c306639..fe575896efffb5469457394e81b7d2f1ac394a47 100644
--- a/third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp
@@ -130,6 +130,11 @@ bool CSPDirectiveList::checkHash(SourceListDirective* directive, const CSPHashVa
return !directive || directive->allowHash(hashValue);
}
+bool CSPDirectiveList::checkHashedAttributes(SourceListDirective* directive) const
+{
+ return !directive || directive->allowHashedAttributes();
+}
+
bool CSPDirectiveList::checkDynamic(SourceListDirective* directive) const
{
return !directive || directive->allowDynamic();
@@ -423,13 +428,21 @@ bool CSPDirectiveList::allowStyleNonce(const String& nonce) const
return checkNonce(operativeDirective(m_styleSrc.get()), nonce);
}
-bool CSPDirectiveList::allowScriptHash(const CSPHashValue& hashValue) const
+bool CSPDirectiveList::allowScriptHash(const CSPHashValue& hashValue, ContentSecurityPolicy::InlineType type) const
{
+ if (type == ContentSecurityPolicy::InlineType::Attribute) {
+ if (!m_policy->experimentalFeaturesEnabled())
+ return false;
+ if (!checkHashedAttributes(operativeDirective(m_scriptSrc.get())))
+ return false;
+ }
return checkHash(operativeDirective(m_scriptSrc.get()), hashValue);
}
-bool CSPDirectiveList::allowStyleHash(const CSPHashValue& hashValue) const
+bool CSPDirectiveList::allowStyleHash(const CSPHashValue& hashValue, ContentSecurityPolicy::InlineType type) const
{
+ if (type != ContentSecurityPolicy::InlineType::Block)
+ return false;
return checkHash(operativeDirective(m_styleSrc.get()), hashValue);
}
« no previous file with comments | « third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.h ('k') | third_party/WebKit/Source/core/frame/csp/CSPSourceList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698