Skip to content
Info disclosure Disclosed report Beginner

Internal Hostname disclosure from multiple Apache servers via blank host header method

Apache servers returned their internal hostname in the default error page when sent a request with an empty Host header over HTTP/1.0. An attacker could learn internal hostnames or IP addresses that might aid further attacks against internal infrastructure.

jackb898 Follow

Originally disclosed on HackerOne

Bounty$150 Low View original
  • Triaged in 23 hours
  • Fixed in 7 months
  • Paid in 21 hours
  • Disclosed after 11 months

Summary by the program

This vulnerability was due to a general misconfiguration of Apache servers; this is a good example of the importance of "Secure Defaults" in open-source projects. An example of a generic request and response would be:

openssl s_client -connect apache.example.com:443 GET apache.example.com/foo HTTP/1.0 Host: Connection: keep-alive User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3 Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9

HTTP/1.1 400 Bad Request Date: Thu, 3 Feb 2020 13:14:15 GMT Server: Apache Content-Length: 335 Content-Type: text/html; charset=iso-8859-1 Strict-Transport-Security: max-age=15768000; preload; X-Content-Type-Options: nosniff Connection: keep-alive

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>400 Bad Request</title> </head><body> <h1>Bad Request</h1> <p>Your browser sent a request that this server could not understand.<br /> </p> <hr> <address>Apache Server at aws-ec2.example.internal Port 443</address> </body></html> closed

As reported by the researcher:

Summary: I found 3 subdomains vulnerable to a method that essentially "tricks" websites into leaking their own internal hostname.

Vulnerability Description This is the "very detailed" explanation, if you just want to test/reproduce it, just scroll past this to "Steps to Reproduce"

Now I'll explain the issue that leaks these internal hostnames. Essentially, it has to do with website behavior towards empty host headers. So the original method comprises of setting up a GET request to the website, just the main directory. Next, you test it for typical host header injection by changing the Host header to anything like foo.com. Send this request, and if the response contains foo.com anywhere, it may be vulnerable to blank host header info. leakage. However when I was testing your site, I noticed it simply gave a 302 and tried to redirect back to the correct host. I found a way to bypass this though; setting up the request to a nonexistent directory, and including the CR character, like this: /foo%0A, makes it give a 404 and return the host header at the bottom of the page.

Now that we have host header injection, here's where you use that to leak the internal information. Firstly, change the protocol from HTTP/1.1 to HTTP/1.0 (this is to allow blank host headers). Next, remove the host header and send the request. Look in the same spot that the host header was displayed previously, and the internal hostname/ip will be displayed there.

Suggested Remediation To prevent this, you need to prevent host header injection, or at least prevent the host header from being returned anywhere in the response.

The best way to do this is using something like Cloudfront protection, which prevents host header injection.

Impact It is a bad idea to leak internal hostnames, as they can be used by attackers to exploit the network or server. They can chain issues to launch specific attacks against the internal infrastructure; in other words, leaking internal IPs or hostnames leads to normally non-issues becoming vulnerabilities.

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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

Ping Identity ran a bug bounty program on HackerOne, and this report, filed by jackb898, describes an information disclosure issue affecting three subdomains. The weakness class recorded for the report is Information Disclosure, the severity was low, and a bounty of 150.00 USD was paid. The report was disclosed on 12 March 2020.

The affected servers were Apache HTTP Server instances. The feature involved is not an application feature at all: it is Apache's default error page behaviour. When Apache generates an error response such as a 400 Bad Request or a 404 Not Found, the default error document includes a signature line in an <address> element that names the server. Normally that line contains the hostname the client asked for. The bug is that under certain conditions it contains the server's own internal hostname instead.

Setup

The only tool shown in the report is openssl s_client, used to open a raw TLS connection to the server so that a handcrafted HTTP request could be sent without a browser or library filling in or normalising headers.

Finding it

The researcher's starting point was ordinary Host header injection testing. The idea is to send a request whose Host header contains an arbitrary value such as foo.com, and then check whether that value is reflected anywhere in the response. If it is, the server may also be willing to reflect an empty or absent host, which is the condition that leads to internal hostname disclosure.

On the target, the simple version did not work: a request with a modified Host header produced a 302 redirect back to the correct host. That defence stopped the naive test but, as the researcher found, not the underlying behaviour.

Exploitation

Step 1: Bypass the redirect with a nonexistent path and a CR character

The researcher changed the request path to a directory that does not exist and appended an encoded carriage return, %0A, to it:

Text
/foo%0A

With this path the server no longer issued the 302 redirect. Instead it returned a 404, and the response body contained the host header value at the bottom of the page, in the <address> line of Apache's default error document. That confirmed host header injection: the server was echoing the client-supplied host into the error page.

Step 2: Downgrade to HTTP/1.0 so the Host header can be blank

The next step is to change the protocol version from HTTP/1.1 to HTTP/1.0. The researcher changed the protocol to HTTP/1.0, which allows blank host headers. HTTP/1.0 does not require it, which allows a request with a blank or absent Host header to be processed.

Step 3: Send the request with no Host header and read the internal hostname

The researcher removed the Host header entirely and sent the request. Looking in the same place where the injected host had appeared in step 1, the internal hostname or IP address was displayed instead.

The program's summary gives a generic example of the full exchange. The connection is opened with:

Bash
openssl s_client -connect apache.example.com:443

and the request sent over it is:

HTTP
GET apache.example.com/foo HTTP/1.0
Host:
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

The request line uses HTTP/1.0 and the Host header is present but empty. The response is:

HTTP
HTTP/1.1 400 Bad Request
Date: Thu, 3 Feb 2020 13:14:15 GMT
Server: Apache
Content-Length: 335
Content-Type: text/html; charset=iso-8859-1
Strict-Transport-Security: max-age=15768000; preload;
X-Content-Type-Options: nosniff
Connection: keep-alive

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache Server at aws-ec2.[redacted] Port 443</address>
</body></html>
closed

The important part is the last line of the body: <address>Apache Server at aws-ec2.[redacted] Port 443</address>. With no usable host supplied by the client, Apache filled the signature with the machine's own internal name, aws-ec2.[redacted], and the port. That is the disclosure: the public response reveals an internal hostname that the client never sent.

Root cause

The program describes the issue as a general misconfiguration of Apache servers and frames it as an example of why secure defaults matter in open-source projects.

The redirect that stopped the naive test was not a real fix. It only handled the case of a request to the main directory with a modified host; a request to a nonexistent path with an encoded CR character produced a 404 whose body still contained the injected host, and once the host was removed entirely under HTTP/1.0, the same location in the page carried the internal name.

Impact

Leaking internal hostnames is, in the researcher's words, a bad idea because attackers can use them to exploit the network or server. The disclosed names and IPs can be chained with other issues to launch specific attacks against internal infrastructure, so that information which would normally be harmless becomes a vulnerability when combined with something else. The report does not name any specific follow-on attack, and the impact is stated in these general terms. The program rated the issue low severity.

Fix

The researcher's suggested remediation is to prevent host header injection, or at minimum to prevent the host header from being returned anywhere in the response. The specific recommendation is to use something like Cloudfront protection, which the researcher says prevents host header injection. The report does not state what the program actually changed.

Variants to test

  1. Send a request with an arbitrary Host value to the main directory and check whether the value appears in the response body. A positive result is the injected value reflected in the page, which indicates the server may also reflect a blank host.
  2. If the main directory redirects, request a nonexistent path with an encoded CR appended, as in /foo%0A, and inspect the error page. A positive result is a 404 whose body contains the host value you supplied.
  3. Repeat the request over HTTP/1.0 with an empty or absent Host header and inspect the same location in the error page. A positive result is an internal hostname or IP address in the <address> line.

Hunting notes

The signal during recon is an error response whose body ends with an <address>Apache Server at ...</address> line: that line is the reflection point. A redirect back to the correct host on a normal request is not proof of safety, because a nonexistent path with an encoded CR character can reach a different code path that still reflects the host. The researcher showed the internal hostname in the response body of a request that never supplied it, and noted that three subdomains were affected.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

Ping Identity runs a bug bounty program on HackerOne. A bug bounty program is a public offer from a company: if you find a security problem in their systems and report it responsibly, they may pay you a reward (the bounty) and, after a while, publish your report so others can learn from it. The researcher in this report is jackb898. The report describes an information disclosure issue: a way of making a web server reveal a piece of information it was not supposed to reveal. The information in question is the server's own internal hostname, the name a machine uses to identify itself on the company's private network. Three subdomains were affected. The report was rated low severity, a bounty of 150.00 USD was paid, and the report was disclosed on 12 March 2020.

The servers involved were Apache HTTP Server instances. Apache is one of the most widely used web server programs in the world: it is the software that receives requests from browsers and sends back web pages. The feature involved is not something a developer wrote on purpose for visitors. It is Apache's default error page behaviour. When something goes wrong with a request, Apache sends back an error page, for example a 400 Bad Request (the server could not understand the request) or a 404 Not Found (the page does not exist). Apache's built-in error page ends with a small signature line inside an HTML element called <address>, which names the server. Normally that line contains the hostname the visitor asked for. The bug is that under certain conditions it contains the server's own internal hostname instead, a name the visitor never sent and was never meant to see.

A useful everyday comparison: think of a receptionist who, when asked for a department that does not exist, reads out the building's private internal extension list instead of saying "sorry, no such department". Nothing was hacked; the building simply answered a question it should have declined to answer.

Setup

The only tool shown in the report is openssl s_client. openssl is a command-line program that comes with most Linux and macOS systems; s_client is one of its modes, which opens a raw encrypted connection to a server. "Raw" here means the researcher types the request by hand instead of letting a browser or a programming library build it. That matters because browsers quietly fill in or tidy up parts of a request, and this bug depends on sending a request that is deliberately malformed in a precise way.

HTTPS is the encrypted version of the web protocol; port 443 is the standard door number for HTTPS traffic.

Finding it

The researcher started with ordinary Host header injection testing. Two terms need unpacking. A header is a small line of text sent alongside every web request or response, carrying metadata: who is asking, what formats they accept, and so on. The Host header is the one that says which website name the visitor is trying to reach, for example www.example.com; one server can host many sites, so the server uses this header to pick the right one. Host header injection means putting an unexpected value into that header and seeing whether the server blindly copies it back into the page. If the server echoes whatever you put there, it may also be willing to echo an empty or missing host, and that is the condition that leads to the internal hostname being revealed.

On the target, the simple version did not work. A request with a modified Host header produced a 302 redirect back to the correct host. A 302 is the HTTP status code for "the thing you asked for has moved, go here instead"; the server was politely bouncing the visitor back to the legitimate site name. That defence stopped the naive test, but as the researcher found, it did not stop the underlying behaviour.

Exploitation

Step 1: Bypass the redirect with a nonexistent path and a CR character

The researcher changed the request path to a directory that does not exist and appended an encoded carriage return, %0A, to it:

Text
/foo%0A

Line by line: /foo is a path on the website, in this case one that does not exist. %0A is how a line feed character is written inside a URL, because a real line break cannot appear in a web address. The server sees a path it cannot match to anything, so instead of redirecting it produces an error page.

Why take this step? Because the normal request was being redirected away before the interesting code ran. By asking for something that does not exist and slipping in an encoded line break, the researcher reached a different part of the server's behaviour: the error handling. With this path the server no longer issued the 302 redirect. Instead it returned a 404, and the response body contained the host header value at the bottom of the page, in the <address> line of Apache's default error document. That confirmed host header injection: the server was echoing the client-supplied host into the error page.

Step 2: Downgrade to HTTP/1.0 so the Host header can be blank

HTTP is the language browsers and servers speak. It has versions. HTTP/1.0, the older version, does not require a Host header, which allows a request with a blank or absent Host header to be processed. HTTP/1.0, the older version, does not require it, which allows a request with a blank or absent Host header to be processed. Downgrading the version is therefore the trick that lets the researcher send a request with no usable host at all.

Step 3: Send the request with no Host header and read the internal hostname

The researcher removed the Host header entirely and sent the request. Looking in the same place where the injected host had appeared in step 1, the internal hostname or IP address was displayed instead. An IP address is the numeric address of a machine on a network, the equivalent of a street address; a hostname is the human-readable name that maps to it.

The program's summary gives a generic example of the full exchange. The connection is opened with:

Bash
openssl s_client -connect apache.example.com:443

Line by line: openssl is the tool; s_client tells it to act as a raw client; -connect apache.example.com:443 says which server and port to connect to. After this command the researcher has an open encrypted channel and can type an HTTP request into it by hand.

The request sent over it is:

HTTP
GET apache.example.com/foo HTTP/1.0
Host:
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

Line by line: the first line is the request line. GET is the method, meaning "give me this"; apache.example.com/foo is what is being asked for; HTTP/1.0 is the deliberately old protocol version from step 2. The second line, Host:, is the key part: the header is present but empty, which is only tolerated under HTTP/1.0. Connection: keep-alive asks the server to keep the connection open after answering. User-Agent describes the browser, here a Chrome version, and is there to make the request look normal. Accept, Accept-Encoding and Accept-Language say which content types, compression formats and languages the client prefers.

The response is:

HTTP
HTTP/1.1 400 Bad Request
Date: Thu, 3 Feb 2020 13:14:15 GMT
Server: Apache
Content-Length: 335
Content-Type: text/html; charset=iso-8859-1
Strict-Transport-Security: max-age=15768000; preload;
X-Content-Type-Options: nosniff
Connection: keep-alive

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache Server at aws-ec2.[redacted] Port 443</address>
</body></html>
closed

Line by line: HTTP/1.1 400 Bad Request is the status line; 400 means the server could not make sense of the request, which is expected because the request was deliberately malformed. Date is when the response was generated. Server: Apache names the server software. Content-Length is the size of the body in bytes. Content-Type says the body is HTML in a particular character set. Strict-Transport-Security tells browsers to keep using HTTPS for this site in future. X-Content-Type-Options: nosniff stops browsers from guessing a different content type than the one declared. Connection: keep-alive keeps the connection open. After the blank line comes the body: a standard Apache error page with a heading, a short explanation, a horizontal rule, and then the signature line.

The important part is the last line of the body: <address>Apache Server at aws-ec2.[redacted] Port 443</address>. With no usable host supplied by the client, Apache filled the signature with the machine's own internal name, aws-ec2.[redacted], and the port. That is the disclosure: the public response reveals an internal hostname that the client never sent.

Root cause

The program describes the issue as a general misconfiguration of Apache servers and frames it as an example of why secure defaults matter in open-source projects. A secure default is a setting that is safe out of the box, so that someone who installs the software and changes nothing is not exposed.

The redirect that stopped the naive test was not a real fix. It only handled the case of a request to the main directory with a modified host; a request to a nonexistent path with an encoded CR character produced a 404 whose body still contained the injected host, and once the host was removed entirely under HTTP/1.0, the same location in the page carried the internal name.

Impact

Leaking internal hostnames is, in the researcher's words, a bad idea because attackers can use them to exploit the network or server. The disclosed names and IPs can be chained with other issues to launch specific attacks against internal infrastructure, so that information which would normally be harmless becomes a vulnerability when combined with something else. The report does not name any specific follow-on attack, and the impact is stated in these general terms. The program rated the issue low severity.

Fix

The researcher's suggested remediation is to prevent host header injection, or at minimum to prevent the host header from being returned anywhere in the response. The specific recommendation is to use something like Cloudfront protection, which the researcher says prevents host header injection. The report does not state what the program actually changed.

Variants to test

  1. Send a request with an arbitrary Host value to the main directory and check whether the value appears in the response body. A positive result is the injected value reflected in the page, which indicates the server may also reflect a blank host.
  2. If the main directory redirects, request a nonexistent path with an encoded CR appended, as in /foo%0A, and inspect the error page. A positive result is a 404 whose body contains the host value you supplied.
  3. Repeat the request over HTTP/1.0 with an empty or absent Host header and inspect the same location in the error page. A positive result is an internal hostname or IP address in the <address> line.

Hunting notes

The signal during recon is an error response whose body ends with an <address>Apache Server at ...</address> line: that line is the reflection point. A redirect back to the correct host on a normal request is not proof of safety, because a nonexistent path with an encoded CR character can reach a different code path that still reflects the host. The researcher showed the internal hostname in the response body of a request that never supplied it, and noted that three subdomains were affected.

Glossary

  • Bug bounty program: a public offer by a company to pay researchers who report security problems responsibly.
  • Bounty: the reward paid for an accepted report.
  • Information disclosure: a weakness where a system reveals information it should keep private.
  • Severity: how serious a problem is judged to be, here low.
  • Subdomain: a named part of a larger domain, such as shop.example.com under example.com.
  • Apache HTTP Server: a widely used web server program that receives requests and sends back pages.
  • Hostname: the human-readable name of a machine on a network.
  • Internal hostname: a machine name used only inside a private network, not meant for outsiders.
  • IP address: the numeric address of a machine on a network.
  • HTTP: the language browsers and servers use to exchange requests and responses.
  • HTTPS: HTTP carried over an encrypted connection.
  • Port: a numbered channel on a machine; 443 is the standard one for HTTPS.
  • Header: a line of metadata sent with a request or response.
  • Host header: the header that names which website the visitor is trying to reach.
  • Host header injection: putting an unexpected value into the Host header to see whether the server copies it back.
  • Reflection: when a server copies something the client sent back into its response.
  • Status code: a three-digit number in a response saying what happened, such as 400, 404 or 302.
  • 400 Bad Request: the server could not understand the request.
  • 404 Not Found: the requested page does not exist.
  • 302 redirect: the server tells the client to go to a different address instead.
  • CR / LF: control characters that mark a line break; %0A is how one is written inside a URL.
  • URL encoding: writing special characters as % plus a code so they can appear in a web address.
  • HTTP/1.0 and HTTP/1.1: versions of the web protocol; 1.1 requires a Host header, 1.0 does not.
  • openssl s_client: a command-line tool that opens a raw encrypted connection so a request can be typed by hand.
  • User-Agent: a header describing the browser or client software.
  • Secure defaults: settings that are safe out of the box, without the installer changing anything.
  • Cloudfront: a content delivery and protection service the researcher suggests as a way to block host header injection.
  • Recon: the early phase of testing where a researcher maps out what a target runs and how it responds.

More by jackb898

View all

9 more disclosed reports, best first.

More from Ping Identity

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.