Skip to content
Info disclosure Disclosed report Intermediate

Port and service scanning on localhost due to improper URL validation.

The curl tool treats the asterisk character as a valid hostname that resolves to localhost, bypassing common URL validation filters that block addresses like 127.0.0.1. An attacker who can control a URL passed to curl could use this to access internal web services on the local machine or perform port scanning.

vshmuk Follow

Originally disclosed on HackerOne

Medium 6.3 View original
  • Disclosed after 46 hours

Summary:

Generally web masters and developers protect user-accessible CURL from requesting forbidden domains so that the attacker is not able to access internal resources. It is usually done using regular expressions. Mostly addresses like 127.x.x.x, 192.168.x.x and "integer" notation of IP addresses (like 2130706433 = 127.0.0.1) are filtered out before executing curl using wrapper scripts. But the ' * ' symbol is valid for CURL, allowing to request localhost's internal web resources and to scan ports. Unfortunately, since http0.9 is turned off by default now, it's harder to easily scan ports (without accessing stderr by the attacker). But if FTP protocol is not disabled, port scanning can still be achieved using time-based attack: active refusal of a closed port takes much less time than connecting by FTP to any other open port. As far as i see, ' * ' and 'localhost' are not synonyms, and ' * ' string should be filtered out not on the webmaster's side but from inside of CURL.

Steps To Reproduce:

$ ./src/curl -V
curl 7.69.0-DEV (x86_64-pc-linux-gnu) libcurl/7.69.0-DEV OpenSSL/1.1.1d

$ ./src/curl -v "*"
*   Trying ::1:80...
* TCP_NODELAY set
* connect to ::1 port 80 failed: Connection refused
*   Trying 127.0.0.1:80...
* TCP_NODELAY set
* connect to 127.0.0.1 port 80 failed: Connection refused
* Failed to connect to * port 80: Connection refused
* Closing connection 0
curl: (7) Failed to connect to * port 80: Connection refused

$ ./src/curl -v "*:8888"
*   Trying ::1:8888...
* TCP_NODELAY set
* connect to ::1 port 8888 failed: Connection refused
*   Trying 127.0.0.1:8888...
* TCP_NODELAY set
* Connected to * (127.0.0.1) port 8888 (#0)
> GET / HTTP/1.1
> Host: *:8888
> User-Agent: curl/7.69.0-DEV
> Accept: */*
> 
<skip>
Hello world!
* Closing connection 0

$ ./src/curl -v "ftp://*:8888"
*   Trying ::1:8888...
* TCP_NODELAY set
* connect to ::1 port 8888 failed: Connection refused
*   Trying 127.0.0.1:8888...
* TCP_NODELAY set
* Connected to * (127.0.0.1) port 8888 (#0)
^C

./src/curl -v "ftp://*:80"
*   Trying ::1:80...
* TCP_NODELAY set
* connect to ::1 port 80 failed: Connection refused
*   Trying 127.0.0.1:80...
* TCP_NODELAY set
* connect to 127.0.0.1 port 80 failed: Connection refused
* Failed to connect to * port 80: Connection refused
* Closing connection 0
curl: (7) Failed to connect to * port 80: Connection refused

Supporting Material/References:

According to https://tools.ietf.org/html/rfc1034, wildcards are special symbols in DNS and should not be used as domain names..

Impact

The vulnerability allows attacker to at least access internal web resources restricted to localhost, or at most to scan locally opened ports and expose services running on the machine.

The original report as published on HackerOne, by vshmuk. 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 resolves the wildcard character '*' to the loopback address, so URL validation that only blocks explicit localhost addresses does not catch it.

Impact

An attacker could access internal web resources restricted to localhost and, if FTP is enabled, scan locally open ports to expose running services.

What the attacker needed

Attacker controls a URL passed to curl; FTP protocol enabled for port scanning

The fix

The text argues that curl itself should reject the asterisk as a hostname rather than relying on application-level filters.

How it was found

  1. Run curl with the asterisk as the host to see it connect to the local machine on port 80.
  2. Run curl with the asterisk and a port number to reach a local web service and receive its response.
  3. Use the FTP scheme with the asterisk and a port to observe connection timing differences for open and closed ports.

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 a website lets users supply a web address for the server to fetch, developers often block addresses that point back to the server itself, such as 127.0.0.1. This report shows that the curl program also accepts a single asterisk as a name for the local machine, so a filter that only blocks the usual addresses can be bypassed. That lets an attacker reach services that are only meant to be used from inside the server.

What is Info disclosure?

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

More from curl

View all

The newest disclosed reports for this program.

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.