Title: [186613] branches/safari-600.8-branch

Diff

Modified: branches/safari-600.8-branch/LayoutTests/ChangeLog (186612 => 186613)


--- branches/safari-600.8-branch/LayoutTests/ChangeLog	2015-07-09 21:01:54 UTC (rev 186612)
+++ branches/safari-600.8-branch/LayoutTests/ChangeLog	2015-07-09 21:01:59 UTC (rev 186613)
@@ -1,5 +1,26 @@
 2015-07-09  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r186505. rdar://problem/21707923
+
+    2015-07-08  Matthew Hanson  <matthew_han...@apple.com>
+
+            Merge r185848. rdar://problem/21708274
+
+        2015-06-22  Michael Catanzaro  <mcatanz...@igalia.com>
+
+                Web sockets should be treated as active mixed content
+                https://bugs.webkit.org/show_bug.cgi?id=140624
+
+                Reviewed by Sam Weinig.
+
+                * http/tests/security/mixedContent/resources/frame-with-insecure-websocket.html: Added.
+                * http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe-expected.txt: Added.
+                * http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe.html: Added.
+                * http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame-expected.txt: Added.
+                * http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame.html: Added.
+
+2015-07-09  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r186504. rdar://problem/21707900
 
     2015-07-07  Matthew Hanson  <matthew_han...@apple.com>

Added: branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/resources/frame-with-insecure-websocket.html (0 => 186613)


--- branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/resources/frame-with-insecure-websocket.html	                        (rev 0)
+++ branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/resources/frame-with-insecure-websocket.html	2015-07-09 21:01:59 UTC (rev 186613)
@@ -0,0 +1,30 @@
+<script src=""
+<script>
+window.jsTestIsAsync = true;
+
+function onSocketOpened() {
+    alert("WebSocket connection opened.");
+    finishJSTest();
+}
+
+function onSocketError() {
+    alert("WebSocket connection failed.");
+    finishJSTest();
+}
+
+function onSocketClosed() {
+    alert("WebSocket closed.");
+    finishJSTest();
+}
+
+try {
+    var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/echo");
+    ws._onopen_ = onSocketOpened;
+    ws._onerror_ = onSocketError;
+    ws._onclose_ = onSocketClosed;
+} catch (e) {
+    alert("Test failed: exception thrown");
+    finishJSTest();
+}
+</script>
+<script src=""

Added: branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe-expected.txt (0 => 186613)


--- branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe-expected.txt	                        (rev 0)
+++ branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe-expected.txt	2015-07-09 21:01:59 UTC (rev 186613)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: line 21: [blocked] The page at https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-websocket.html was not allowed to run insecure content from ws://127.0.0.1:8880/websocket/tests/hybi/echo.
+
+ALERT: WebSocket connection failed.
+This test loads an iframe that creates an insecure WebSocket connection. We should block the connection and trigger a mixed content callback because the main frame is HTTPS, but the data sent over the socket could be recorded or controlled by an attacker.
+
+

Added: branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe.html (0 => 186613)


--- branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe.html	                        (rev 0)
+++ branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe.html	2015-07-09 21:01:59 UTC (rev 186613)
@@ -0,0 +1,9 @@
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+</script>
+<p>This test loads an iframe that creates an insecure WebSocket connection. We
+should block the connection and trigger a mixed content callback because the
+main frame is HTTPS, but the data sent over the socket could be recorded or
+controlled by an attacker.</p>
+<iframe src=""

Added: branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame-expected.txt (0 => 186613)


--- branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame-expected.txt	                        (rev 0)
+++ branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame-expected.txt	2015-07-09 21:01:59 UTC (rev 186613)
@@ -0,0 +1,4 @@
+CONSOLE MESSAGE: line 21: [blocked] The page at https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-websocket.html was not allowed to run insecure content from ws://127.0.0.1:8880/websocket/tests/hybi/echo.
+
+ALERT: WebSocket connection failed.
+This test opens a window that connects to an insecure ws:// WebSocket. We should block the connection and trigger a mixed content callback because the main frame is HTTPS, but the data sent over the socket could be recorded or controlled by an attacker.

Added: branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame.html (0 => 186613)


--- branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame.html	                        (rev 0)
+++ branches/safari-600.8-branch/LayoutTests/http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame.html	2015-07-09 21:01:59 UTC (rev 186613)
@@ -0,0 +1,27 @@
+<html>
+<body>
+<script>
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+    testRunner.setCanOpenWindows();
+    testRunner.setCloseRemainingWindowsWhenComplete(true);
+}
+
+window.addEventListener("message", function (e) {
+  if (window.testRunner)
+      testRunner.notifyDone();
+}, false);
+
+</script>
+<p>This test opens a window that connects to an insecure ws:// WebSocket.  We
+should block the connection and trigger a mixed content callback because the
+main frame is HTTPS, but the data sent over the socket could be recorded or
+controlled by an attacker.</p>
+<script>
+_onload_ = function() {
+    window.open("https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-websocket.html");
+}
+</script>
+</body>
+</html>

Modified: branches/safari-600.8-branch/Source/WebCore/ChangeLog (186612 => 186613)


--- branches/safari-600.8-branch/Source/WebCore/ChangeLog	2015-07-09 21:01:54 UTC (rev 186612)
+++ branches/safari-600.8-branch/Source/WebCore/ChangeLog	2015-07-09 21:01:59 UTC (rev 186613)
@@ -1,5 +1,29 @@
 2015-07-09  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r186505. rdar://problem/21707923
+
+    2015-07-08  Matthew Hanson  <matthew_han...@apple.com>
+
+            Merge r185848. rdar://problem/21708274
+
+        2015-06-22  Michael Catanzaro  <mcatanz...@igalia.com>
+
+                Web sockets should be treated as active mixed content
+                https://bugs.webkit.org/show_bug.cgi?id=140624
+
+                Reviewed by Sam Weinig.
+
+                Tests: http/tests/security/mixedContent/websocket/insecure-websocket-in-iframe.html
+                       http/tests/security/mixedContent/websocket/insecure-websocket-in-main-frame.html
+
+                * Modules/websockets/WebSocket.cpp:
+                (WebCore::WebSocket::connect): Block ws:// WebSocket connections from https:// pages, and
+                emit the onerror event after doing so.
+                * platform/SchemeRegistry.cpp:
+                (WebCore::secureSchemes): Add wss:// to the list of secure schemes.
+
+2015-07-09  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r186504. rdar://problem/21707900
 
     2015-07-07  Matthew Hanson  <matthew_han...@apple.com>

Modified: branches/safari-600.8-branch/Source/WebCore/Modules/websockets/WebSocket.cpp (186612 => 186613)


--- branches/safari-600.8-branch/Source/WebCore/Modules/websockets/WebSocket.cpp	2015-07-09 21:01:54 UTC (rev 186612)
+++ branches/safari-600.8-branch/Source/WebCore/Modules/websockets/WebSocket.cpp	2015-07-09 21:01:59 UTC (rev 186613)
@@ -57,6 +57,7 @@
 #include <runtime/ArrayBufferView.h>
 #include <wtf/HashSet.h>
 #include <wtf/PassOwnPtr.h>
+#include <wtf/RunLoop.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
@@ -278,6 +279,23 @@
         }
     }
 
+    if (scriptExecutionContext()->isDocument()) {
+        Document& document = toDocument(*scriptExecutionContext());
+        if (!document.frame()->loader().mixedContentChecker().canRunInsecureContent(document.securityOrigin(), m_url)) {
+            // Balanced by the call to ActiveDOMObject::unsetPendingActivity() in WebSocket::stop().
+            ActiveDOMObject::setPendingActivity(this);
+            // We must block this connection. Instead of throwing an exception, we indicate this
+            // using the error event. But since this code executes as part of the WebSocket's
+            // constructor, we have to wait until the constructor has completed before firing the
+            // event; otherwise, users can't connect to the event.
+            RunLoop::main().dispatch([this]() {
+                dispatchEvent(Event::create(eventNames().errorEvent, false, false));
+                stop();
+            });
+            return;
+        }
+    }
+
     String protocolString;
     if (!protocols.isEmpty())
         protocolString = joinStrings(protocols, subProtocolSeperator());

Modified: branches/safari-600.8-branch/Source/WebCore/platform/SchemeRegistry.cpp (186612 => 186613)


--- branches/safari-600.8-branch/Source/WebCore/platform/SchemeRegistry.cpp	2015-07-09 21:01:54 UTC (rev 186612)
+++ branches/safari-600.8-branch/Source/WebCore/platform/SchemeRegistry.cpp	2015-07-09 21:01:59 UTC (rev 186613)
@@ -58,6 +58,7 @@
         secureSchemes.add("https");
         secureSchemes.add("about");
         secureSchemes.add("data");
+        secureSchemes.add("wss");
     }
 
     return secureSchemes;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to