RESOLVED FIXED 160159
Content Blocker cannot block WebSocket connections
https://bugs.webkit.org/show_bug.cgi?id=160159
Summary Content Blocker cannot block WebSocket connections
Andrey Meshkov
Reported 2016-07-25 02:54:42 PDT
Steps to reproduce: 1. Register a simple content blocker: [{trigger: {url-filter: "echo.websocket.org" }, action: {type: "block"}}] 2. Go to https://websocket.org/echo.html 3. Click "Connect", then "Send" Expected result: WebSocket connection should be blocked by the content blocker. Actual result: WebSocket connection is working.
Attachments
Patch (37.46 KB, patch)
2016-07-28 17:57 PDT, Alex Christensen
no flags
Patch (77.08 KB, patch)
2016-08-01 17:05 PDT, Alex Christensen
no flags
Archive of layout-test-results from ews103 for mac-yosemite (864.21 KB, application/zip)
2016-08-01 17:58 PDT, Build Bot
no flags
Archive of layout-test-results from ews125 for ios-simulator-wk2 (735.72 KB, application/zip)
2016-08-01 17:59 PDT, Build Bot
no flags
Archive of layout-test-results from ews104 for mac-yosemite-wk2 (802.17 KB, application/zip)
2016-08-01 18:04 PDT, Build Bot
no flags
Archive of layout-test-results from ews112 for mac-yosemite (1.56 MB, application/zip)
2016-08-01 18:12 PDT, Build Bot
no flags
Patch (78.16 KB, patch)
2016-08-01 21:21 PDT, Alex Christensen
no flags
Patch (78.79 KB, patch)
2016-08-04 10:37 PDT, Alex Christensen
no flags
Radar WebKit Bug Importer
Comment 1 2016-07-26 16:17:48 PDT
Alex Christensen
Comment 2 2016-07-28 17:57:54 PDT
Andrey Meshkov
Comment 3 2016-07-29 01:41:00 PDT
Thank you Alex! Offtop: I see you've added a new feature for forcing HTTPS? Is it in the stable Safari version already?
Alex Christensen
Comment 4 2016-08-01 17:05:21 PDT
Build Bot
Comment 5 2016-08-01 17:58:32 PDT
Comment on attachment 285054 [details] Patch Attachment 285054 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/1795547 New failing tests: http/tests/websocket/tests/hybi/contentextensions/upgrade.html http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html http/tests/websocket/tests/hybi/contentextensions/block.html http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php http/tests/websocket/tests/hybi/contentextensions/block-cookies.php http/tests/websocket/tests/hybi/contentextensions/block-worker.html http/tests/websocket/tests/hybi/contentextensions/display-none.html
Build Bot
Comment 6 2016-08-01 17:58:35 PDT
Created attachment 285059 [details] Archive of layout-test-results from ews103 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews103 Port: mac-yosemite Platform: Mac OS X 10.10.5
Build Bot
Comment 7 2016-08-01 17:59:48 PDT
Comment on attachment 285054 [details] Patch Attachment 285054 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/1795517 New failing tests: http/tests/websocket/tests/hybi/contentextensions/upgrade.html http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html http/tests/websocket/tests/hybi/contentextensions/block.html http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php http/tests/websocket/tests/hybi/contentextensions/block-cookies.php http/tests/websocket/tests/hybi/contentextensions/block-worker.html http/tests/websocket/tests/hybi/contentextensions/display-none.html
Build Bot
Comment 8 2016-08-01 17:59:50 PDT
Created attachment 285060 [details] Archive of layout-test-results from ews125 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews125 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.5
Build Bot
Comment 9 2016-08-01 18:04:29 PDT
Comment on attachment 285054 [details] Patch Attachment 285054 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/1795554 New failing tests: http/tests/contentextensions/make-https.html
Build Bot
Comment 10 2016-08-01 18:04:32 PDT
Created attachment 285061 [details] Archive of layout-test-results from ews104 for mac-yosemite-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
Build Bot
Comment 11 2016-08-01 18:12:46 PDT
Comment on attachment 285054 [details] Patch Attachment 285054 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/1795559 New failing tests: http/tests/websocket/tests/hybi/contentextensions/upgrade.html http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html http/tests/websocket/tests/hybi/contentextensions/block.html http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php http/tests/websocket/tests/hybi/contentextensions/block-cookies.php http/tests/websocket/tests/hybi/contentextensions/block-worker.html http/tests/websocket/tests/hybi/contentextensions/display-none.html
Build Bot
Comment 12 2016-08-01 18:12:49 PDT
Created attachment 285064 [details] Archive of layout-test-results from ews112 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews112 Port: mac-yosemite Platform: Mac OS X 10.10.5
Alex Christensen
Comment 13 2016-08-01 21:21:13 PDT
Brady Eidson
Comment 14 2016-08-04 10:03:53 PDT
Comment on attachment 285071 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=285071&action=review > Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:237 > + m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = makeRef(*this)] (ScriptExecutionContext&) { > + if (m_client) > + m_client->didUpgradeURL(); > + })); This makes me super, super sad; That ThreadableWebSocketChannelClientWrapper has its own m_pendingTasks queue, to execute tasks in the ScriptExecutionContext's thread, when ScriptExecutionContext already has that functionality. I know this is established style in the class, so you shouldn't change it now, but please file a bug to follow up and get rid of that. > Source/WebCore/Modules/websockets/WebSocketHandshake.cpp:257 > - // Set "Cookie2: <cookie>" if cookies 2 exists for url? > - } > + String cookie = cookieRequestHeaderFieldValue(m_document, url); > + if (!cookie.isEmpty()) > + request.setHTTPHeaderField(HTTPHeaderName::Cookie, cookie); > + // Set "Cookie2: <cookie>" if cookies 2 exists for url? Do we have a bugzilla for Cookie2? Should this be a formal FIXME referencing that bugzilla? If not, then I don't see the value in keeping the comment.
Alex Christensen
Comment 15 2016-08-04 10:36:40 PDT
(In reply to comment #14) > Comment on attachment 285071 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=285071&action=review > > > Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:237 > > + m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = makeRef(*this)] (ScriptExecutionContext&) { > > + if (m_client) > > + m_client->didUpgradeURL(); > > + })); > > This makes me super, super sad; That ThreadableWebSocketChannelClientWrapper > has its own m_pendingTasks queue, to execute tasks in the > ScriptExecutionContext's thread, when ScriptExecutionContext already has > that functionality. > > I know this is established style in the class, so you shouldn't change it > now, but please file a bug to follow up and get rid of that. https://bugs.webkit.org/show_bug.cgi?id=160557 > > > Source/WebCore/Modules/websockets/WebSocketHandshake.cpp:257 > > - // Set "Cookie2: <cookie>" if cookies 2 exists for url? > > - } > > + String cookie = cookieRequestHeaderFieldValue(m_document, url); > > + if (!cookie.isEmpty()) > > + request.setHTTPHeaderField(HTTPHeaderName::Cookie, cookie); > > + // Set "Cookie2: <cookie>" if cookies 2 exists for url? > > Do we have a bugzilla for Cookie2? > Should this be a formal FIXME referencing that bugzilla? > > If not, then I don't see the value in keeping the comment. Removed comment. We have not yet supported cookie2 in websockets, and it's deprecated. https://tools.ietf.org/html/rfc6265#section-9.3
Alex Christensen
Comment 16 2016-08-04 10:37:45 PDT
WebKit Commit Bot
Comment 17 2016-08-04 11:09:07 PDT
Comment on attachment 285337 [details] Patch Clearing flags on attachment: 285337 Committed r204127: <http://trac.webkit.org/changeset/204127>
WebKit Commit Bot
Comment 18 2016-08-04 11:09:13 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.