logo

etc_portage

Unnamed repository; edit this file 'description' to name the repository. git clone https://hacktivis.me/git/etc_portage.git

0002-Remove-support-for-PING-in-HTML-anchors-privacy.patch (18443B)


  1. From baf0c7c97905fe9226ea097535a07c9a15d8fb18 Mon Sep 17 00:00:00 2001
  2. Message-Id: <baf0c7c97905fe9226ea097535a07c9a15d8fb18.1550728895.git.contact@hacktivis.me>
  3. In-Reply-To: <9c4baaec2f310d43011ec3835e0fbaf585ed583c.1550728895.git.contact@hacktivis.me>
  4. References: <9c4baaec2f310d43011ec3835e0fbaf585ed583c.1550728895.git.contact@hacktivis.me>
  5. From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
  6. Date: Fri, 2 Nov 2018 18:14:21 +0100
  7. Subject: [PATCH 2/6] Remove support for PING in HTML anchors [privacy]
  8. ---
  9. Source/WebCore/Sources.txt | 1 -
  10. Source/WebCore/html/HTMLAnchorElement.cpp | 16 --
  11. .../html/parser/XSSAuditorDelegate.cpp | 4 -
  12. Source/WebCore/loader/DocumentLoader.cpp | 6 -
  13. Source/WebCore/loader/PingLoader.cpp | 218 ------------------
  14. .../loader/cache/CachedResourceLoader.cpp | 3 -
  15. .../page/csp/ContentSecurityPolicy.cpp | 5 -
  16. Source/WebKit/WebProcess/WebPage/WebPage.cpp | 3 -
  17. 8 files changed, 256 deletions(-)
  18. delete mode 100644 Source/WebCore/loader/PingLoader.cpp
  19. diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt
  20. index 704e50c773..bbee4a0695 100644
  21. --- a/Source/WebCore/Sources.txt
  22. +++ b/Source/WebCore/Sources.txt
  23. @@ -1276,7 +1276,6 @@ loader/NavigationAction.cpp
  24. loader/NavigationScheduler.cpp
  25. loader/NetscapePlugInStreamLoader.cpp
  26. loader/ServerTimingParser.cpp
  27. -loader/PingLoader.cpp
  28. loader/PolicyChecker.cpp
  29. loader/ProgressTracker.cpp
  30. loader/ResourceCryptographicDigest.cpp
  31. diff --git a/Source/WebCore/html/HTMLAnchorElement.cpp b/Source/WebCore/html/HTMLAnchorElement.cpp
  32. index 0155fc70a1..e53302748d 100644
  33. --- a/Source/WebCore/html/HTMLAnchorElement.cpp
  34. +++ b/Source/WebCore/html/HTMLAnchorElement.cpp
  35. @@ -39,7 +39,6 @@
  36. #include "HTMLPictureElement.h"
  37. #include "KeyboardEvent.h"
  38. #include "MouseEvent.h"
  39. -#include "PingLoader.h"
  40. #include "PlatformMouseEvent.h"
  41. #include "RenderImage.h"
  42. #include "ResourceRequest.h"
  43. @@ -364,19 +363,6 @@ bool HTMLAnchorElement::isLiveLink() const
  44. return isLink() && treatLinkAsLiveForEventType(m_wasShiftKeyDownOnMouseDown ? MouseEventWithShiftKey : MouseEventWithoutShiftKey);
  45. }
  46. -void HTMLAnchorElement::sendPings(const URL& destinationURL)
  47. -{
  48. - if (!document().frame())
  49. - return;
  50. -
  51. - if (!hasAttributeWithoutSynchronization(pingAttr) || !document().settings().hyperlinkAuditingEnabled())
  52. - return;
  53. -
  54. - SpaceSplitString pingURLs(attributeWithoutSynchronization(pingAttr), false);
  55. - for (unsigned i = 0; i < pingURLs.size(); i++)
  56. - PingLoader::sendPing(*document().frame(), document().completeURL(pingURLs[i]), destinationURL);
  57. -}
  58. -
  59. #if USE(SYSTEM_PREVIEW)
  60. bool HTMLAnchorElement::isSystemPreviewLink() const
  61. {
  62. @@ -442,8 +428,6 @@ void HTMLAnchorElement::handleClick(Event& event)
  63. ShouldSendReferrer shouldSendReferrer = hasRel(Relation::NoReferrer) ? NeverSendReferrer : MaybeSendReferrer;
  64. auto newFrameOpenerPolicy = hasRel(Relation::NoOpener) ? std::make_optional(NewFrameOpenerPolicy::Suppress) : std::nullopt;
  65. frame->loader().urlSelected(completedURL, target(), &event, LockHistory::No, LockBackForwardList::No, shouldSendReferrer, document().shouldOpenExternalURLsPolicyToPropagate(), newFrameOpenerPolicy, downloadAttribute, systemPreviewInfo);
  66. -
  67. - sendPings(completedURL);
  68. }
  69. HTMLAnchorElement::EventType HTMLAnchorElement::eventType(Event& event)
  70. diff --git a/Source/WebCore/html/parser/XSSAuditorDelegate.cpp b/Source/WebCore/html/parser/XSSAuditorDelegate.cpp
  71. index 80b4213669..e8c69162aa 100644
  72. --- a/Source/WebCore/html/parser/XSSAuditorDelegate.cpp
  73. +++ b/Source/WebCore/html/parser/XSSAuditorDelegate.cpp
  74. @@ -35,7 +35,6 @@
  75. #include "FrameLoaderClient.h"
  76. #include "HTMLParserIdioms.h"
  77. #include "NavigationScheduler.h"
  78. -#include "PingLoader.h"
  79. #include <wtf/JSONValues.h>
  80. #include <wtf/text/StringBuilder.h>
  81. #include <wtf/text/CString.h>
  82. @@ -104,9 +103,6 @@ void XSSAuditorDelegate::didBlockScript(const XSSInfo& xssInfo)
  83. m_didSendNotifications = true;
  84. frameLoader.client().didDetectXSS(m_document.url(), xssInfo.m_didBlockEntirePage);
  85. -
  86. - if (!m_reportURL.isEmpty())
  87. - PingLoader::sendViolationReport(*m_document.frame(), m_reportURL, generateViolationReport(xssInfo), ViolationReportType::XSSAuditor);
  88. }
  89. if (xssInfo.m_didBlockEntirePage)
  90. diff --git a/Source/WebCore/loader/DocumentLoader.cpp b/Source/WebCore/loader/DocumentLoader.cpp
  91. index 9b5aecc05f..ee80d8c118 100644
  92. --- a/Source/WebCore/loader/DocumentLoader.cpp
  93. +++ b/Source/WebCore/loader/DocumentLoader.cpp
  94. @@ -65,7 +65,6 @@
  95. #include "MemoryCache.h"
  96. #include "NetworkLoadMetrics.h"
  97. #include "Page.h"
  98. -#include "PingLoader.h"
  99. #include "PlatformStrategies.h"
  100. #include "PolicyChecker.h"
  101. #include "ProgressTracker.h"
  102. @@ -2055,11 +2054,6 @@ void DocumentLoader::addConsoleMessage(MessageSource messageSource, MessageLevel
  103. static_cast<ScriptExecutionContext*>(m_frame->document())->addConsoleMessage(messageSource, messageLevel, message, requestIdentifier);
  104. }
  105. -void DocumentLoader::sendCSPViolationReport(URL&& reportURL, Ref<FormData>&& report)
  106. -{
  107. - PingLoader::sendViolationReport(*m_frame, WTFMove(reportURL), WTFMove(report), ViolationReportType::ContentSecurityPolicy);
  108. -}
  109. -
  110. void DocumentLoader::enqueueSecurityPolicyViolationEvent(SecurityPolicyViolationEvent::Init&& eventInit)
  111. {
  112. m_frame->document()->enqueueSecurityPolicyViolationEvent(WTFMove(eventInit));
  113. diff --git a/Source/WebCore/loader/PingLoader.cpp b/Source/WebCore/loader/PingLoader.cpp
  114. deleted file mode 100644
  115. index 134e5560e6..0000000000
  116. --- a/Source/WebCore/loader/PingLoader.cpp
  117. +++ /dev/null
  118. @@ -1,218 +0,0 @@
  119. -/*
  120. - * Copyright (C) 2010 Google Inc. All rights reserved.
  121. - * Copyright (C) 2015 Roopesh Chander (roop@roopc.net)
  122. - * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
  123. - *
  124. - * Redistribution and use in source and binary forms, with or without
  125. - * modification, are permitted provided that the following conditions are
  126. - * met:
  127. - *
  128. - * * Redistributions of source code must retain the above copyright
  129. - * notice, this list of conditions and the following disclaimer.
  130. - * * Redistributions in binary form must reproduce the above
  131. - * copyright notice, this list of conditions and the following disclaimer
  132. - * in the documentation and/or other materials provided with the
  133. - * distribution.
  134. - * * Neither the name of Google Inc. nor the names of its
  135. - * contributors may be used to endorse or promote products derived from
  136. - * this software without specific prior written permission.
  137. - *
  138. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  139. - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  140. - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  141. - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  142. - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  143. - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  144. - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  145. - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  146. - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  147. - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  148. - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  149. - *
  150. - */
  151. -
  152. -#include "config.h"
  153. -#include "PingLoader.h"
  154. -
  155. -#include "ContentSecurityPolicy.h"
  156. -#include "Document.h"
  157. -#include "Frame.h"
  158. -#include "FrameLoader.h"
  159. -#include "FrameLoaderClient.h"
  160. -#include "InspectorInstrumentation.h"
  161. -#include "LoaderStrategy.h"
  162. -#include "NetworkLoadMetrics.h"
  163. -#include "Page.h"
  164. -#include "PlatformStrategies.h"
  165. -#include "ProgressTracker.h"
  166. -#include "ResourceHandle.h"
  167. -#include "ResourceLoadInfo.h"
  168. -#include "ResourceRequest.h"
  169. -#include "ResourceResponse.h"
  170. -#include "SecurityOrigin.h"
  171. -#include "SecurityPolicy.h"
  172. -#include "UserContentController.h"
  173. -#include <wtf/text/CString.h>
  174. -
  175. -namespace WebCore {
  176. -
  177. -#if !ENABLE(CONTENT_EXTENSIONS)
  178. -
  179. -// Returns true if we should block the load.
  180. -static inline bool processContentExtensionRulesForLoad(const Frame&, ResourceRequest&, ResourceType)
  181. -{
  182. - return false;
  183. -}
  184. -
  185. -#else
  186. -
  187. -// Returns true if we should block the load.
  188. -static bool processContentExtensionRulesForLoad(const Frame& frame, ResourceRequest& request, ResourceType resourceType)
  189. -{
  190. - auto* documentLoader = frame.loader().documentLoader();
  191. - if (!documentLoader)
  192. - return false;
  193. - auto* page = frame.page();
  194. - if (!page)
  195. - return false;
  196. - auto status = page->userContentProvider().processContentExtensionRulesForLoad(request.url(), resourceType, *documentLoader);
  197. - applyBlockedStatusToRequest(status, page, request);
  198. - return status.blockedLoad;
  199. -}
  200. -
  201. -#endif
  202. -
  203. -void PingLoader::loadImage(Frame& frame, const URL& url)
  204. -{
  205. - ASSERT(frame.document());
  206. - auto& document = *frame.document();
  207. -
  208. - if (!document.securityOrigin().canDisplay(url)) {
  209. - FrameLoader::reportLocalLoadFailed(&frame, url);
  210. - return;
  211. - }
  212. -
  213. - ResourceRequest request(url);
  214. - if (processContentExtensionRulesForLoad(frame, request, ResourceType::Image))
  215. - return;
  216. -
  217. - document.contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(request, ContentSecurityPolicy::InsecureRequestType::Load);
  218. -
  219. - request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0");
  220. -
  221. - HTTPHeaderMap originalRequestHeader = request.httpHeaderFields();
  222. -
  223. - String referrer = SecurityPolicy::generateReferrerHeader(document.referrerPolicy(), request.url(), frame.loader().outgoingReferrer());
  224. - if (!referrer.isEmpty())
  225. - request.setHTTPReferrer(referrer);
  226. - frame.loader().addExtraFieldsToSubresourceRequest(request);
  227. -
  228. - startPingLoad(frame, request, WTFMove(originalRequestHeader), ShouldFollowRedirects::Yes);
  229. -}
  230. -
  231. -// http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing
  232. -void PingLoader::sendPing(Frame& frame, const URL& pingURL, const URL& destinationURL)
  233. -{
  234. - ASSERT(frame.document());
  235. -
  236. - if (!pingURL.protocolIsInHTTPFamily())
  237. - return;
  238. -
  239. - ResourceRequest request(pingURL);
  240. - if (processContentExtensionRulesForLoad(frame, request, ResourceType::Raw))
  241. - return;
  242. -
  243. - auto& document = *frame.document();
  244. - document.contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(request, ContentSecurityPolicy::InsecureRequestType::Load);
  245. -
  246. - request.setHTTPMethod("POST");
  247. - request.setHTTPContentType("text/ping");
  248. - request.setHTTPBody(FormData::create("PING"));
  249. - request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0");
  250. -
  251. - HTTPHeaderMap originalRequestHeader = request.httpHeaderFields();
  252. -
  253. - frame.loader().addExtraFieldsToSubresourceRequest(request);
  254. -
  255. - auto& sourceOrigin = document.securityOrigin();
  256. - FrameLoader::addHTTPOriginIfNeeded(request, sourceOrigin.toString());
  257. - request.setHTTPHeaderField(HTTPHeaderName::PingTo, destinationURL);
  258. - if (!SecurityPolicy::shouldHideReferrer(pingURL, frame.loader().outgoingReferrer())) {
  259. - request.setHTTPHeaderField(HTTPHeaderName::PingFrom, document.url());
  260. - if (!sourceOrigin.isSameSchemeHostPort(SecurityOrigin::create(pingURL).get())) {
  261. - String referrer = SecurityPolicy::generateReferrerHeader(document.referrerPolicy(), pingURL, frame.loader().outgoingReferrer());
  262. - if (!referrer.isEmpty())
  263. - request.setHTTPReferrer(referrer);
  264. - }
  265. - }
  266. -
  267. - startPingLoad(frame, request, WTFMove(originalRequestHeader), ShouldFollowRedirects::Yes);
  268. -}
  269. -
  270. -void PingLoader::sendViolationReport(Frame& frame, const URL& reportURL, Ref<FormData>&& report, ViolationReportType reportType)
  271. -{
  272. - ASSERT(frame.document());
  273. -
  274. - ResourceRequest request(reportURL);
  275. - if (processContentExtensionRulesForLoad(frame, request, ResourceType::Raw))
  276. - return;
  277. -
  278. - auto& document = *frame.document();
  279. - document.contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(request, ContentSecurityPolicy::InsecureRequestType::Load);
  280. -
  281. - request.setHTTPMethod("POST"_s);
  282. - request.setHTTPBody(WTFMove(report));
  283. - switch (reportType) {
  284. - case ViolationReportType::ContentSecurityPolicy:
  285. - request.setHTTPContentType("application/csp-report"_s);
  286. - break;
  287. - case ViolationReportType::XSSAuditor:
  288. - request.setHTTPContentType("application/json"_s);
  289. - break;
  290. - }
  291. -
  292. - bool removeCookies = true;
  293. - if (document.securityOrigin().isSameSchemeHostPort(SecurityOrigin::create(reportURL).get()))
  294. - removeCookies = false;
  295. - if (removeCookies)
  296. - request.setAllowCookies(false);
  297. -
  298. - HTTPHeaderMap originalRequestHeader = request.httpHeaderFields();
  299. -
  300. - frame.loader().addExtraFieldsToSubresourceRequest(request);
  301. -
  302. - String referrer = SecurityPolicy::generateReferrerHeader(document.referrerPolicy(), reportURL, frame.loader().outgoingReferrer());
  303. - if (!referrer.isEmpty())
  304. - request.setHTTPReferrer(referrer);
  305. -
  306. - startPingLoad(frame, request, WTFMove(originalRequestHeader), ShouldFollowRedirects::No);
  307. -}
  308. -
  309. -void PingLoader::startPingLoad(Frame& frame, ResourceRequest& request, HTTPHeaderMap&& originalRequestHeaders, ShouldFollowRedirects shouldFollowRedirects)
  310. -{
  311. - unsigned long identifier = frame.page()->progress().createUniqueIdentifier();
  312. - // FIXME: Why activeDocumentLoader? I would have expected documentLoader().
  313. - // It seems like the PingLoader should be associated with the current
  314. - // Document in the Frame, but the activeDocumentLoader will be associated
  315. - // with the provisional DocumentLoader if there is a provisional
  316. - // DocumentLoader.
  317. - bool shouldUseCredentialStorage = frame.loader().client().shouldUseCredentialStorage(frame.loader().activeDocumentLoader(), identifier);
  318. - FetchOptions options;
  319. - options.credentials = shouldUseCredentialStorage ? FetchOptions::Credentials::Include : FetchOptions::Credentials::Omit;
  320. - options.redirect = shouldFollowRedirects == ShouldFollowRedirects::Yes ? FetchOptions::Redirect::Follow : FetchOptions::Redirect::Error;
  321. -
  322. - // FIXME: Move ping loads to normal subresource loading to get normal inspector request instrumentation hooks.
  323. - InspectorInstrumentation::willSendRequestOfType(&frame, identifier, frame.loader().activeDocumentLoader(), request, InspectorInstrumentation::LoadType::Ping);
  324. -
  325. - platformStrategies()->loaderStrategy()->startPingLoad(frame, request, WTFMove(originalRequestHeaders), options, [protectedFrame = makeRef(frame), identifier] (const ResourceError& error, const ResourceResponse& response) {
  326. - if (!response.isNull())
  327. - InspectorInstrumentation::didReceiveResourceResponse(protectedFrame, identifier, protectedFrame->loader().activeDocumentLoader(), response, nullptr);
  328. - if (error.isNull()) {
  329. - NetworkLoadMetrics emptyMetrics;
  330. - InspectorInstrumentation::didFinishLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, emptyMetrics, nullptr);
  331. - } else
  332. - InspectorInstrumentation::didFailLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, error);
  333. - });
  334. -}
  335. -
  336. -}
  337. diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.cpp b/Source/WebCore/loader/cache/CachedResourceLoader.cpp
  338. index 9d3d108113..614cfee9b5 100644
  339. --- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp
  340. +++ b/Source/WebCore/loader/cache/CachedResourceLoader.cpp
  341. @@ -57,7 +57,6 @@
  342. #include "Logging.h"
  343. #include "MemoryCache.h"
  344. #include "Page.h"
  345. -#include "PingLoader.h"
  346. #include "PlatformStrategies.h"
  347. #include "RenderElement.h"
  348. #include "ResourceLoadInfo.h"
  349. @@ -202,8 +201,6 @@ ResourceErrorOr<CachedResourceHandle<CachedImage>> CachedResourceLoader::request
  350. if (Document* document = frame->document())
  351. request.upgradeInsecureRequestIfNeeded(*document);
  352. URL requestURL = request.resourceRequest().url();
  353. - if (requestURL.isValid() && canRequest(CachedResource::Type::ImageResource, requestURL, request, ForPreload::No))
  354. - PingLoader::loadImage(*frame, requestURL);
  355. return CachedResourceHandle<CachedImage> { };
  356. }
  357. }
  358. diff --git a/Source/WebCore/page/csp/ContentSecurityPolicy.cpp b/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
  359. index 9b966fa02b..f1b1b51da1 100644
  360. --- a/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
  361. +++ b/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
  362. @@ -45,7 +45,6 @@
  363. #include "JSExecState.h"
  364. #include "JSWindowProxy.h"
  365. #include "ParsingUtilities.h"
  366. -#include "PingLoader.h"
  367. #include "ResourceRequest.h"
  368. #include "RuntimeEnabledFeatures.h"
  369. #include "SchemeRegistry.h"
  370. @@ -759,10 +758,6 @@ void ContentSecurityPolicy::reportViolation(const String& effectiveViolatedDirec
  371. if (m_client) {
  372. for (const auto& url : reportURIs)
  373. m_client->sendCSPViolationReport(URL { m_protectedURL, url }, report.copyRef());
  374. - } else {
  375. - auto& document = downcast<Document>(*m_scriptExecutionContext);
  376. - for (const auto& url : reportURIs)
  377. - PingLoader::sendViolationReport(*document.frame(), URL { m_protectedURL, url }, report.copyRef(), ViolationReportType::ContentSecurityPolicy);
  378. }
  379. }
  380. diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp
  381. index 5aa26e75b2..bae31537b3 100644
  382. --- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp
  383. +++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp
  384. @@ -181,7 +181,6 @@
  385. #include <WebCore/NotImplemented.h>
  386. #include <WebCore/Page.h>
  387. #include <WebCore/PageConfiguration.h>
  388. -#include <WebCore/PingLoader.h>
  389. #include <WebCore/PlatformKeyboardEvent.h>
  390. #include <WebCore/PluginDocument.h>
  391. #include <WebCore/PrintContext.h>
  392. @@ -3358,8 +3357,6 @@ void WebPage::sendCSPViolationReport(uint64_t frameID, const WebCore::URL& repor
  393. auto report = reportData.takeData();
  394. if (!report)
  395. return;
  396. - if (auto* frame = WebProcess::singleton().webFrame(frameID))
  397. - PingLoader::sendViolationReport(*frame->coreFrame(), reportURL, report.releaseNonNull(), ViolationReportType::ContentSecurityPolicy);
  398. }
  399. void WebPage::enqueueSecurityPolicyViolationEvent(uint64_t frameID, SecurityPolicyViolationEvent::Init&& eventInit)
  400. --
  401. 2.20.1