Skip to content
SSRF Disclosed report Intermediate CVE-2022-27780

CVE-2022-27780: percent-encoded path separator in URL host

curl URL-decoded the entire proxy string, so a proxy host containing a percent-encoded slash could pass an allow-list check that only looked at the host suffix. An attacker could then make curl send requests to an unintended internal host through the proxy, leading to blind or full SSRF depending on the proxy.

haxatron1 Follow

Originally disclosed on HackerOne

  • Triaged in 13 hours
  • Fixed in 13 days
  • Disclosed after 13 days

Summary:

URL decoding the entire proxy string could lead to SSRF filter bypasses. For example,

When the following curl specifies the proxy string http://example.com%2F127.0.0.1

  • If curl URL parser or another RFC3986 compliant parser parses the initial string http://127.0.0.1%2F.example.com, it will derive 127.0.0.1%2Fexample.com or 127.0.0.1/example.com as the host, if for instance, an SSRF check is used to determine if a host ends with .example.com (.example.com being a allow-listed domain), the check will succeed.
  • curl will then URL decode the entire proxy string to http://127.0.0.1/example.com and send it to the server
GET http://127.0.0.1/example.com HTTP/1.1
Host: 127.0.0.1/example.com
User-Agent: curl/7.83.0
Accept: */*
Proxy-Connection: Keep-Alive
  • This proxy string is valid, and proxy servers, even RFC3986-compliant ones will send the request to the host 127.0.0.1

Steps To Reproduce:

I switched things up and used 127.0.0.1 as the allow-listed server and example.com as the target server to make it easier (no need to setup a HTTP server) to reproduce.

  1. I used https://github.com/abhinavsingh/proxy.py as my proxy server.
  2. Perform the following:
curl -x http://127.0.0.1:8899 http://example.com%2F127.0.0.1
  1. You will receive a malformed response
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <head>
                <title>400 - Bad Request</title>
        </head>
        <body>
                <h1>400 - Bad Request</h1>
        </body>
</html>

However, this response is actually being returned by example.com, the reason is that proxy.py will forward the Host header, currently 127.0.0.1/example.com curl sends it, making it a Blind SSRF

  1. If
  • an attacker can control the host header either via curl itself
  • the proxy does not forward the host header curl sends,
  • or if servers which ignore the Host header entirely such as Express is used,

it is possible to read the full response

curl -x http://127.0.0.1:8899 -H "Host: example.com" http://example.com%2F127.0.0.1/%2e%2e/

Recommended Fix:

The recommended fix for this is to not URL decode the host component of the proxy string when passing to proxy server.

Impact

SSRF filter bypass at if the curl URL parser or a RFC 3986 parser is used, it could lead to blind / full SSRF depending on the proxy used.

The original report as published on HackerOne, by haxatron1. 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

curl URL-decoded the whole proxy string, including the host, after any allow-list check had already parsed the encoded host.

Impact

An SSRF filter that relies on a URL parser could be bypassed, giving blind SSRF through a proxy that forwards the Host header, or full SSRF if the Host header is controlled or ignored.

What the attacker needed

Curl used with a proxy; SSRF check uses a URL parser; proxy forwards or ignores Host header

The fix

curl should not URL-decode the host part of the proxy string before passing it to the proxy server.

How it was found

  1. Run a proxy server such as proxy.py on a local port.
  2. Use curl with that proxy and a target URL whose host contains a percent-encoded slash.
  3. Observe that the proxy forwards the request to the decoded host, producing a response from that host.
  4. If the Host header can be controlled or ignored, read the full response from the unintended host.

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.

A proxy is a middle server that forwards your requests. curl, a command-line tool for fetching URLs, decoded a special character in the proxy address before using it, so a security check that looked only at the end of the hostname could be fooled. That let an attacker reach a different server than the one the check allowed.

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 by haxatron1

View all

30 more disclosed reports, best first.

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.