'Copy As Curl' in the network panel of the devtools does not escape the HTTP method properly, leading to local code execution
The Firefox DevTools 'Copy As cURL' feature did not escape the HTTP method when generating a curl command. A malicious webpage could set a crafted HTTP method so that when a user copies the request as cURL and pastes it into a terminal, arbitrary commands are executed.
Originally disclosed on Mozilla
- Fixed in 36 days
- Paid in 33 days
- Disclosed after 36 days
Created attachment 9119373
bug.html
Firefox devtools have a 'network' panel, where all the requests made by the current webpage are listed.
In this panel, the user can right-click on a query, and then select 'Copy As cURL'. The user is then expected to paste what he just copied into a terminal.
The issue is that the HTTP method of the request, which is controlled by the potentially malicious webpage, is not escaped when the curl command is formed.
As an example, the following javascript snippet will make a problematic request:
fetch('', {method: '|evilcommand|'});
When this snippet is run, and then a naive user uses 'Copy as cURL' on the generated request and then pastes it into a terminal, evilcommand is executed.
Note: an HTTP verb cannot contain a space (so one can not launch evilcommand with arguments), but the following characters are allowed, making it possible to construct complex malicious payloads: ` ' . * $ & | ~.
What the report shows
The target is the Firefox DevTools Network panel (Netmonitor). That panel lists every request the current page makes, and a user can right-click a request and choose Copy As cURL to get a command they are expected to paste into a terminal.
The researcher found that the HTTP method of the request, which the page controls, is not escaped when the curl command is built. A page can therefore choose a method that turns the copied command into something the terminal runs.
The example given is a single fetch call:
fetch('', {method: '|evilcommand|'});
When that snippet runs, the request appears in the Network panel. A user who right-clicks it, picks Copy As cURL and pastes the result into a terminal ends up executing evilcommand.
The report notes one limit: an HTTP verb cannot contain a space, so the attacker cannot pass arguments to the command directly. It also lists characters that are allowed in a verb and can be used to build more complex payloads:
The report does not describe a fix, a bounty amount or a CVSS score.
Root cause
The likely cause is that the method string is interpolated into the generated shell command without quoting or escaping. The method is attacker-controlled data that crosses a trust boundary: it comes from a web page and ends up in a shell, where characters such as |, &, $ and backticks have meaning. Any component that builds a command line from untrusted input has to treat that input as data, not as syntax.
Impact
The impact depends on the user. A developer who copies a request from a malicious or compromised page and pastes it into a terminal runs the attacker's command with their own privileges. The report rates the issue medium severity and classifies it as privilege escalation. Because a space is not allowed in a verb, the attacker cannot simply append arguments, but the allowed characters still permit compound commands and shell expansion.
How this kind of bug works
This is command injection through a generated shell command. A tool takes structured data (here, an HTTP request) and renders it as text meant for a shell. If any field is placed into that text without escaping, shell metacharacters in the field are interpreted when the text is executed.
The dangerous characters are the ones the shell treats specially: | for pipelines, & for background or chaining, ; for sequencing, $ and backticks for expansion, quotes for grouping, and ~ for home directory expansion. Even when one field has a restricted character set, as with HTTP methods, the remaining characters are often enough.
The defence is to never build shell text by concatenation. Either quote and escape every interpolated value for the target shell, or avoid the shell entirely by passing an argument vector to the process. For a copy-to-clipboard feature, the safest approach is to produce a command where every user-controlled value is single-quoted with internal quotes escaped.
How to test for it
- Identify features that generate commands or scripts from request data: copy as cURL, copy as fetch, export to a script, generate a reproduction command, or a "replay in terminal" button.
- Find which parts of the request you control. The method is a good first candidate, but also consider the URL, path, query string, header names and values, cookies, and the body.
- Set a field to a value containing shell metacharacters, for example a pipe followed by a harmless command, and trigger the copy feature.
- Inspect the generated text. A positive result is a command where your characters appear unquoted and would be interpreted by a shell, not a command where they are wrapped in quotes or escaped.
- Confirm safely. Use a command that only writes a marker, such as creating a file in a temporary directory, and run it in a disposable environment.
Common false positives: the value is quoted correctly but looks alarming; the tool escapes for one shell but you tested another; the field is rejected before it reaches the generator; or the copied text is never meant to be executed, only displayed. Check the actual generated string before claiming impact.
How it is fixed
The standard fix is to escape or quote every interpolated value for the shell the output targets, including the method, URL, headers and body. Where possible, generate an argument list instead of a shell string. Some tools also validate the method against the set of standard verbs, or refuse to generate a command for unusual ones. Regression tests should cover metacharacters in each field.
Hunting notes
This class tends to hide in developer tooling: browser DevTools, proxy tools, API clients, CLI tools that print commands, and web dashboards that offer "copy as command". Recon signals include any UI text mentioning cURL, terminal, shell, replay or export, and any feature that turns a captured request into text.
To get a report accepted, show the exact generated command, show that the injected characters are unquoted, and demonstrate execution with a harmless marker in a controlled environment. Explain the user interaction required, since the victim must copy and paste the command. Keep the payload minimal and avoid anything that could damage a real machine.
What happened, in plain words
Firefox has a set of built-in tools for developers, called DevTools. One of them is the Network panel, which lists every request the page you are looking at sends out. A request is simply a message the browser sends to a server to ask for something or to send something, a bit like posting a letter and waiting for the reply. The Network panel shows these messages so a developer can see what the page is doing behind the scenes.
Inside that panel you can right-click a request and choose Copy As cURL. cURL is a small command-line program that sends requests, so this option gives you a ready-made command that repeats the request you just saw. The idea is that you paste it into a terminal (the text window where you type commands on your computer) and run it, for example to test the same request again.
The researcher found a problem in how that command is built. Every request has an HTTP method, which is a short label saying what kind of action the request is. The two best-known ones are GET (please give me something) and POST (here is some data). The method is chosen by the web page, and a malicious page can put almost any text in it. When Firefox turns the request into a cURL command, it copies the method into the command without protecting it. So a page can pick a method that, once pasted into a terminal, is no longer just a label but part of a command the terminal will run.
The example in the report is a single line of JavaScript, the language web pages use:
fetch('', {method: '|evilcommand|'});
Line by line: fetch is the browser function that sends a request. The first part, '', is the address, left empty here so the request goes to the current page. The second part, {method: '|evilcommand|'}, sets the method to the text |evilcommand|. That text is not a normal method at all; it is a small piece of shell syntax wrapped around a command name.
When this snippet runs, the request shows up in the Network panel. A user who right-clicks it, chooses Copy As cURL and pastes the result into a terminal ends up running evilcommand.
The report notes one limit. An HTTP method cannot contain a space, so the attacker cannot pass arguments to the command directly. It also lists characters that are allowed inside a method and can be used to build more complex payloads:
Each of these has a special meaning to a terminal, which is why they matter. The pipe | sends the output of one command into another. The ampersand & can chain or background commands. The dollar sign $ and the backtick start a substitution, where the terminal runs something and inserts the result. Quotes group text together, and ~ stands for your home folder. Even with spaces banned, these are enough to assemble something harmful.
The text does not describe a fix, a bounty amount or a CVSS score.
In general, how this kind of bug works
This is command injection through a generated command. The pattern is common: a tool takes structured data (here, a request) and writes it out as text meant for a terminal. If any field is dropped into that text without protection, the terminal reads the field's special characters as instructions rather than as plain text. A useful comparison is a form letter where someone's name is filled in: if the name contains a sentence, the letter now contains that sentence too, and the reader may treat it as part of the letter.
The dangerous characters are the ones the terminal treats specially: | for pipelines, & for chaining, ; for sequencing, $ and backticks for substitution, quotes for grouping, and ~ for the home folder. Even when one field has a restricted set of allowed characters, as with HTTP methods, the remaining ones are often enough.
The defence is never to build terminal text by gluing strings together. Either quote and escape every inserted value for the terminal in question, or skip the terminal entirely and pass the program a list of separate arguments. For a copy-to-clipboard feature, the safest approach is to produce a command where every value the user controls is single-quoted, with any internal quotes escaped.
How to test for it
- Look for features that generate commands or scripts from request data: copy as cURL, copy as fetch, export to a script, generate a reproduction command, or a replay button.
- Work out which parts of the request you control. The method is a good first candidate, but also consider the address, path, query string, header names and values, cookies and body. A cookie is a small piece of data a site stores in your browser and sends back with each request, often used to remember who you are.
- Put a value containing terminal special characters into a field, for example a pipe followed by a harmless command, and trigger the copy feature.
- Inspect the generated text. A positive result is a command where your characters appear unquoted and would be interpreted, not one where they are wrapped in quotes or escaped.
- Confirm safely. Use a command that only writes a marker, such as creating a file in a temporary folder, and run it in a disposable environment.
Common false positives: the value is quoted correctly but looks alarming; the tool escapes for one terminal but you tested another; the field is rejected before it reaches the generator; or the copied text is never meant to be run, only displayed. Check the actual generated string before claiming impact.
How it is fixed
The standard fix is to escape or quote every inserted value for the terminal the output targets, including the method, address, headers and body. Where possible, generate a list of arguments instead of a terminal string. Some tools also check the method against the set of standard ones, or refuse to generate a command for unusual ones. Regression tests should cover special characters in each field.
Where to look
This class tends to hide in developer tooling: browser DevTools, proxy tools, API clients, command-line tools that print commands, and web dashboards that offer copy as command. Signals worth watching include any interface text mentioning cURL, terminal, shell, replay or export, and any feature that turns a captured request into text.
To get a report accepted, show the exact generated command, show that the injected characters are unquoted, and demonstrate execution with a harmless marker in a controlled environment. Explain the user interaction required, since the victim must copy and paste the command. Keep the payload minimal and avoid anything that could damage a real machine.
Glossary
- DevTools: the set of developer tools built into a browser, opened with a keyboard shortcut or menu.
- Network panel (Netmonitor): the DevTools tab that lists every request the current page makes.
- Request: a message the browser sends to a server, for example to fetch a page or submit data.
- HTTP method: a short label on a request saying what kind of action it is, such as
GETorPOST. - cURL: a command-line program that sends requests, often used to repeat or test one.
- Terminal (shell): the text window where you type commands for your computer to run.
- Command injection: a bug where untrusted text is placed into a command and the terminal runs it as instructions.
- Escaping / quoting: marking text so that special characters are treated as plain text rather than as instructions.
- Shell metacharacter: a character such as
|,&,$or a backtick that the terminal gives a special meaning. - Payload: the piece of text an attacker supplies to trigger the bug.
- Privilege escalation: gaining the ability to do things with someone else's permissions, here the victim's own.
- Severity: a rating of how serious a bug is, here medium.
- CVSS: a standard scoring system for vulnerability severity; the report gives no score.
- Cookie: a small piece of data a site stores in your browser and sends back with requests.
- False positive: a result that looks like a bug but is not one.