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

Unified Diff: media/blink/buffered_data_source.cc

Issue 1220963004: Check the response URL origin in BufferedDataSource to avoid mixing cross-origin responses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check Origin and canRequest Created 5 years, 5 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: media/blink/buffered_data_source.cc
diff --git a/media/blink/buffered_data_source.cc b/media/blink/buffered_data_source.cc
index d5f32b1ca298d4c787731c70eb26ead26632bea0..9d10a58e4a3a9910ccfa69554621f7d7dbc261e8 100644
--- a/media/blink/buffered_data_source.cc
+++ b/media/blink/buffered_data_source.cc
@@ -10,6 +10,8 @@
#include "base/single_thread_task_runner.h"
#include "media/base/media_log.h"
#include "net/base/net_errors.h"
+#include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
+#include "third_party/WebKit/public/web/WebFrame.h"
using blink::WebFrame;
@@ -356,6 +358,7 @@ void BufferedDataSource::StartCallback(
loader_->Stop();
return;
}
+ response_original_url_ = loader_->response_original_url();
// All responses must be successful. Resources that are assumed to be fully
// buffered must have a known content length.
@@ -403,8 +406,8 @@ void BufferedDataSource::PartialReadStartCallback(
BufferedResourceLoader::Status status) {
DCHECK(render_task_runner_->BelongsToCurrentThread());
DCHECK(loader_.get());
-
- if (status == BufferedResourceLoader::kOk) {
+ if (status == BufferedResourceLoader::kOk &&
+ CheckPartialResponseURL(loader_->response_original_url())) {
// Once the request has started successfully, we can proceed with
// reading from it.
ReadInternal();
@@ -422,6 +425,25 @@ void BufferedDataSource::PartialReadStartCallback(
ReadOperation::Run(read_op_.Pass(), kReadError);
}
+bool BufferedDataSource::CheckPartialResponseURL(
+ const GURL& partial_response_original_url) const {
+ // If the SecurityOrigin of the frame can read content of the new response, we
hubbe 2015/07/06 17:22:47 Why? Why would we ever support redirects pointing
horo 2015/07/07 01:06:46 In current implementation, redirects pointing to a
falken 2015/07/07 02:32:49 To clarify: YouTube and Vimeo use redirects for th
hubbe 2015/07/08 18:13:23 That's what I thought too. Which I think means tha
horo 2015/07/09 00:14:27 I don't know the real world usage of the media ele
+ // accept.
+ if (frame_->securityOrigin().canRequest(partial_response_original_url))
+ return true;
+
+ // If the response is generated in a Service Worker we accept.
falken 2015/07/07 02:32:49 Please mention here something about why, i.e., the
horo 2015/07/07 03:48:36 yes. added comments.
+ if (!partial_response_original_url.is_valid())
falken 2015/07/07 02:32:49 is_empty() instead of is_valid Sidenote: It's a b
horo 2015/07/07 03:48:36 Done.
+ return true;
+
+ // Otherwise we don't support mixing different origin responses. If we support
+ // this, malicious attackers can scan the bytes of other origin resources by
+ // mixing their generated bytes and the target response. See
+ // http://crbug.com/489060#c32 for details.
+ return response_original_url_.GetOrigin() ==
+ partial_response_original_url.GetOrigin();
+}
+
void BufferedDataSource::ReadCallback(
BufferedResourceLoader::Status status,
int bytes_read) {

Powered by Google App Engine
This is Rietveld 408576698