Skip to content
Info disclosure Disclosed report Intermediate CVE-2023-28163

Vulnerability in Firefox 'Save As' Dialog Allows Attackers to Steal Environment Variables

The Firefox 'Save As' dialog fails to filter percent signs in file extensions when environment variables are appended, allowing an attacker to craft a filename that expands to a secret environment variable. An attacker could steal stored secrets such as AWS, Azure, or Firebase keys by tricking a victim into downloading and re-uploading a file.

Shaheen Fazim Follow

Originally disclosed on Mozilla

  • Fixed in 8 days
  • Paid in 8 days
  • Disclosed after 8 days
Text
Created attachment 9318706
poc.html

Normally, when a file is saved using the "Save As" dialog in the Firefox browser, the user is protected from different types of attacks by filtering out dangerous extensions or characters.

However, there is a remaining vulnerability where an attacker can place environment variables at the end of the file extension, which allows % signs to pass through without being filtered. An attacker can exploit this vulnerability to steal a victim's stored environment variable, such as various secret keys ( AWS, AZURE, Firebase, etc.),  or other tokens.

Steps to Reproduce:

This vulnerability works when a user has set the "Save As" dialog as the default download option (Settings → Files and Applications → Downloads → “Always ask you where to save files” is checked). Alternatively, an attacker could lure the victim into using the right-click download method, which always opens the "Save As" dialog for downloading a file.

1. Download and open the poc.html file in Firefox.
2. Download the file using one of the methods mentioned above on the poc.html page.
3. Upload the downloaded file to the poc.html page and observe that the secret is extracted (in this case, the username environment variable is used).

this vulnerability is similar to https://bugzilla.mozilla.org/show_bug.cgi?id=1765049 and https://bugs.chromium.org/p/chromium/issues/detail?id=1247389

The original report as published on Mozilla's Bugzilla, by Shaheen Fazim. 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

Likely the filename sanitisation in the Save As dialog does not account for environment variable syntax (percent signs) when they appear after the file extension, so the expansion happens later.

Impact

An attacker could steal stored environment variables such as cloud provider secret keys or tokens, but the attack requires the victim to have the Save As dialog enabled or use right-click download and then upload the file back.

What the attacker needed

Save As dialog is default or right-click download used; Victim downloads and re-uploads the file

How it was found

  1. Open the provided poc.html file in Firefox.
  2. Download the file using the Save As dialog (either by default setting or right-click).
  3. Upload the downloaded file back to the poc.html page and observe the extracted secret.

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 download a file, Firefox usually cleans up the filename to stop sneaky tricks. But if the filename ends with something like '%USERNAME%', Firefox doesn't remove the percent signs, and Windows replaces that with your actual username. The attacker makes a page that downloads a file with such a name, then asks you to upload it back, and the file's name now contains your secret.

What is Info disclosure?

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

More by Shaheen Fazim

View all

38 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.

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.