Vaccari's Code

Universal XSS bypassing uBlock Origin: Site-Controlled Element Selector

11/28/2026

Even the tools we design to protect ourselves can, ironically, become a vector for attacks if not built with the most rigorous security in mind. Such is the case with uBlock Origin, one of the most trusted and widely used browser extensions for ad and content blocking. Recently, a Universal XSS (Cross-Site Scripting) vulnerability was discovered in uBlock Origin, allowing a malicious website to inject arbitrary JavaScript code into any page visited by the user. And the most interesting part? Artificial intelligence played a crucial role in its discovery.

The Anatomy of a Universal XSS in uBlock Origin

To understand the severity of this flaw, first, we need to define what XSS is. In simple terms, an XSS is a vulnerability that allows an attacker to inject malicious code (usually JavaScript) into a website, which is then executed in the user's browser. A Universal XSS is even more dangerous, as it allows the code to be executed on any site, not just the one the attacker initially compromised.

The flaw was found in the MV2 (Manifest V2) version of uBlock Origin for Firefox, although a similar, but less severe, version also affected uBO Lite (MV3). The core of the issue lies in uBlock Origin's "element picker," a very useful tool that allows the user to select and block visual elements on a page with a simple right-click.

The "element picker" works by injecting an iframe – an HTML element that embeds another HTML document – which points to an internal extension URL, such as moz-extension://[RANDOM_UUID]/web_accessible_resources/epicker-ui.html. This page, in turn, can communicate with the extension's background script to add new filter rules. The attack unfolds in four main steps:

  1. Discover the picker's URL: The attacker needs to know the extension's UUID (Universally Unique Identifier), which is random for each installation.
  2. Create an invisible iframe: With the URL in hand, the attacker embeds the picker's iframe into their own site, making it invisible (with opacity: 0).
  3. Manipulate the picker: The malicious site "drives" the picker's iframe to add the desired filter.
  4. Trick the user into a click: Position the invisible iframe so that a legitimate user click on the attacker's page is interpreted as a click on the picker's "Create" button.

UUID Disclosure and Arbitrary Filter Injection

The first step, discovering the extension's UUID, is ingenious. In Firefox, uBlock Origin has a default filter rule (lootdest.*##+js(no-fetch-if, adsbygoogle, war:googlesyndication_adsbygoogle.js)) that intercepts fetch requests (an API for making network requests) and, internally, makes an XHR (XMLHttpRequest, another JavaScript object for HTTP requests) request to moz-extension://<UUID>/web_accessible_resources/googlesyndication_adsbygoogle.js. This internal request leaks the UUID.

An attacking site can intercept this internal XHR request by overwriting XMLHttpRequest.prototype.open:

const origOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(m, url, ...a) {
    const e = /^moz-extension:\/\/[^/]+/.exec(url);
    if (e) {
        e[0] // <- has the extension's UUID!
    }
    return origOpen.call(this, m, url, ...a);
};

By making a fetch('/adsbygoogle.js') request, the uBO filter is activated, the internal XHR request is made, and the attacker can extract the UUID. It's important to note that this isn't the only way to leak the UUID, but it was the one the researcher used.

With the UUID, the attacker can create their own iframe pointing to the element picker's URL. Then, using MessageChannel and postMessage – APIs for secure communication between different browsing contexts – the malicious site can communicate with the picker's iframe. Normally, the picker restricts the types of filters that can be added, prohibiting, for example, "scriptlet filters" (advanced filters that can execute small snippets of JavaScript).

However, there was a trick. In one of the messages sent to the picker, there's an opt field that is normally used to specify the request type (e.g., $image). The value of this field is appended to the filter. The attacker discovered they could insert a newline character (\n) into the opt field, allowing them to inject a completely arbitrary filter, such as:

image\ngoogle.com##+js(trusted-rpnt, script, ...)

This allowed the injection of a "trusted filter" – a filter with special permissions – that could execute JavaScript on any domain. The main flaw here is that the element picker should not accept messages from an attacker without validation. One of the implemented fixes was the inclusion of a "secret password" that the real picker receives and sends in the initial message.

The Impact: Arbitrary JavaScript on Any Site

The final part of the attack involved "the click." Since the picker's iframe can be made invisible, the malicious site can overlay visual elements or simply wait for the user to click anywhere on the page. This click would then be "captured" by the picker's invisible "Create" button.

The result? uBlock Origin would add a trusted filter containing the attacker's arbitrary JavaScript for any domain. Since these filters are treated as "trusted," they have the ability to inject code into any site the user visits. Although a recompilation of the filters (for example, after the user manually edits their rules) could remove the trust, the attacker could simply immediately open the victim's page to ensure script execution.

Why This Matters To You

This vulnerability is a vivid reminder that security is a shared and continuous responsibility, even for the tools we trust the most. For developers, the lesson is clear: rigorous validation of all input, regardless of its apparent origin. In the case of postMessage, this means not only checking the origin (event.origin) but also the content of the messages, ensuring that no unexpected or malicious data can be processed. Small details, such as a newline character in a field, can have catastrophic consequences.

For tech leaders and decision-makers, the story highlights the importance of investing in security from design, testing extensively (including with the help of AI tools, as seen here with GPT-5.6 Sol, which found the flaw), and always being vigilant. The attack surface of web applications and browser extensions is vast and complex. The trust we place in our digital tools demands that they be built with unshakeable resilience.

Sources


📬 Enjoyed this? Subscribe to the Vaccari's Code newsletter for the next wave of software & AI trends, straight to your inbox: Subscribe here

← all posts · listen to the episode →