Skip to content
SSRF Disclosed report Intermediate CVE-2020-8284

CVE-2020-8284: trusting FTP PASV responses

curl's default behaviour of trusting the IP address in an FTP PASV response allows an attacker-controlled FTP server to make curl connect to arbitrary internal hosts and ports. This enables port scanning and service version disclosure from the server running curl, especially when curl is used in SSRF-prone web applications.

vepe Follow

Originally disclosed on HackerOne

  • Triaged in 4 days
  • Fixed in 18 days
  • Paid in 5 days
  • Disclosed after 3 months

Summary:

The issue here arises from the fact that curl by default has the option CURLOPT_FTP_SKIP_PASV_IP disabled by default. As a result, an attacker controlling the URL used by curl, can perform port scanning on behalf of the server where curl is running. This can be achieved by setting up a custom FTP server that would setup the data channel through the PASV command using the port scanning target IP and port in the PASV connection info. One good target for this issue are web applications vulnerable to SSRF.

Steps To Reproduce:

So we can differentiate between open, closed and filtered ports with the following:

  1. Open ports

curl will reply with TYPE after the PASV command example: Received: USER anonymous in 5 Received: PASS [email protected] in 5 Received: PWD in 5ms Received: EPSV in 6ms Received: PASV in 6ms Received: TYPE I in 6ms Received: SIZE whatever in 5ms Received: RETR whatever in 5ms

  1. Filtered

curl will timeout after the PASV command example: Received: USER anonymous in 6 Received: PASS [email protected] in 5 Received: PWD in 5ms Received: EPSV in 6ms Received: PASV in 5ms Received: in 1011ms

  1. Closed

curl will close the control channel connection immediately after PASV example: Received: USER anonymous in 6ms Received: PASS [email protected] in 6ms Received: PWD in 5ms Received: EPSV in 5ms Received: PASV in 5ms Received: in 5ms

In the attachments, I have included an ftp server (F1088885) that automates these steps. Usage: ./ssrf_pasvaggresvftp.sh -t 127.0.0.1/31 -p 80,8000-8100 -x ./ftp_curl.sh -vv

the file included in the -x option is supposed to trigger the ssrf on the target server that would lead to the call of curl with the attacker's URL. In this case we simulate the issue by calling curl locally. The attachment F1088859 is the script used in the example.

Impact

Through the port scanning, an attacker could uncover services running in the internal network. It could also be possible to perform version enumeration or other information disclosure if the attacker can get back the results of curl. For example, an attacker points curl at host:22 for the data channel . If an ssh server is running on that host, then it will reply with its version which is then disclosed to the attacker.

Ultimately, this issue can be used as a stepping stone to launch further attacks on the vulnerable server.

Attachments

ftp_scanner.gif
ftp_scanner.gif From the original on HackerOne

The original report as published on HackerOne, by vepe. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 curl did not validate that the IP address in the PASV response matched the control connection's peer, and the option to skip the PASV IP was disabled by default.

Impact

An attacker could uncover services running on the internal network and potentially perform version enumeration, serving as a stepping stone for further attacks.

What the attacker needed

Attacker controls FTP server; curl used in SSRF context

How it was found

  1. Set up a malicious FTP server that responds to PASV with the target IP and port.
  2. Make curl connect to this FTP server (e.g., via an SSRF in a web app).
  3. Observe curl's behaviour after PASV: TYPE command for open ports, timeout for filtered, immediate close for closed.

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 curl downloads a file from an FTP server, the server tells curl where to connect for the data. By default, curl trusts that address. A malicious FTP server can give an internal address instead, tricking curl into probing the internal network.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.