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

Unified Diff: third_party/WebKit/Source/core/dom/PendingScript.cpp

Issue 1675183003: Fix SRI bypass by loading same resource twice in same origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Rebase on ToT Created 4 years, 10 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/dom/PendingScript.cpp
diff --git a/third_party/WebKit/Source/core/dom/PendingScript.cpp b/third_party/WebKit/Source/core/dom/PendingScript.cpp
index 0c0fdc93b80588359404a5fc22d03f79ac5a1217..5058b054842ef0a0a1e7a2dec040952ddb10d19b 100644
--- a/third_party/WebKit/Source/core/dom/PendingScript.cpp
+++ b/third_party/WebKit/Source/core/dom/PendingScript.cpp
@@ -165,9 +165,15 @@ void PendingScript::notifyFinished(Resource* resource)
// integrity attribute isn't empty in addition to checking if the
// resource has empty integrity metadata.
if (!integrityAttr.isEmpty() && !scriptResource->integrityMetadata().isEmpty()) {
- if (!scriptResource->integrityAlreadyChecked() && resource->resourceBuffer()) {
- scriptResource->setIntegrityAlreadyChecked(true);
+ ScriptIntegrityDisposition disposition = scriptResource->integrityDisposition();
+ if (disposition == ScriptIntegrityDisposition::Failed) {
+ // TODO(jww): This should probably also generate a console
+ // message identical to the one produced by
+ // CheckSubresourceIntegrity below. See https://crbug.com/585267.
+ m_integrityFailure = true;
+ } else if (disposition == ScriptIntegrityDisposition::NotChecked && resource->resourceBuffer()) {
m_integrityFailure = !SubresourceIntegrity::CheckSubresourceIntegrity(scriptResource->integrityMetadata(), *m_element, resource->resourceBuffer()->data(), resource->resourceBuffer()->size(), resource->url(), *resource);
+ scriptResource->setIntegrityDisposition(m_integrityFailure ? ScriptIntegrityDisposition::Failed : ScriptIntegrityDisposition::Passed);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698