browser.devtools.inspectedWindow.eval isn't blocked on addons.mozilla.org
The browser's devtools API allowed an extension to execute arbitrary JavaScript on addons.mozilla.org, a protected domain where other script-injection APIs are blocked. An attacker could run code in the context of that site, potentially compromising user accounts or data.
Originally disclosed on Mozilla
- Fixed in 3 months
- Paid in 4 months
- Disclosed after 3 months
Created attachment 8936762
devtools-panels-poc.zip
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Steps to reproduce:
1. Unpack attached PoC addon
2. Go to about:debugging and temporarily load the unpacked addon
3. Go to 'addons.mozilla.org'
4. Open web inspector
Actual results:
We execute arbitrary JS on addons.mozilla.org
Expected results:
Since tabs.executeScript() doesn't work on the addons page, I think its reasonable to do the same for devtools.inspectedWindow()
What the report shows
The target is the Developer Tools component of Mozilla's WebExtensions platform, specifically the browser.devtools.inspectedWindow.eval API. The researcher, Abdulrahman Alqabandi, reported that this API is not blocked on addons.mozilla.org, while the closely related tabs.executeScript() is. The report was disclosed on 28 March 2018 and rated medium severity.
The reproduction is short and consists of four steps:
- Unpack the attached PoC addon (
devtools-panels-poc.zip). - Go to
about:debuggingand temporarily load the unpacked addon. - Go to
addons.mozilla.org. - Open the web inspector.
The user agent recorded in the report is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
The actual result, in the researcher's words, is that arbitrary JavaScript is executed on addons.mozilla.org. The expected result is that the same restriction applied to tabs.executeScript() should apply to devtools.inspectedWindow(), since the former does not work on the addons page. The report does not give a bounty amount, a CVSS score, a weakness classification or details of the fix.
Root cause
The report points to an inconsistency in how privileged extension APIs are restricted on Mozilla's own addons site. tabs.executeScript() is blocked from injecting into addons.mozilla.org, but devtools.inspectedWindow.eval is not, so an extension that opens the web inspector on that origin can still evaluate script in the page. The report does not state why the check covers one path and not the other.
Impact
An installed extension could run arbitrary JavaScript in the context of addons.mozilla.org.
How this kind of bug works
Browsers and extension platforms often protect sensitive origins, such as the vendor's own add-on store, from extension script injection. The protection is usually implemented as a check on the injection API: the browser refuses to run content scripts or evaluated code in a tab whose URL matches a protected origin. The weakness appears when several APIs can achieve the same effect and the check is applied to only some of them. tabs.executeScript and devtools.inspectedWindow.eval both execute code in a page, but they travel through different code paths, so a guard placed in one path does not automatically cover the other.
This is a general pattern: a security decision is enforced at the wrong layer, at the level of a single API rather than at the level of the capability. Any new or less common API that reaches the same capability reopens the hole. Defences that hold are centralised checks on the target origin performed at the point where code is actually injected, independent of which API requested it, plus tests that enumerate every injection-capable API against the protected origins.
How to test for it
- Identify the protected origins. These are usually the vendor's add-on store, account pages and other high-value domains where extension injection is meant to be refused.
- Enumerate every API that can execute code or read page content in a tab: tab script injection, devtools evaluation, debugging protocols, content script registration, and any newer API that reaches the same place.
- For each API, attempt to run a harmless marker (for example, setting a variable or reading
document.domain) against a tab on a protected origin, and check whether it executes. - Compare results across APIs. A positive result is one API succeeding where another is refused on the same origin, which shows the guard is incomplete.
- Confirm the result is not caused by the extension having host permissions that legitimately override the block, and not by the page being a different origin after a redirect. These are the common false positives.
Requests here are made through the extension APIs rather than raw HTTP, so the test is about which API call succeeds, not about crafting a payload.
How it is fixed
Protected origins should be defined in one place, and the check should run at the moment code would be executed in the target page. Regression tests should exercise each injection-capable API against each protected origin, so that a future API cannot silently bypass the restriction.
Hunting notes
This class of bug tends to hide wherever a platform has more than one way to reach the same privileged operation: extension APIs, debugging interfaces, automation protocols and internal tooling. Recon signals include documentation that lists several APIs with overlapping capabilities, changelogs that add a new injection or evaluation method, and any statement that a particular origin is protected from extensions. When you find one blocked path, look for its siblings.
A short reproduction with a small proof-of-concept extension and a precise expected-versus-actual comparison is usually enough.
What happened, in plain words
This report is about a browser extension being able to run its own code inside a Mozilla website where it should not be allowed to. The website in question is addons.mozilla.org, Mozilla's add-on store, the place where people download browser extensions. The researcher, Abdulrahman Alqabandi, found that a particular extension feature could still execute JavaScript on that page, even though a closely related feature was already blocked there. The report was disclosed on 28 March 2018 and rated medium severity.
A few words first, because the rest depends on them.
- A browser extension (Mozilla calls them add-ons) is a small program you install into your browser to add features. Because it lives inside the browser, it can do things a normal website cannot, such as reading or changing the contents of pages you visit.
- JavaScript is the programming language that web pages run inside your browser. If someone can run their own JavaScript in a page, they can make that page do things its owners did not intend.
addons.mozilla.orgis a sensitive site: it is where extensions are distributed, so Mozilla does not want other extensions quietly changing what happens there.- Developer Tools (the web inspector) is the panel built into browsers for inspecting and debugging pages. Extensions can talk to it through an API, which is a set of commands the browser offers to extension code.
The two extension features at the centre of the report are:
tabs.executeScript(): asks the browser to run a piece of JavaScript inside a tab. Mozilla had already made this refuse to work onaddons.mozilla.org.browser.devtools.inspectedWindow.eval: asks the browser to evaluate JavaScript in the page currently open in the developer tools panel. This one was not blocked onaddons.mozilla.org.
Both end up running code in a page. Only one of them was stopped. That gap is the bug.
What the report shows
The researcher attached a small proof-of-concept extension, devtools-panels-poc.zip, and gave four steps to reproduce the problem:
- Unpack the attached PoC addon.
- Go to
about:debuggingand temporarily load the unpacked addon. - Go to
addons.mozilla.org. - Open the web inspector.
Each step matters. Unpacking the zip gives you the extension's files in a folder. about:debugging is a built-in browser page for loading an extension temporarily from a folder, without publishing it, which is exactly what you want for a test like this. Visiting addons.mozilla.org puts the protected site in front of the extension. Opening the web inspector is the last step of the reproduction.
The user agent recorded in the report is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
A user agent is the short text a browser sends to identify itself and its version. Here it records the browser and operating system used during the test.
The actual result, in the researcher's words, is that arbitrary JavaScript is executed on addons.mozilla.org. The expected result is that the same restriction that applies to tabs.executeScript() should apply to devtools.inspectedWindow(), since the former does not work on the addons page. In other words: if one door is locked, the other door into the same room should be locked too.
The report does not give a bounty amount, a CVSS score, a weakness classification or details of the fix.
Why it happens
Mozilla protects its own add-on store from extension script injection. The protection is implemented as a check on the injection feature: the browser refuses to run code in a tab whose address matches a protected site. The problem is that there is more than one way to run code in a page. tabs.executeScript and devtools.inspectedWindow.eval both do it, but they go through different parts of the browser's code, so a check placed in one part does not automatically cover the other. The tabs route was blocked and the devtools route was not.
What it means in practice
An installed extension could run arbitrary JavaScript in the context of addons.mozilla.org. The report does not describe what that script did or what data it could reach, so the practical consequences beyond code execution on the page are not stated.
In general, how this kind of bug works
Browsers and extension platforms often protect sensitive sites, such as the vendor's own add-on store, from extension script injection. The protection is usually a check on the injection feature: the browser refuses to run code in a tab whose address matches a protected site.
The weakness appears when several features can achieve the same effect and the check is applied to only some of them. Think of a building with two entrances where the guard only stands at the front door. Anyone who knows about the side door walks straight in. In software, the side door is any newer or less common feature that reaches the same capability.
Defences that hold are centralised: the check on the target site is performed at the point where code is actually injected, no matter which feature asked for it. Tests should also try every code-running feature against every protected site, so a future feature cannot quietly reopen the hole.
In general, how to test for it
- Identify the protected sites. These are usually the vendor's add-on store, account pages and other high-value domains where extension injection is meant to be refused.
- List every feature that can run code or read page content in a tab: tab script injection, devtools evaluation, debugging protocols, content script registration, and any newer feature that reaches the same place.
- For each feature, try to run a harmless marker (for example, setting a variable or reading
document.domain) against a tab on a protected site, and check whether it executes. - Compare the results. A positive finding is one feature succeeding where another is refused on the same site, which shows the guard is incomplete.
- Rule out false positives: the extension may have permissions that legitimately override the block, or the page may have redirected to a different site. These are the common mistakes.
Requests here are made through the extension features rather than raw network traffic, so the test is about which call succeeds, not about crafting a payload.
In general, how it is fixed
Protected sites should be defined in one place, and the check should run at the moment code would be executed in the target page. Regression tests should exercise each code-running feature against each protected site, so that a future feature cannot silently bypass the restriction.
In general, where to look
This class of bug tends to hide wherever a platform has more than one way to reach the same privileged operation: extension features, debugging interfaces, automation protocols and internal tooling. Useful signals include documentation that lists several features with overlapping abilities, changelogs that add a new injection or evaluation method, and any statement that a particular site is protected from extensions. When you find one blocked path, look for its siblings.
A short reproduction with a small proof-of-concept extension and a precise expected-versus-actual comparison is usually enough.
Glossary
- Browser extension (add-on): a small program installed into a browser to add features, with more access to pages than a normal website has.
- JavaScript: the programming language web pages run inside the browser.
- API: a set of commands a program offers so other programs can use its features.
tabs.executeScript(): an extension feature that runs JavaScript inside a browser tab.browser.devtools.inspectedWindow.eval: an extension feature that evaluates JavaScript in the page open in the developer tools panel.- Developer Tools (web inspector): the built-in browser panel for inspecting and debugging pages.
about:debugging: a built-in browser page for loading an extension temporarily from a folder.- Proof of concept (PoC): a minimal example that demonstrates a bug works.
- User agent: the short text a browser sends to identify itself and its version.
- Origin / site: the address that identifies a website, such as
addons.mozilla.org. - Injection: running code inside a page from outside that page, for example from an extension.
- Bypass: getting around a protection that is supposed to stop you.
- Severity: a rating of how serious a bug is.
- CVSS: a standard scoring system for the severity of security bugs.
- Regression test: an automated test that checks a fixed bug stays fixed.
- False positive: a test result that looks like a bug but is not one.