forked from brave/brave-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent extensions from tampering with Uphold linking flow (brave/bra…
- Loading branch information
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
source_set("common") { | ||
sources = [ | ||
"brave_extension_urls.cc", | ||
"brave_extension_urls.h", | ||
] | ||
|
||
deps = [ | ||
"//base", | ||
"//extensions/common", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* Copyright (c) 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/extensions/common/brave_extension_urls.h" | ||
|
||
#include "base/strings/string_util.h" | ||
#include "url/origin.h" | ||
|
||
namespace extension_urls { | ||
|
||
bool IsBraveProtectedUrl(const url::Origin& origin, base::StringPiece path) { | ||
return (origin.DomainIs("sandbox.uphold.com") && | ||
base::StartsWith(path, "/authorize/", | ||
base::CompareCase::SENSITIVE)) || | ||
(origin.DomainIs("api.uphold.com") && | ||
base::StartsWith(path, "/oauth2/token", | ||
base::CompareCase::SENSITIVE)); | ||
} | ||
|
||
} // namespace extension_urls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* Copyright (c) 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_EXTENSIONS_COMMON_EXTENSION_URLS_H_ | ||
#define BRAVE_EXTENSIONS_COMMON_EXTENSION_URLS_H_ | ||
|
||
#include "extensions/common/extension_urls.h" | ||
|
||
namespace extension_urls { | ||
|
||
// Returns true if the URL points to a security-critical service. | ||
bool IsBraveProtectedUrl(const url::Origin& origin, base::StringPiece path); | ||
|
||
} // namespace extension_urls | ||
|
||
#endif // BRAVE_EXTENSIONS_COMMON_EXTENSION_URLS_H_ |
21 changes: 21 additions & 0 deletions
21
patches/extensions-browser-api-web_request-web_request_permissions.cc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
diff --git a/extensions/browser/api/web_request/web_request_permissions.cc b/extensions/browser/api/web_request/web_request_permissions.cc | ||
index bf321bd13711feaf4f7889f71d876ed6d71ebd7c..d6d66bd52170db2e7d4f11c8f8e59af40abe1936 100644 | ||
--- a/extensions/browser/api/web_request/web_request_permissions.cc | ||
+++ b/extensions/browser/api/web_request/web_request_permissions.cc | ||
@@ -9,6 +9,7 @@ | ||
#include "base/strings/string_piece.h" | ||
#include "base/strings/string_util.h" | ||
#include "base/strings/stringprintf.h" | ||
+#include "brave/extensions/common/brave_extension_urls.h" | ||
#include "content/public/browser/child_process_security_policy.h" | ||
#include "content/public/browser/resource_request_info.h" | ||
#include "extensions/browser/api/extensions_api_client.h" | ||
@@ -320,6 +321,8 @@ bool WebRequestPermissions::HideRequest( | ||
// for requests from common renderers. | ||
if (extension_urls::IsWebstoreUpdateUrl(url) || | ||
extension_urls::IsBlacklistUpdateUrl(url) || | ||
+ extension_urls::IsBraveProtectedUrl(url::Origin::Create(url), | ||
+ url.path_piece()) || | ||
extension_urls::IsSafeBrowsingUrl(url::Origin::Create(url), | ||
url.path_piece()) || | ||
(url.DomainIs("chrome.google.com") && |