Opened on 12/21/2014 at 03:07:02 AM

Closed on 08/10/2016 at 04:49:45 PM

Last modified on 02/29/2020 at 11:46:32 PM

#1727 closed defect (fixed)

WebSocket connections can't be blocked

Reported by: fanboy Assignee: kzar
Priority: P2 Milestone: Adblock-Plus-1.12.2-for-Chrome-Opera-Safari
Module: Platform Keywords:
Cc: sebastian, mapx, greiner, kzar, arthur, fhd, Lain_13, Ross, scheer Blocked By: #4331, #4332
Blocking: Platform: Chrome
Ready: yes Confidential: no
Tester: Unknown Verified working: yes
Review URL(s):

Description (last modified by kzar)


  • Adblock Plus for Chrome 1.11, Chrome 50.
  • EasyList enabled, including the filter ||^$third-party.

How to reproduce

  1. Visit
  2. Open the Chrome developer tools, click the Network tab and then the WS section.

Observed behaviour

A WebSocket to ws:// is successfully opened, adverts are displayed on the page.

Expected behaviour

The WebSocket connection/messages should be blocked, there should be no adverts displayed.


Chrome currently doesn't allow extensions to block WebSockets, Chromium bug #129353 has been open for some time now to address this limitation but little progress seems to have been made.

In the mean time both uBlock Origin and the Adguard browser extension have added a workaround. They use a content script to inject a wrapper for WebSocket into pages. The wrapper performs a dummy web request before WebSocket messages are sent/received. The extension recognises these dummy web requests as representing a WebSocket message. It intercepts and blocks them if the corresponding WebSocket message should be blocked. The WebSocket wrapper then allows / blocks the WebSocket message based on whether the dummy web request was blocked or not.

This is becoming an increasingly important problem as more and more websites are using WebSockets for advertising. We now need to add a similar work around to adblockpluschrome


Hints for testers

In supported versions of Chrome, Opera and Safari test the following:

It's important to test as many websites that use WebSockets properly as possible, wrapping WebSocket like this could well cause problems. (For more examples see the discussions linked in the References section above.)

We refactored some of the code added with issue #1677 whilst making these changes. So it's also important to make sure that code to protect our ElemHide stylesheets still works. In case the US version of Yahoo no longer uses this circumvention technique here are the steps I took to test the feature. (All in the console for a webpage.)

  1. Find our stylesheet: var sheet = document.documentElement.shadowRoot.styleSheets[0]; (Note: On some browsers you will need to remove the ".shadowRoot", also note that 0 might be the wrong index. You'll have to experiment to figure out the correct number.)
  2. Make sure you have the correct stylesheet by checking its first rule: sheet.rules[0]; (It should have a whole bunch of selectors to hide advertisements.)
  3. Once you have the correct stylesheet take note of the number of rules it contains: sheet.rules.length; (For me, with just EasyList enabled I saw 87 rules.)
  4. Now try removing a rule: sheet.removeRule(0); sheet.deleteRule(0);
  5. Now check no rules were removed, by checking the number of rules again: sheet.rules.length;
  6. Finally ensure our sheet can't be disabled: sheet.disabled = true; sheet.disabled; (Should display false.)

Finally we also refactored some code relating to YouTube adblocking for older versions of Safari which used Flash. Please test that YouTube adverts do not play when using an old version of Safari, to make sure a regression like #4141 has not resurfaced. (Take a look at that issue for some more testing approaches.)

Attachments (0)

Change History (37)

comment:1 Changed on 12/21/2014 at 04:41:14 PM by sebastian

  • Cc sebastian added
  • Component changed from Unknown to Platform
  • Description modified (diff)
  • Resolution set to worksforme
  • Status changed from new to closed

With no filter subscription but this one filter configured, I get the popup, both with Chrome and Firefox. However when I use EasyList I don't get a popup there with either browser.

However, note that Adblock Plus for Chrome currently treats all requests with type other as if they are of the type object, to work around, which caused issues like #1372.

comment:2 Changed on 12/23/2014 at 09:49:12 PM by fanboy

If its that's the case Chrome isn't blocking outright. There has been reports be a few users regarding this;

These were fixed by myself by disabling filter in Firefox, would be nice to see if Chrome blocking this script. If left alone wsockd will keep on generating popups for Chrome users.

comment:3 Changed on 12/23/2014 at 10:07:22 PM by fanboy

Also wsock isn't limited to just the above site; Also seen on these. (probably far more)

comment:4 Changed on 12/26/2014 at 04:34:04 PM by sebastian

  • Keywords externaldependency added
  • Priority changed from Unknown to P2
  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Summary changed from Chrome supporting $other to WebSocket connections can't be blocked

It seems that Chrome currently doesn't allow extensions to intercept WebSocket connections. But they plan to implement it by Once the webRequest API supports WebSocket connections we have to add the ws:// and wss:// URL schemes in our code.

comment:5 Changed on 12/28/2014 at 08:43:13 PM by mapx

  • Cc mapx added

comment:6 Changed on 12/30/2014 at 10:22:05 AM by sebastian

  • Priority changed from P2 to P3

comment:7 Changed on 03/03/2016 at 10:58:11 PM by Lain_13 - here is another example. This time it's ( ws:// ). Instead of loading popups they are loading scripts and images, and then insert them into page using data:url. It's possible to circumvent by hiding, but if they will also use !important trick it will became a serious issue.

Last edited on 03/03/2016 at 11:12:23 PM by Lain_13

comment:8 Changed on 04/27/2016 at 11:40:03 AM by mapx

  • Tester set to Unknown
  • Verified working unset


Maybe we can use new JS features (Proxy, WeakMap) to intercept or wrap around the script execution from Chrome extension. There's an example of a wrapper around WebSocket API created by the developer behind uBlock Origin.
See detail here

comment:9 Changed on 04/27/2016 at 11:42:01 AM by mapx

  • Cc greiner kzar added

comment:10 Changed on 05/30/2016 at 09:23:12 AM by arthur

  • Cc arthur added

uBlock Origin had some support for blocking WebSockets in version 1.7.0 but it was removed later and a separete extension was created. Not sure how good it works though.

comment:11 Changed on 05/30/2016 at 09:28:30 AM by mapx

the guys from adguard improved the approach and the last idea was to add the websockets support back in the extension

comment:12 Changed on 05/30/2016 at 10:41:08 AM by kzar

  • Description modified (diff)
  • Keywords externaldependency removed
  • Priority changed from P3 to P2
  • Ready set

We agree this is an important problem, we'll tackle it as soon as possible. Unfortunately that likely won't be before late June / early July.

comment:13 Changed on 06/17/2016 at 04:16:50 PM by fhd

  • Cc fhd added

comment:14 Changed on 06/21/2016 at 09:26:17 AM by kzar

  • Owner set to kzar

comment:15 Changed on 06/23/2016 at 06:15:01 PM by mapx

  • Cc Lain_13 added

comment:16 Changed on 06/23/2016 at 06:50:40 PM by Lain_13

BTW, I've implemented my own stand-alone wrapper-blocker (actually instead of blocking it simulates working websocket).

Rather simple and dirty, but it works.

Last edited on 06/23/2016 at 06:53:37 PM by Lain_13

comment:17 Changed on 06/25/2016 at 02:05:41 PM by kzar

Thanks Lain_13, interesting to see your approach, it didn't occur to me to use a Proxy object and that actually would be a pretty nice way to wrap WebSocket, preventing access to the original constructor. Unfortunately we support older browser versions (Safari 9 and Chrome < 49) which don't have Proxy support.

I'm on it anyway, will update you guys when I have something I'm happy with!

comment:18 Changed on 06/25/2016 at 05:40:13 PM by kzar

Making some progress, little teaser for you guys :)

comment:19 Changed on 06/26/2016 at 11:57:11 AM by kzar

  • Review URL(s) modified (diff)
  • Status changed from reopened to reviewing

comment:20 Changed on 06/26/2016 at 12:06:37 PM by kzar

  • Description modified (diff)

comment:21 follow-up: Changed on 06/26/2016 at 12:12:46 PM by fanboy

So filters like this should also work?


comment:22 Changed on 06/26/2016 at 03:51:00 PM by Lain_13

[moved this comment to code review]

Last edited on 06/26/2016 at 03:57:57 PM by Lain_13

comment:23 in reply to: ↑ 21 Changed on 06/26/2016 at 08:32:12 PM by kzar

Replying to fanboy:

So filters like this should also work?

Yup, think they should work :)

comment:24 Changed on 07/28/2016 at 10:59:25 AM by kzar

  • Description modified (diff)

comment:25 Changed on 07/28/2016 at 11:14:13 AM by kzar

  • Description modified (diff)

comment:26 Changed on 08/10/2016 at 01:14:24 PM by kzar

  • Description modified (diff)

comment:27 Changed on 08/10/2016 at 04:45:34 PM by abpbot

A commit referencing this issue has landed:
Issue 1727 - Prevent circumvention via WebSocket

comment:28 Changed on 08/10/2016 at 04:49:45 PM by kzar

  • Cc Ross scheer added
  • Milestone set to Adblock-Plus-for-Chrome-Opera-Safari-next
  • Resolution set to fixed
  • Status changed from reviewing to closed

Heads up Ross / Scott, this one will need a lot of testing!

comment:29 Changed on 08/11/2016 at 02:13:27 PM by sebastian

  • Review URL(s) modified (diff)

comment:30 Changed on 08/11/2016 at 03:44:41 PM by abpbot

comment:31 Changed on 08/15/2016 at 01:09:27 PM by trev

  • Blocked By 4331 added

comment:32 Changed on 08/15/2016 at 01:31:04 PM by trev

  • Blocked By 4332 added

comment:33 Changed on 08/23/2016 at 06:41:36 AM by rraceanu

  • Verified working set

Ads circumventing ABP with WebSocket are being blocked.

Win 10 Home x64- 10586
Chrome 52
Opera 39, 41(dev build)

Win 7 x64
Chrome 30,31,42,43,50
Opera 19,23,28,39,36


||^$third-party (blocked - RuAdlist+Easylist)


||^$third-party (RuAdlist+Easylist)

  • (WS connections blocked)

||^$third-party (blocked - Easylist)

||^$third-party (blocked - Easylist)

  • (ws connections blocked)

||^$third-party (blocked - Easylist)

  • (blocked - Easylist)
  • works properly.
  • (header and sidebar loads)
  • (chat loads promptly - 3-5 sec)

Safari 6 OS 10.8 x64


ws:// - index 3 (blocked)

  • ("ws://") - index 1 (not blocked)

||^$third-party - No ads displayed.

("ws://") - index 3 (blocked)

||^$third-party (blocked - Easylist) - (blocked -Easylist)


("ws://") - index 3 (blocked)
||^$third-party (blocked - Easylist)

  • (blocked - Easylist)
  • (not supported on Safari 6, page is broken)
  • chat works properly
  • works properly.

Safari 7 - OSX 10.9 x64
Safari 9 - OS 10.11 x64


||^$third-party (blocked - RuAdlist+Easylist)


||^$third-party (blocked - RuAdlist+Easylist)

  • (WS connections blocked)

||^$third-party (blocked - Easylist)
||^$third-party (blocked - Easylist)

  • (ws connections blocked)

||^$third-party (blocked - Easylist)

  • (blocked - Easylist)
  • works properly.
  • (header and sidebar loads)
  • (chat loads promptly - 3-5 sec)
Last edited on 08/23/2016 at 11:01:39 AM by mapx

comment:34 Changed on 08/23/2016 at 10:50:59 AM by routehero

Users should be presented with the fact that Adblock Plus will overwrite WebSocket() functionality.

Failing to do so does not allow the user to make informed decisions about what is happening in their browser.

Malicious extension authors could also use this technique. This strikes me as a slippery slope.

comment:35 Changed on 08/23/2016 at 11:26:27 AM by Lain_13

Oh man, you came here as well. I'll just leave this link here:
Just for the reference. Everyone here already seen this discussion.

Last edited on 08/23/2016 at 11:28:37 AM by Lain_13

comment:36 follow-up: Changed on 12/14/2017 at 02:28:08 PM by ricard85perez

Hello colleagues, I have a problem. When I try to broadcast online with my coworkers via webcam, I get advertising from and I can not eliminate it. I have well configured adblockplus and I can not solve this problem and I always have to disconnect the webcam when I have to transmit on facebook or another videoconference page

Last edited on 02/29/2020 at 11:46:32 PM by ricard85perez

comment:37 in reply to: ↑ 36 Changed on 12/14/2017 at 02:36:05 PM by kzar

Replying to ricard85perez:

Hello colleagues, I have a problem. When I try to broadcast online with my coworkers via webcam, I get advertising from and I can not eliminate it. I have well configured adblockplus and I can not solve this problem and I always have to disconnect the webcam when I have to transmit on facebook or another videoconference page

Hi Ricard,

It sounds like you could have malware on your computer, I would first of all install a virus scanner and check your computer for viruses and malware.

If that doesn't help you could report the advert that is not being blocked to EasyList, perhaps they will be able to add a filter which helps you.

Finally I should mention this is not the right place to report such problems, in the future please instead ask questions on the Adblock Plus forums.

Cheers, Dave.

Add Comment

Modify Ticket

Change Properties
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from kzar.
Note: See TracTickets for help on using tickets.