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

Side by Side Diff: third_party/WebKit/Source/core/dom/PendingScript.cpp

Issue 1713093002: Fix SRI bypass by loading same resource twice in same origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@2623
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 ASSERT(resource->type() == Resource::Script); 157 ASSERT(resource->type() == Resource::Script);
158 ScriptResource* scriptResource = toScriptResource(resource); 158 ScriptResource* scriptResource = toScriptResource(resource);
159 String integrityAttr = m_element->fastGetAttribute(HTMLNames::integrityA ttr); 159 String integrityAttr = m_element->fastGetAttribute(HTMLNames::integrityA ttr);
160 160
161 // It is possible to get back a script resource with integrity metadata 161 // It is possible to get back a script resource with integrity metadata
162 // for a request with an empty integrity attribute. In that case, the 162 // for a request with an empty integrity attribute. In that case, the
163 // integrity check should be skipped, so this check ensures that the 163 // integrity check should be skipped, so this check ensures that the
164 // integrity attribute isn't empty in addition to checking if the 164 // integrity attribute isn't empty in addition to checking if the
165 // resource has empty integrity metadata. 165 // resource has empty integrity metadata.
166 if (!integrityAttr.isEmpty() && !scriptResource->integrityMetadata().isE mpty()) { 166 if (!integrityAttr.isEmpty() && !scriptResource->integrityMetadata().isE mpty()) {
167 if (!scriptResource->integrityAlreadyChecked() && resource->resource Buffer()) { 167 ScriptIntegrityDisposition disposition = scriptResource->integrityDi sposition();
168 scriptResource->setIntegrityAlreadyChecked(true); 168 if (disposition == ScriptIntegrityDisposition::Failed) {
169 // TODO(jww): This should probably also generate a console
170 // message identical to the one produced by
171 // CheckSubresourceIntegrity below. See https://crbug.com/585267 .
172 m_integrityFailure = true;
173 } else if (disposition == ScriptIntegrityDisposition::NotChecked && resource->resourceBuffer()) {
169 m_integrityFailure = !SubresourceIntegrity::CheckSubresourceInte grity(scriptResource->integrityMetadata(), *m_element, resource->resourceBuffer( )->data(), resource->resourceBuffer()->size(), resource->url(), *resource); 174 m_integrityFailure = !SubresourceIntegrity::CheckSubresourceInte grity(scriptResource->integrityMetadata(), *m_element, resource->resourceBuffer( )->data(), resource->resourceBuffer()->size(), resource->url(), *resource);
175 scriptResource->setIntegrityDisposition(m_integrityFailure ? Scr iptIntegrityDisposition::Failed : ScriptIntegrityDisposition::Passed);
170 } 176 }
171 } 177 }
172 } 178 }
173 179
174 if (m_streamer) 180 if (m_streamer)
175 m_streamer->notifyFinished(resource); 181 m_streamer->notifyFinished(resource);
176 } 182 }
177 183
178 void PendingScript::notifyAppendData(ScriptResource* resource) 184 void PendingScript::notifyAppendData(ScriptResource* resource)
179 { 185 {
(...skipping 30 matching lines...) Expand all
210 bool PendingScript::isReady() const 216 bool PendingScript::isReady() const
211 { 217 {
212 if (resource() && !resource()->isLoaded()) 218 if (resource() && !resource()->isLoaded())
213 return false; 219 return false;
214 if (m_streamer && !m_streamer->isFinished()) 220 if (m_streamer && !m_streamer->isFinished())
215 return false; 221 return false;
216 return true; 222 return true;
217 } 223 }
218 224
219 } 225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698