Diff
Modified: trunk/LayoutTests/ChangeLog (208548 => 208549)
--- trunk/LayoutTests/ChangeLog 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/LayoutTests/ChangeLog 2016-11-10 18:50:08 UTC (rev 208549)
@@ -1,3 +1,35 @@
+2016-11-10 Daniel Bates <[email protected]>
+
+ REGRESSION (r195004): Scripts and plugins blocked for subsequent loads in same WebContent
+ process after receiving HTTP 0.9 response
+ https://bugs.webkit.org/show_bug.cgi?id=164387
+ <rdar://problem/28987537>
+
+ Reviewed by Brent Fulgham.
+
+ Add a new test to ensure that the HTTP 0.9 sandbox policy does not persist across navigations.
+
+ Unskip HTTP 0.9 tests and update expected results for existing tests as needed.
+
+ * TestExpectations: Unskip the HTTP 0.9 tests.
+ * http/tests/security/http-0.9/default-port-plugin-blocked-expected.txt: Remove duplicate console
+ messages now that we emit the console message exactly once per document.
+ * http/tests/security/http-0.9/default-port-script-blocked-expected.txt: Ditto.
+ * http/tests/security/http-0.9/iframe-blocked-expected.txt: Update expected result now that we
+ no longer emit a console message for a blocked load.
+ * http/tests/security/http-0.9/image-blocked-expected.txt: Ditto.
+ * http/tests/security/http-0.9/image-on-HTTP-0.9-default-port-page-allowed-expected.txt: Remove
+ duplicate console messages now that we emit the console message exactly once per document.
+ * http/tests/security/http-0.9/image-on-HTTP-0.9-page-blocked-expected.txt: Ditto.
+ * http/tests/security/http-0.9/resources/sandbox-should-not-persist-on-navigation.html: Added.
+ * http/tests/security/http-0.9/sandbox-should-not-persist-on-navigation-expected.txt: Added.
+ * http/tests/security/http-0.9/sandbox-should-not-persist-on-navigation.html: Added.
+ * http/tests/security/http-0.9/worker-connect-src-blocked-expected.txt: Update expected result
+ now that we no longer apply a sandbox policy to the main resource if a subresource had an HTTP 0.9
+ response.
+ * http/tests/security/http-0.9/worker-importScripts-blocked-expected.txt: Ditto.
+ * http/tests/security/http-0.9/xhr-asynchronous-blocked-expected.txt: Ditto.
+
2016-11-04 Jiewen Tan <[email protected]>
Update SubtleCrypto::importKey to match the latest spec
Modified: trunk/LayoutTests/TestExpectations (208548 => 208549)
--- trunk/LayoutTests/TestExpectations 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/LayoutTests/TestExpectations 2016-11-10 18:50:08 UTC (rev 208549)
@@ -67,9 +67,6 @@
# Only iOS has selection UI drawn by UIKit
editing/selection/character-granularity-rect.html [ Skip ]
-# Until we fix webkit.org/b/164387 these tests will only pass when run singly (i.e. pass --run-singly to run-webkit-tests).
-webkit.org/b/164387 http/tests/security/http-0.9 [ Skip ]
-
#//////////////////////////////////////////////////////////////////////////////////////////
# End platform-specific tests.
#//////////////////////////////////////////////////////////////////////////////////////////
Modified: trunk/LayoutTests/http/tests/security/http-0.9/default-port-plugin-blocked-expected.txt (208548 => 208549)
--- trunk/LayoutTests/http/tests/security/http-0.9/default-port-plugin-blocked-expected.txt 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/LayoutTests/http/tests/security/http-0.9/default-port-plugin-blocked-expected.txt 2016-11-10 18:50:08 UTC (rev 208549)
@@ -1,6 +1,4 @@
CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-load-plugin-fail.pl' because it is using HTTP/0.9.
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-load-plugin-fail.pl' because it is using HTTP/0.9.
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-load-plugin-fail.pl' because it is using HTTP/0.9.
This tests that loading of a plugin is blocked in a HTTP 0.9 response served over port 80. This test PASSED if you see content in the iframe below. Otherwise, it FAILED.
Modified: trunk/LayoutTests/http/tests/security/http-0.9/default-port-script-blocked-expected.txt (208548 => 208549)
--- trunk/LayoutTests/http/tests/security/http-0.9/default-port-script-blocked-expected.txt 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/LayoutTests/http/tests/security/http-0.9/default-port-script-blocked-expected.txt 2016-11-10 18:50:08 UTC (rev 208549)
@@ -1,6 +1,4 @@
CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-alert-fail.pl' because it is using HTTP/0.9.
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-alert-fail.pl' because it is using HTTP/0.9.
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-alert-fail.pl' because it is using HTTP/0.9.
CONSOLE MESSAGE: Blocked script execution in 'http://127.0.0.1:8000/security/http-0.9/resources/nph-alert-fail.pl' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
This tests that _javascript_ is blocked in a HTTP 0.9 response served over port 80. This test PASSED if you see content in the iframe below and do not see a _javascript_ alert. Otherwise, it FAILED. This page and its subresources must be served over port 80 to run this test by hand.
Modified: trunk/LayoutTests/http/tests/security/http-0.9/iframe-blocked-expected.txt (208548 => 208549)
--- trunk/LayoutTests/http/tests/security/http-0.9/iframe-blocked-expected.txt 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/LayoutTests/http/tests/security/http-0.9/iframe-blocked-expected.txt 2016-11-10 18:50:08 UTC (rev 208549)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-fail.pl' because it is using HTTP/0.9.
CONSOLE MESSAGE: Stopped document load from 'http://127.0.0.1:8000/security/http-0.9/resources/nph-fail.pl' because it is using HTTP/0.9 on a non-default port.
Modified: trunk/LayoutTests/http/tests/security/http-0.9/image-blocked-expected.txt (208548 => 208549)
--- trunk/LayoutTests/http/tests/security/http-0.9/image-blocked-expected.txt 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/LayoutTests/http/tests/security/http-0.9/image-blocked-expected.txt 2016-11-10 18:50:08 UTC (rev 208549)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-image.pl' because it is using HTTP/0.9.
CONSOLE MESSAGE: Cancelled resource load from 'http://127.0.0.1:8000/security/http-0.9/resources/nph-image.pl' because it is using HTTP/0.9 and the document was loaded with a different HTTP version.
ALERT: PASS
Modified: trunk/LayoutTests/http/tests/security/http-0.9/image-on-HTTP-0.9-default-port-page-allowed-expected.txt (208548 => 208549)
--- trunk/LayoutTests/http/tests/security/http-0.9/image-on-HTTP-0.9-default-port-page-allowed-expected.txt 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/LayoutTests/http/tests/security/http-0.9/image-on-HTTP-0.9-default-port-page-allowed-expected.txt 2016-11-10 18:50:08 UTC (rev 208549)
@@ -1,8 +1,4 @@
CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-image-on-HTTP-0.9-default-port-page-allowed.pl' because it is using HTTP/0.9.
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-image-on-HTTP-0.9-default-port-page-allowed.pl' because it is using HTTP/0.9.
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-image-on-HTTP-0.9-default-port-page-allowed.pl' because it is using HTTP/0.9.
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-image.pl' because it is using HTTP/0.9.
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-image.pl' because it is using HTTP/0.9.
--------
Modified: trunk/LayoutTests/http/tests/security/http-0.9/image-on-HTTP-0.9-page-blocked-expected.txt (208548 => 208549)
--- trunk/LayoutTests/http/tests/security/http-0.9/image-on-HTTP-0.9-page-blocked-expected.txt 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/LayoutTests/http/tests/security/http-0.9/image-on-HTTP-0.9-page-blocked-expected.txt 2016-11-10 18:50:08 UTC (rev 208549)
@@ -1,7 +1,4 @@
CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-image-on-HTTP-0.9-page-blocked.pl' because it is using HTTP/0.9.
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-image-on-HTTP-0.9-page-blocked.pl' because it is using HTTP/0.9.
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-image-on-HTTP-0.9-page-blocked.pl' because it is using HTTP/0.9.
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8080/security/http-0.9/resources/nph-image.pl' because it is using HTTP/0.9.
CONSOLE MESSAGE: Cancelled resource load from 'http://127.0.0.1:8080/security/http-0.9/resources/nph-image.pl' because it is using HTTP/0.9 on a non-default port.
Added: trunk/LayoutTests/http/tests/security/http-0.9/resources/sandbox-should-not-persist-on-navigation.html (0 => 208549)
--- trunk/LayoutTests/http/tests/security/http-0.9/resources/sandbox-should-not-persist-on-navigation.html (rev 0)
+++ trunk/LayoutTests/http/tests/security/http-0.9/resources/sandbox-should-not-persist-on-navigation.html 2016-11-10 18:50:08 UTC (rev 208549)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="result">FAIL</p>
+<script>
+document.getElementById("result").textContent = "PASS";
+if (window.testRunner)
+ testRunner.notifyDone();
+</script>
+</body>
+</html>
Copied: trunk/LayoutTests/http/tests/security/http-0.9/sandbox-should-not-persist-on-navigation-expected.txt (from rev 208548, trunk/LayoutTests/http/tests/security/http-0.9/image-blocked-expected.txt) (0 => 208549)
--- trunk/LayoutTests/http/tests/security/http-0.9/sandbox-should-not-persist-on-navigation-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/security/http-0.9/sandbox-should-not-persist-on-navigation-expected.txt 2016-11-10 18:50:08 UTC (rev 208549)
@@ -0,0 +1,2 @@
+CONSOLE MESSAGE: Cancelled resource load from 'http://127.0.0.1:8000/security/http-0.9/resources/nph-image.pl' because it is using HTTP/0.9 and the document was loaded with a different HTTP version.
+PASS
Added: trunk/LayoutTests/http/tests/security/http-0.9/sandbox-should-not-persist-on-navigation.html (0 => 208549)
--- trunk/LayoutTests/http/tests/security/http-0.9/sandbox-should-not-persist-on-navigation.html (rev 0)
+++ trunk/LayoutTests/http/tests/security/http-0.9/sandbox-should-not-persist-on-navigation.html 2016-11-10 18:50:08 UTC (rev 208549)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.dumpChildFramesAsText();
+ testRunner.waitUntilDone();
+}
+
+function runTest()
+{
+ window.location.href = ""
+}
+</script>
+</head>
+<body>
+<img src="" _onload_="runTest()" _onerror_="runTest()"> <!-- Apply sandbox -->
+</body>
+</html>
Modified: trunk/LayoutTests/http/tests/security/http-0.9/worker-connect-src-blocked-expected.txt (208548 => 208549)
--- trunk/LayoutTests/http/tests/security/http-0.9/worker-connect-src-blocked-expected.txt 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/LayoutTests/http/tests/security/http-0.9/worker-connect-src-blocked-expected.txt 2016-11-10 18:50:08 UTC (rev 208549)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-worker-fail.pl' because it is using HTTP/0.9.
CONSOLE MESSAGE: Cancelled resource load from 'http://127.0.0.1:8000/security/http-0.9/resources/nph-worker-fail.pl' because it is using HTTP/0.9 and the document was loaded with a different HTTP version.
ALERT: PASS
Modified: trunk/LayoutTests/http/tests/security/http-0.9/worker-importScripts-blocked-expected.txt (208548 => 208549)
--- trunk/LayoutTests/http/tests/security/http-0.9/worker-importScripts-blocked-expected.txt 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/LayoutTests/http/tests/security/http-0.9/worker-importScripts-blocked-expected.txt 2016-11-10 18:50:08 UTC (rev 208549)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-worker-fail.pl' because it is using HTTP/0.9.
CONSOLE MESSAGE: Cancelled resource load from 'http://127.0.0.1:8000/security/http-0.9/resources/nph-worker-fail.pl' because it is using HTTP/0.9 and the document was loaded with a different HTTP version.
ALERT: PASS
Modified: trunk/LayoutTests/http/tests/security/http-0.9/xhr-asynchronous-blocked-expected.txt (208548 => 208549)
--- trunk/LayoutTests/http/tests/security/http-0.9/xhr-asynchronous-blocked-expected.txt 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/LayoutTests/http/tests/security/http-0.9/xhr-asynchronous-blocked-expected.txt 2016-11-10 18:50:08 UTC (rev 208549)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: Sandboxing 'http://127.0.0.1:8000/security/http-0.9/resources/nph-fail.pl' because it is using HTTP/0.9.
CONSOLE MESSAGE: Cancelled resource load from 'http://127.0.0.1:8000/security/http-0.9/resources/nph-fail.pl' because it is using HTTP/0.9 and the document was loaded with a different HTTP version.
ALERT: PASS
Modified: trunk/Source/WebCore/ChangeLog (208548 => 208549)
--- trunk/Source/WebCore/ChangeLog 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/Source/WebCore/ChangeLog 2016-11-10 18:50:08 UTC (rev 208549)
@@ -1,3 +1,49 @@
+2016-11-10 Daniel Bates <[email protected]>
+
+ REGRESSION (r195004): Scripts and plugins blocked for subsequent loads in same WebContent
+ process after receiving HTTP 0.9 response
+ https://bugs.webkit.org/show_bug.cgi?id=164387
+ <rdar://problem/28987537>
+
+ Reviewed by Brent Fulgham.
+
+ Fixes an issue where the HTTP 0.9 sandbox persisted across subsequent loads in the same
+ WebContent process.
+
+ Currently when an HTTP 0.9 response is received for a request made to a default port
+ (e.g. 80) we apply a sandbox policy on the FrameLoader for the main resource that
+ disallows scripts and plugins. A FrameLoader may be re-used for navigations. Therefore,
+ the sandbox policy applied to one site may be applied to another site. Moreover the
+ sandbox policy was applied to the FrameLoader of the main resource regardless of whether
+ the HTTP response was for a subresource. Instead we should apply the sandbox on a per-
+ Document basis and only if we receive an HTTP 0.9 response for the document when the
+ corresponding HTTP request was made to a default port.
+
+ As a side benefit of this change, we emit exactly one console message to Web Inspector
+ when the HTTP 0.9 sandbox is applied to a document as opposed to three console messages.
+ Moreover, we only emit this console message when the document load is not blocked.
+
+ Test: http/tests/security/http-0.9/sandbox-should-not-persist-on-navigation.html
+
+ * dom/Document.cpp:
+ (WebCore::Document::initSecurityContext): Disallow scripts and plugins if an HTTP 0.9
+ response was received for this document. Note that if this function is called for a
+ document associated with an HTTP 0.9 response then the corresponding HTTP request was
+ made to a default port. DocumentLoader::responseReceived() blocks the load for a document
+ with an HTTP 0.9 response corresponding to an HTTP request made to a non-default port.
+ This invariant is covered by the tests LayoutTests/http/tests/security/http-0.9/default-port-{plugin, script}-blocked.html.
+ (WebCore::Document::shouldEnforceHTTP0_9Sandbox): Added. Returns whether an HTTP 0.9 response
+ was received for this document.
+ * dom/Document.h:
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::responseReceived): Remove logic to apply sandbox policy to the
+ FrameLoader associated with the main resource. We will apply the sandbox during initialization
+ of the document.
+ * loader/ResourceLoader.cpp:
+ (WebCore::ResourceLoader::didReceiveResponse): Ditto.
+ * loader/SubresourceLoader.cpp:
+ (WebCore::SubresourceLoader::didReceiveResponse): Ditto.
+
2016-11-04 Jiewen Tan <[email protected]>
Update SubtleCrypto::importKey to match the latest spec
Modified: trunk/Source/WebCore/dom/Document.cpp (208548 => 208549)
--- trunk/Source/WebCore/dom/Document.cpp 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-11-10 18:50:08 UTC (rev 208549)
@@ -5122,6 +5122,12 @@
applyQuickLookSandbox();
#endif
+ if (shouldEnforceHTTP0_9Sandbox()) {
+ String message = makeString("Sandboxing '", m_url.stringCenterEllipsizedToLength(), "' because it is using HTTP/0.9.");
+ addConsoleMessage(MessageSource::Security, MessageLevel::Error, message);
+ enforceSandboxFlags(SandboxScripts | SandboxPlugins);
+ }
+
if (Settings* settings = this->settings()) {
if (settings->needsStorageAccessFromFileURLsQuirk())
securityOrigin()->grantStorageAccessFromFileURLsQuirk();
@@ -6906,6 +6912,14 @@
return ShouldOpenExternalURLsPolicy::ShouldNotAllow;
}
+bool Document::shouldEnforceHTTP0_9Sandbox() const
+{
+ if (m_isSynthesized || !m_frame)
+ return false;
+ DocumentLoader* documentLoader = m_frame->loader().activeDocumentLoader();
+ return documentLoader && documentLoader->response().isHttpVersion0_9();
+}
+
#if USE(QUICK_LOOK)
bool Document::shouldEnforceQuickLookSandbox() const
{
Modified: trunk/Source/WebCore/dom/Document.h (208548 => 208549)
--- trunk/Source/WebCore/dom/Document.h 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/Source/WebCore/dom/Document.h 2016-11-10 18:50:08 UTC (rev 208549)
@@ -1397,6 +1397,8 @@
void applyQuickLookSandbox();
#endif
+ bool shouldEnforceHTTP0_9Sandbox() const;
+
unsigned m_referencingNodeCount;
std::unique_ptr<StyleResolver> m_userAgentShadowTreeStyleResolver;
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (208548 => 208549)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2016-11-10 18:50:08 UTC (rev 208549)
@@ -740,12 +740,6 @@
stopLoading();
return;
}
-
- ASSERT(m_identifierForLoadWithoutResourceLoader || m_mainResource);
- unsigned long identifier = m_identifierForLoadWithoutResourceLoader ? m_identifierForLoadWithoutResourceLoader : m_mainResource->identifier();
- String message = "Sandboxing '" + url.string() + "' because it is using HTTP/0.9.";
- m_frame->document()->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message, identifier);
- frameLoader()->forceSandboxFlags(SandboxScripts | SandboxPlugins);
}
frameLoader()->policyChecker().checkContentPolicy(m_response, [this](PolicyAction policy) {
Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (208548 => 208549)
--- trunk/Source/WebCore/loader/ResourceLoader.cpp 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp 2016-11-10 18:50:08 UTC (rev 208549)
@@ -456,10 +456,6 @@
didFail(error);
return;
}
-
- String message = "Sandboxing '" + m_response.url().string() + "' because it is using HTTP/0.9.";
- m_frame->document()->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message, m_identifier);
- frameLoader()->forceSandboxFlags(SandboxScripts | SandboxPlugins);
}
if (FormData* data = ""
Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (208548 => 208549)
--- trunk/Source/WebCore/loader/SubresourceLoader.cpp 2016-11-10 18:36:44 UTC (rev 208548)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp 2016-11-10 18:50:08 UTC (rev 208549)
@@ -262,14 +262,6 @@
if (shouldIncludeCertificateInfo())
response.includeCertificateInfo();
- if (response.isHttpVersion0_9()) {
- if (m_frame) {
- String message = "Sandboxing '" + response.url().string() + "' because it is using HTTP/0.9.";
- m_frame->document()->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message, identifier());
- frameLoader()->forceSandboxFlags(SandboxScripts | SandboxPlugins);
- }
- }
-
if (m_resource->resourceToRevalidate()) {
if (response.httpStatusCode() == 304) {
// 304 Not modified / Use local copy