Commit 99a348cf authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[PH][Desktop] Block unsecure pages.

Before this patch, a payment handler page could be unsecure.

This patch checks for the following conditions:
- Unsecure origin.
- Non-cryptographic scheme.
- Invalid certificate.
- Flagged in safe browsing database.
If any of these conditions are hit, Chrome aborts payment by closing the
payment handler page and showing an error message.

After this patch, if a payment handler page is detected to be unsecure,
Chrome closes the payment handler page and shows an error message.

Bug: 828431
Change-Id: Ifdc5a3e3ebf9c511f21aa03dee2d8d3230ac8b88
Reviewed-on: https://chromium-review.googlesource.com/1012451Reviewed-by: default avataranthonyvd <anthonyvd@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550987}
parent 8a54940f
...@@ -991,6 +991,7 @@ split_static_library("ui") { ...@@ -991,6 +991,7 @@ split_static_library("ui") {
"//components/password_manager/content/browser", "//components/password_manager/content/browser",
"//components/password_manager/core/browser", "//components/password_manager/core/browser",
"//components/password_manager/sync/browser", "//components/password_manager/sync/browser",
"//components/payments/content:utils",
"//components/pdf/browser", "//components/pdf/browser",
"//components/physical_web/data_source", "//components/physical_web/data_source",
"//components/physical_web/webui", "//components/physical_web/webui",
......
...@@ -8,11 +8,13 @@ ...@@ -8,11 +8,13 @@
#include "base/base64.h" #include "base/base64.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/payments/ssl_validity_checker.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
#include "chrome/browser/ui/views/payments/payment_request_views_util.h" #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/payments/content/origin_security_checker.h"
#include "components/vector_icons/vector_icons.h" #include "components/vector_icons/vector_icons.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
...@@ -200,12 +202,22 @@ void PaymentHandlerWebFlowViewController::ButtonPressed( ...@@ -200,12 +202,22 @@ void PaymentHandlerWebFlowViewController::ButtonPressed(
void PaymentHandlerWebFlowViewController::DidFinishNavigation( void PaymentHandlerWebFlowViewController::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { content::NavigationHandle* navigation_handle) {
if (!OriginSecurityChecker::IsOriginSecure(navigation_handle->GetURL()) ||
!OriginSecurityChecker::IsSchemeCryptographic(
navigation_handle->GetURL()) ||
!SslValidityChecker::IsSslCertificateValid(
navigation_handle->GetWebContents())) {
AbortPayment();
return;
}
if (first_navigation_complete_callback_) { if (first_navigation_complete_callback_) {
std::move(first_navigation_complete_callback_) std::move(first_navigation_complete_callback_)
.Run(true, web_contents()->GetMainFrame()->GetProcess()->GetID(), .Run(true, web_contents()->GetMainFrame()->GetProcess()->GetID(),
web_contents()->GetMainFrame()->GetRoutingID()); web_contents()->GetMainFrame()->GetRoutingID());
first_navigation_complete_callback_ = PaymentHandlerOpenWindowCallback(); first_navigation_complete_callback_ = PaymentHandlerOpenWindowCallback();
} }
UpdateHeaderView(); UpdateHeaderView();
} }
...@@ -215,11 +227,14 @@ void PaymentHandlerWebFlowViewController::TitleWasSet( ...@@ -215,11 +227,14 @@ void PaymentHandlerWebFlowViewController::TitleWasSet(
} }
void PaymentHandlerWebFlowViewController::DidAttachInterstitialPage() { void PaymentHandlerWebFlowViewController::DidAttachInterstitialPage() {
UpdateHeaderView(); AbortPayment();
} }
void PaymentHandlerWebFlowViewController::DidDetachInterstitialPage() { void PaymentHandlerWebFlowViewController::AbortPayment() {
UpdateHeaderView(); if (web_contents())
web_contents()->Close();
dialog()->ShowErrorMessage();
} }
} // namespace payments } // namespace payments
...@@ -52,7 +52,8 @@ class PaymentHandlerWebFlowViewController ...@@ -52,7 +52,8 @@ class PaymentHandlerWebFlowViewController
content::NavigationHandle* navigation_handle) override; content::NavigationHandle* navigation_handle) override;
void TitleWasSet(content::NavigationEntry* entry) override; void TitleWasSet(content::NavigationEntry* entry) override;
void DidAttachInterstitialPage() override; void DidAttachInterstitialPage() override;
void DidDetachInterstitialPage() override;
void AbortPayment();
Profile* profile_; Profile* profile_;
GURL target_; GURL target_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment