safe_browsing-disable-reporting-of-safebrowsing-over.patch 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. From 8f348bf2c249701de2f6049ac57fe346bd6b665f Mon Sep 17 00:00:00 2001
  2. From: Joachim Bauch <jojo@struktur.de>
  3. Date: Tue, 7 Jul 2015 18:28:46 +0200
  4. Subject: [PATCH 48/66] safe_browsing: disable reporting of safebrowsing
  5. override
  6. Disables reporting of the safebrowsing override, i.e. the report sent
  7. if a user decides to visit a page that was flagged as "insecure".
  8. This prevents trk:148 (phishing) and trk:149 (malware).
  9. ---
  10. .../browser/safe_browsing/client_side_detection_service.cc | 12 ++++++++++++
  11. 1 file changed, 12 insertions(+)
  12. --- a/chrome/browser/safe_browsing/client_side_detection_service.cc
  13. +++ b/chrome/browser/safe_browsing/client_side_detection_service.cc
  14. @@ -63,12 +63,6 @@ enum MalwareReportTypes {
  15. REPORT_RESULT_MAX
  16. };
  17. -void UpdateEnumUMAHistogram(MalwareReportTypes report_type) {
  18. - DCHECK(report_type >= 0 && report_type < REPORT_RESULT_MAX);
  19. - UMA_HISTOGRAM_ENUMERATION("SBClientMalware.SentReports", report_type,
  20. - REPORT_RESULT_MAX);
  21. -}
  22. -
  23. } // namespace
  24. const int ClientSideDetectionService::kInitialClientModelFetchDelayMs = 10000;
  25. @@ -281,94 +275,8 @@ void ClientSideDetectionService::StartCl
  26. DCHECK_CURRENTLY_ON(BrowserThread::UI);
  27. std::unique_ptr<ClientPhishingRequest> request(verdict);
  28. - if (!enabled_) {
  29. - if (!callback.is_null())
  30. - callback.Run(GURL(request->url()), false);
  31. - return;
  32. - }
  33. -
  34. - // Fill in metadata about which model we used.
  35. - if (is_extended_reporting) {
  36. - request->set_model_filename(model_loader_extended_->name());
  37. - request->mutable_population()->set_user_population(
  38. - ChromeUserPopulation::EXTENDED_REPORTING);
  39. - } else {
  40. - request->set_model_filename(model_loader_standard_->name());
  41. - request->mutable_population()->set_user_population(
  42. - ChromeUserPopulation::SAFE_BROWSING);
  43. - }
  44. - DVLOG(2) << "Starting report for hit on model " << request->model_filename();
  45. -
  46. - request->mutable_population()->set_profile_management_status(
  47. - GetProfileManagementStatus(
  48. - g_browser_process->browser_policy_connector()));
  49. -
  50. - std::string request_data;
  51. - if (!request->SerializeToString(&request_data)) {
  52. - UMA_HISTOGRAM_COUNTS_1M("SBClientPhishing.RequestNotSerialized", 1);
  53. - DVLOG(1) << "Unable to serialize the CSD request. Proto file changed?";
  54. - if (!callback.is_null())
  55. - callback.Run(GURL(request->url()), false);
  56. - return;
  57. - }
  58. -
  59. - net::NetworkTrafficAnnotationTag traffic_annotation =
  60. - net::DefineNetworkTrafficAnnotation(
  61. - "safe_browsing_client_side_phishing_detector", R"(
  62. - semantics {
  63. - sender: "Safe Browsing Client-Side Phishing Detector"
  64. - description:
  65. - "If the client-side phishing detector determines that the "
  66. - "current page contents are similar to phishing pages, it will "
  67. - "send a request to Safe Browsing to ask for a final verdict. If "
  68. - "Safe Browsing agrees the page is dangerous, Chrome will show a "
  69. - "full-page interstitial warning."
  70. - trigger:
  71. - "Whenever the clinet-side detector machine learning model "
  72. - "computes a phishy-ness score above a threshold, after page-load."
  73. - data:
  74. - "Top-level page URL without CGI parameters, boolean and double "
  75. - "features extracted from DOM, such as the number of resources "
  76. - "loaded in the page, if certain likely phishing and social "
  77. - "engineering terms found on the page, etc."
  78. - destination: GOOGLE_OWNED_SERVICE
  79. - }
  80. - policy {
  81. - cookies_allowed: YES
  82. - cookies_store: "Safe browsing cookie store"
  83. - setting:
  84. - "Users can enable or disable this feature by toggling 'Protect "
  85. - "you and your device from dangerous sites' in Chrome settings "
  86. - "under Privacy. This feature is enabled by default."
  87. - chrome_policy {
  88. - SafeBrowsingEnabled {
  89. - policy_options {mode: MANDATORY}
  90. - SafeBrowsingEnabled: false
  91. - }
  92. - }
  93. - })");
  94. - auto resource_request = std::make_unique<network::ResourceRequest>();
  95. - resource_request->url = GetClientReportUrl(kClientReportPhishingUrl);
  96. - resource_request->method = "POST";
  97. - resource_request->load_flags = net::LOAD_DISABLE_CACHE;
  98. - auto loader = network::SimpleURLLoader::Create(std::move(resource_request),
  99. - traffic_annotation);
  100. - loader->AttachStringForUpload(request_data, "application/octet-stream");
  101. - loader->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
  102. - url_loader_factory_.get(),
  103. - base::BindOnce(&ClientSideDetectionService::OnURLLoaderComplete,
  104. - base::Unretained(this), loader.get()));
  105. -
  106. - // Remember which callback and URL correspond to the current fetcher object.
  107. - std::unique_ptr<ClientPhishingReportInfo> info(new ClientPhishingReportInfo);
  108. - auto* loader_ptr = loader.get();
  109. - info->loader = std::move(loader);
  110. - info->callback = callback;
  111. - info->phishing_url = GURL(request->url());
  112. - client_phishing_reports_[loader_ptr] = std::move(info);
  113. -
  114. - // Record that we made a request
  115. - phishing_report_times_.push(base::Time::Now());
  116. + if (!callback.is_null())
  117. + callback.Run(GURL(request->url()), false);
  118. }
  119. void ClientSideDetectionService::StartClientReportMalwareRequest(
  120. @@ -377,81 +285,8 @@ void ClientSideDetectionService::StartCl
  121. DCHECK_CURRENTLY_ON(BrowserThread::UI);
  122. std::unique_ptr<ClientMalwareRequest> request(verdict);
  123. - if (!enabled_) {
  124. - if (!callback.is_null())
  125. - callback.Run(GURL(request->url()), GURL(request->url()), false);
  126. - return;
  127. - }
  128. -
  129. - std::string request_data;
  130. - if (!request->SerializeToString(&request_data)) {
  131. - UpdateEnumUMAHistogram(REPORT_FAILED_SERIALIZATION);
  132. - DVLOG(1) << "Unable to serialize the CSD request. Proto file changed?";
  133. - if (!callback.is_null())
  134. - callback.Run(GURL(request->url()), GURL(request->url()), false);
  135. - return;
  136. - }
  137. -
  138. - net::NetworkTrafficAnnotationTag traffic_annotation =
  139. - net::DefineNetworkTrafficAnnotation(
  140. - "safe_browsing_client_side_malware_detector", R"(
  141. - semantics {
  142. - sender: "Safe Browsing Client-Side Malware Detector"
  143. - description:
  144. - "If the client-side malware detector determines that a requested "
  145. - "page's IP is in the blacklisted malware IPs, it will send a "
  146. - "request to Safe Browsing to ask for a final verdict. If Safe "
  147. - "Browsing agrees the page is dangerous, Chrome will show a "
  148. - "full-page interstitial warning."
  149. - trigger:
  150. - "Whenever the IP of the page is in malware blacklist."
  151. - data:
  152. - "Top-level page URL without CGI parameters, its non-https "
  153. - "referrer, URLs of resources that match IP blacklist."
  154. - destination: GOOGLE_OWNED_SERVICE
  155. - }
  156. - policy {
  157. - cookies_allowed: YES
  158. - cookies_store: "Safe browsing cookie store"
  159. - setting:
  160. - "Users can enable or disable this feature by toggling 'Protect "
  161. - "you and your device from dangerous sites' in Chrome settings "
  162. - "under Privacy. This feature is enabled by default."
  163. - chrome_policy {
  164. - SafeBrowsingEnabled {
  165. - policy_options {mode: MANDATORY}
  166. - SafeBrowsingEnabled: false
  167. - }
  168. - }
  169. - })");
  170. - auto resource_request = std::make_unique<network::ResourceRequest>();
  171. - resource_request->url = GetClientReportUrl(kClientReportMalwareUrl);
  172. - resource_request->method = "POST";
  173. - resource_request->load_flags = net::LOAD_DISABLE_CACHE;
  174. - auto loader = network::SimpleURLLoader::Create(std::move(resource_request),
  175. - traffic_annotation);
  176. - loader->AttachStringForUpload(request_data, "application/octet-stream");
  177. - loader->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
  178. - url_loader_factory_.get(),
  179. - base::BindOnce(&ClientSideDetectionService::OnURLLoaderComplete,
  180. - base::Unretained(this), loader.get()));
  181. -
  182. - // Remember which callback and URL correspond to the current fetcher object.
  183. - std::unique_ptr<ClientMalwareReportInfo> info(new ClientMalwareReportInfo);
  184. - auto* loader_ptr = loader.get();
  185. - info->loader = std::move(loader);
  186. - info->callback = callback;
  187. - info->original_url = GURL(request->url());
  188. - client_malware_reports_[loader_ptr] = std::move(info);
  189. -
  190. - UMA_HISTOGRAM_ENUMERATION("SBClientMalware.SentReports", REPORT_SENT,
  191. - REPORT_RESULT_MAX);
  192. -
  193. - UMA_HISTOGRAM_COUNTS_1M("SBClientMalware.IPBlacklistRequestPayloadSize",
  194. - request_data.size());
  195. -
  196. - // Record that we made a malware request
  197. - malware_report_times_.push(base::Time::Now());
  198. + if (!callback.is_null())
  199. + callback.Run(GURL(request->url()), GURL(request->url()), false);
  200. }
  201. void ClientSideDetectionService::HandlePhishingVerdict(