Skip to content
RCE Advisory Advanced CVE-2026-10928

Script injection in Headless (CVE-2026-10928)

A URL supplied on the command line is concatenated into a single-quoted JavaScript string without escaping single quotes, allowing an attacker to inject arbitrary JavaScript. This script runs in the chrome://headless WebUI with browser-level DevTools Protocol access, potentially enabling arbitrary file read/write and remote code execution.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 58 days

Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports without the security team.

Overview: When Chrome is run in headless mode with certain flags (e.g., --dump-dom), the provided URL is concatenated into a JavaScript expression using single quotes. Because base::WriteJson does not escape single quotes and GURL preserves them in URL fragments, an attacker can inject arbitrary JavaScript. This script executes in the chrome://headless WebUI with browser-level DevTools Protocol (CDP) privileges, potentially allowing arbitrary file read/write and RCE.

Affected files:

  • components/headless/command_handler/headless_command_handler.cc

Estimated timestamp from git blame: 2025-09-10

Summary

A potential vulnerability exists in HeadlessCommandHandler where an attacker-supplied URL is unsafely concatenated into a JavaScript string literal evaluated in the chrome://headless/ WebUI context. Because this context is granted browser-level DevTools Protocol (CDP) access via Target.exposeDevToolsProtocol, an attacker can leverage this injection to achieve full browser compromise, including arbitrary local file read and write.

Technical Details

When Chrome is invoked in headless mode with a command-processing flag (such as --dump-dom), it routes the request to headless::ProcessHeadlessCommands (chrome/browser/headless/headless_command_processor.cc). This creates a new WebContents navigated to chrome://headless/ and instantiates a HeadlessCommandHandler.

The vulnerability occurs during the execution of the headless commands. In components/headless/command_handler/headless_command_handler.cc, the OnDevToolsProtocolExposed method builds a JavaScript expression to be executed via Runtime.evaluate:

C++
std::string json_commands = base::WriteJson(commands).value_or("");
std::string script = "executeCommands(JSON.parse('" + json_commands + "'))";

The commands dictionary contains targetUrl, which is the attacker-supplied URL from the command line. The injection is possible due to the interaction of three factors:

  1. GURL Canonicalization: When parsing the command-line URL, GURL strictly follows RFCs and does not percent-encode single quotes (') within the URL fragment (url/url_canon_etc.cc:262).
  2. JSON Serialization: base::WriteJson follows the JSON standard and escapes double quotes ("), but it explicitly does not escape single quotes (') (base/json/string_escape.cc:83).
  3. Unsafe Concatenation: The resulting JSON string is blindly concatenated into a single-quoted JavaScript string literal.

An attacker providing a URL like https://example.com/#'+PAYLOAD+' causes the generated expression to break out of the string literal: executeCommands(JSON.parse('{"targetUrl":"https://example.com/#'+PAYLOAD+'"}'))

The PAYLOAD is then executed as raw JavaScript in the chrome://headless/ renderer. Crucially, because the expression is executed via the CDP command Runtime.evaluate, it bypasses the WebUI Content Security Policy (CSP) that would normally block inline scripts.

Impact and Escalation

Prior to evaluating the script, HeadlessCommandHandler calls Target.exposeDevToolsProtocol. Because the handler's DevTools client is trusted, this successfully injects a window.cdp.send function into the chrome://headless/ page, backed by a BrowserDevToolsAgentHost.

While this initial host is created in "discovery-only" mode (which restricts domains like Browser), the injected session has AccessMode::kBrowser privileges. The attacker's JavaScript payload can simply call Target.attachToBrowserTarget via window.cdp.send to obtain a session ID for a brand-new, unrestricted browser-level DevTools connection.

With this full connection, the attacker can:

  • Read arbitrary local files by sending Target.createTarget with a file:/// URL and evaluating scripts within it.
  • Write arbitrary files to the filesystem by sending Browser.setDownloadBehavior to override the download path, followed by Page.download.

Potential Reproduction Steps

(Note: These are suggested steps based on code analysis; we do not currently have a working proof of concept.)

  1. Run headless Chrome with a specially crafted URL designed to break out of the single-quoted string and invoke a CDP command. For example, to read /etc/passwd:
    Bash
    chrome --headless --dump-dom "https://example.com/x#'+window.cdp.send(JSON.stringify({id:1,method:'Target.createTarget',params:{url:'file:///etc/passwd'}}))+'"
    
  2. To achieve file write/RCE, the payload would first call Target.attachToBrowserTarget, extract the sessionId, and then send flattened protocol commands (e.g., Browser.setDownloadBehavior and Page.download) using that session ID.

Suggested Fix

Do not use string concatenation to build the JavaScript expression. Instead, pass the configuration via standard DevTools Protocol arguments or properly escape the json_commands string specifically for inclusion within a single-quoted JavaScript literal (e.g., by replacing ' with \' before concatenation).

Evaluated with Chrome root at commit: f200f57a19490707ff8bc7aa5de3cbc443a3afad


Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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

Likely the URL is placed into a single-quoted JavaScript string without escaping single quotes, and the JSON serialisation used does not escape single quotes either.

Impact

An attacker could potentially read and write arbitrary local files and achieve remote code execution, though the report notes that no working proof of concept exists yet.

What the attacker needed

Attacker controls the URL passed to headless Chrome; Chrome run with a command-processing flag like --dump-dom

The fix

The code should be fixed by passing configuration via standard DevTools Protocol arguments or by properly escaping single quotes in the JSON string before concatenation.

How it was found

  1. Run headless Chrome with a crafted URL that breaks out of the single-quoted string and calls a DevTools Protocol command.
  2. To achieve file write or remote code execution, the payload would first call Target.attachToBrowserTarget, extract the session ID, and then send flattened protocol commands using that session ID.

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 Chrome runs in headless mode with certain flags, it takes a URL from the command line and inserts it into a piece of JavaScript code without properly escaping special characters. An attacker who can control that URL can break out of the string and run their own JavaScript inside a privileged Chrome page. That page has powerful debugging access, which could let the attacker read or write files on the computer.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.