Skip to content
RCE Disclosed report Intermediate CVE-2021-24002

Arbitrary ftp command execution using ftp URLs

Firefox 87.0 allowed control characters such as %0A and %0D in FTP URLs, so a crafted link could inject extra FTP commands. An attacker could make a victim's browser execute arbitrary FTP commands on a server the attacker could not otherwise access.

Daniel Santos Follow

Originally disclosed on Mozilla

  • Fixed in 8 days
  • Paid in 13 days
  • Disclosed after 8 days
Text
Created attachment 9212965
ftps.py

On Firefox 87.0 (64-bit) FTP URLs (e.g. ftp://xxxx/yyy) allow the control characters %0A and %0D as part of the filename. This allows an attacker to craft a link that when accessed by a victim with the proper permissions will execute arbitrary commands on the FTP server.

The following steps can be used to reproduce the issue:
* To emulate an FTP server, run the attached ftps.py FTP server (you need to install pyftpdlib first)
* On the same directory create a file named test
* Create an HTML page containing link like: <a href="ftp://[YOUR_FTP_SERVER_ADDRESS]/A%0D%0ADELE%20test">Download</a>
* From a machine running Firefox 87.0 with network access to the FTP server access the malicious page and click on the link
* Check the test file is deleted

IMPACT
An attacker may force a victim to execute FTP commands on a server on which the attacker has no previous access. Moreover,  allowing control characters in FTP URLs may permit NAT slipstreaming attacks depending on the victim's router's configuration and FTP ALG implementation.

The original report as published on Mozilla's Bugzilla, by Daniel Santos. 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 FTP URL handler failed to reject or strip encoded carriage-return and line-feed characters before passing the path to the FTP command channel.

Impact

An attacker may force a victim to execute FTP commands on a server the attacker has no previous access to, and depending on the router configuration and FTP ALG implementation, allowing control characters may also permit NAT slipstreaming attacks.

What the attacker needed

Victim uses Firefox 87.0; victim clicks a crafted link; victim has network access to the FTP server; victim has FTP permissions on the server

How it was found

  1. Run the provided Python FTP server and create a file named test in the same directory.
  2. Create an HTML page with a link whose FTP URL contains encoded carriage-return and line-feed characters followed by an FTP DELE command.
  3. From Firefox 87.0 with network access to the FTP server, open the malicious page and click the link.
  4. Check that the test file has been deleted.

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.

FTP is an old protocol for transferring files, and its commands are separated by special line-break characters. Firefox did not block those line-break characters when they appeared encoded in a link, so an attacker could sneak extra commands into what looked like a normal download link. When the victim clicked it, their browser sent those extra commands to the FTP server.

What is RCE?

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

More by Daniel Santos

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.

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.