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

Unified Diff: pdf/out_of_process_instance.cc

Issue 1316803003: Prevent leaking PDF data cross-origin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2454
Patch Set: Created 5 years, 4 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
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/out_of_process_instance.cc
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc
index df881c5fada58a70748004cb95090572e325aea9..808606be7dece140fd6fad6bcaa5ba48d028a5d2 100644
--- a/pdf/out_of_process_instance.cc
+++ b/pdf/out_of_process_instance.cc
@@ -303,23 +303,24 @@ bool OutOfProcessInstance::Init(uint32_t argc,
const char* argn[],
const char* argv[]) {
// Check if the PDF is being loaded in the PDF chrome extension. We only allow
- // the plugin to be put into "full frame" mode when it is being loaded in the
- // extension because this enables some features that we don't want pages
- // abusing outside of the extension.
+ // the plugin to be loaded in the extension and print preview to avoid
+ // exposing sensitive APIs directly to external websites.
pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this);
- std::string document_url = document_url_var.is_string() ?
- document_url_var.AsString() : std::string();
+ if (!document_url_var.is_string())
+ return false;
+ std::string document_url = document_url_var.AsString();
std::string extension_url = std::string(kChromeExtension);
- bool in_extension =
- !document_url.compare(0, extension_url.size(), extension_url);
-
- if (in_extension) {
- // Check if the plugin is full frame. This is passed in from JS.
- for (uint32_t i = 0; i < argc; ++i) {
- if (strcmp(argn[i], "full-frame") == 0) {
- full_ = true;
- break;
- }
+ std::string print_preview_url = std::string(kChromePrint);
+ if (!base::StringPiece(document_url).starts_with(kChromeExtension) &&
+ !base::StringPiece(document_url).starts_with(kChromePrint)) {
+ return false;
+ }
+
+ // Check if the plugin is full frame. This is passed in from JS.
+ for (uint32_t i = 0; i < argc; ++i) {
+ if (strcmp(argn[i], "full-frame") == 0) {
+ full_ = true;
+ break;
}
}
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698