Skip to content
Info disclosure Disclosed report Intermediate CVE-2020-12392

'Copy As Curl' in the network panel of the devtools uses '--data' instead of '--data-raw', leading to arbitrary local file access

The 'Copy as curl' feature in the browser's developer tools generated curl commands using '--data' instead of '--data-raw'. If a request body started with '@', curl would treat the rest as a filename, so an attacker could craft a request that, when copied and run, would send a local file to the attacker's server.

Ophir LOJKINE Follow

Originally disclosed on Mozilla

  • Fixed in 2 months
  • Paid in 4 months
  • Disclosed after 2 months
Text
Created attachment 9125643
bug.html

After the discussion about the patch for bug 1607742, I made a few more experiments with the "Copy as curl" functionality, and found another vulnerability : POST data is sent using '--data' instead of '--data-raw'. This means that if the body of an HTTP request starts with the character '@', the rest of the body will be interpreted as a file name to send instead of raw data.

An attacker can use this bug to read local files on the computer of an user of the "Copy as curl"  functionality. The only thing he has to do is making a request such as the following :

    fetch('', {body: '@/etc/passwd', method:'POST'})

When the user will use 'copy as curl' on the generated request, and then execute the curl command, the contents of /etc/passwd will be send to the attacker's server.

Fixing this bug is as simple as using --data-raw instead of --data.

The original report as published on Mozilla's Bugzilla, by Ophir LOJKINE. 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 'Copy as curl' feature used curl's '--data' option, which interprets a leading '@' as a filename, instead of '--data-raw' which treats the input as literal data.

Impact

An attacker could read local files on the computer of a user who uses 'Copy as curl' and then runs the generated command.

What the attacker needed

Victim uses 'Copy as curl'; victim runs the generated curl command; attacker can make the victim's browser send a crafted…

The fix

The bug should be fixed by using '--data-raw' instead of '--data' in the generated curl command.

How it was found

  1. Attacker crafts a request with a body starting with '@' followed by a local file path.
  2. Victim uses 'Copy as curl' on that request in the developer tools.
  3. Victim executes the generated curl command.
  4. The local file's contents are sent to the attacker's server.

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 use 'Copy as curl' in your browser's developer tools, it creates a command that repeats a web request. The bug was that this command used an option that lets curl read a file if the data starts with '@'. So a malicious website could make a request with a body starting with '@' and a file path, and if you copied that request as curl and ran it, your computer would send that file to the attacker.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by Ophir LOJKINE

View all

1 more disclosed report, 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.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.