From Host Header injection to SQL injection
A development subdomain reflected the X-Forwarded-Host header in a redirect and in a meta refresh tag, allowing an attacker to reach a hidden admin login form. That form was vulnerable to SQL injection, letting the attacker log in as administrator.
Published on medium.com
I believe in automation so any mission i could automate i never do it manually so my whole recon phase is automated with bash script i made it myself to handle about 25 other tool and filter all their result into different text files . one of these tools is a simple bash script i made to iterate through subdomains…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This write-up describes a chain that started with a host header injection on a development subdomain and ended in an admin login form that could be bypassed with a SQL injection payload. The program is referred to only as somedomain.com, and the affected host is dev-test.somedomain.com. In normal operation that subdomain redirects to www.somedomain.com with a 302 response that carries only headers and no body.
The author's point is that a bug the program would not accept on its own, host header injection that needs a man-in-the-middle to reach a victim, exposed a hidden admin login form that was itself vulnerable to SQL injection. The report was closed as not applicable at first and later accepted as an access control issue.

Setup
The researcher works with a self-written bash script that drives about 25 other tools and filters their output into separate text files. One of those scripts iterates through a list of subdomains, sends a curl request to each one with custom headers added, and then searches the response headers and response body for those headers.
No accounts, roles or product versions are described. The only precondition that matters is that the tester can send arbitrary request headers to the target subdomain and observe both the response headers and the response body.
Finding it
While running the header-reflection script against the program, the researcher noticed that on dev-test.somedomain.com the X-Forwarded-Host header was reflected in the response headers, specifically in the Location header. Injecting this header:
X-Forwarded-Host: www.bing.com
made the subdomain redirect to www.bing.com.
Opening the subdomain in a browser with Burp Suite as a proxy confirmed the behaviour. In normal condition the subdomain redirects to www.somedomain.com with a 302 response that has no body, only headers. With the injected header it redirects to www.bing.com instead.
The first idea was cache poisoning, so the researcher used another bash script that sends the request two or three thousand times and then opens the subdomain in the browser to check whether the cache had been poisoned and the redirect to www.bing.com was served to other users. That failed: the server was configured well against cache poisoning. The program would also never accept a bug that needs a man-in-the-middle to inject the header into a victim's browser, so the issue looked like a dead end.
Exploitation
Step 1: notice the body that should not be there
With the header injected, the 302 response contained a body with a form in it. In normal condition the response contains only response headers and no response body. That difference is what made the researcher keep going.
Step 2: stop the redirect and inspect the body
Intercepting the response in Burp Suite, the researcher changed the status code from 302 Found to 200 OK and removed the Location header to stop the redirect. The subdomain still redirected to www.bing.com. Repeating the step and searching the body showed an injected meta tag.

Step 3: remove the meta refresh
Deleting the meta tag in Burp Suite and forwarding the response put the browser in front of a login form. In normal case the researcher was not supposed to reach it, but through the host header injection the form was reachable. It was an admin login form.
Step 4: note the weaknesses that the program would not accept
The form sent the user and password over an insecure protocol (HTTP). The form also had no rate limit on the number of login attempts. Neither was acceptable to the program as a finding on its own, so the researcher moved on to SQL injection.
Step 5: SQL injection in the login form
The payload used was:
user : administrator’ or 1=1 --+pass : any password
With that, the researcher was inside the admin dashboard. The subdomain was a dev test subdomain, so there were no sensitive actions or data inside the dashboard.
Root cause
The X-Forwarded-Host value was reflected into the Location header and into a meta refresh in the body of the 302 response. Because the value was reflected into a meta refresh in the body as well as into the Location header, removing the Location header alone did not stop the redirect; the meta tag had to be removed too. Once the redirect was neutralised, the response revealed a hidden admin login form that was not otherwise reachable.
That form then accepted a classic authentication bypass payload. The existing defences did not stop the chain: cache poisoning was mitigated on the server, but the reflection itself was not. The report does not describe the server-side code, so the exact query construction is not shown.
Impact
Through the host header injection the researcher could reach an admin login form that was not reachable in normal use, and through SQL injection in that form could log in to the admin dashboard. The affected host was a dev test subdomain, so in this case there were no sensitive actions or data inside the dashboard. The program initially rejected the report because it read it as host header injection through a man-in-the-middle; after a detailed video showing that no victim is needed and that this is an access control issue, the report was accepted and resolved in 10 days. There was no bounty because the program is a VDP.
Fix
The report does not say what change was made to resolve the issue. The takeaways point at the general direction: apply defence in depth, do not assume an attacker will not reach hidden forms or hidden pages, and apply filters on the inputs of those pages and forms. In practice that means not trusting client-supplied host headers when building redirects or response bodies, and parameterising the login query.
Variants to test
- Send
X-Forwarded-Hostto every subdomain and compare the response headers and body with the baseline. A positive result is the value appearing inLocation, in a meta refresh, in links or in form actions. - When a redirect is present, change the status code to 200 and drop
Location, then search the body for a second redirect mechanism such as a meta refresh. A positive result is a body that still navigates away. - After neutralising every redirect, look at what the body actually renders. A positive result is a login form, an admin panel or any page that is not reachable through the normal flow.
- On any login form reached this way, try the same authentication bypass payload and observe whether the response differs from a normal failed login. A positive result is a session or a dashboard instead of an error.
- Check whether the login form is served over HTTP and whether repeated attempts are throttled. Both were present here but were not accepted by this program on their own.
Timeline
| Date | Event |
|---|---|
| 14 May | Report |
| 16 May | Not applicable |
| 18 May | Reopened |
| 24 May | Resolved |
What happened, in plain words
A security researcher was testing a company's website, which we will call somedomain.com. One of its subdomains, dev-test.somedomain.com, was a development or test version of the site. In normal use, visiting that subdomain simply redirects you to the main site, www.somedomain.com, with a response that contains only instructions to redirect (headers) and no page content (body).
The researcher found that the subdomain reflected the value of a particular request header, X-Forwarded-Host, into its redirect response. By putting www.bing.com in that header, the subdomain would redirect to Bing instead. On its own, the company did not consider this a serious bug, because an attacker would need to be in the middle of a victim's connection to insert that header. But the researcher kept looking. When the header was injected, the redirect response also contained a hidden page with a login form. By removing the redirect instructions, the researcher could see and use that form, which turned out to be an admin login form. That form was then vulnerable to SQL injection, a way of altering a database query by putting SQL code into a login field. With a simple payload, the researcher logged into the admin dashboard. The subdomain was only a test environment, so there was no sensitive data there. The company first rejected the report, but after a video showing that no victim was needed, they accepted it as an access control issue and fixed it in 10 days. There was no bounty because the program is a VDP (vulnerability disclosure program), which does not pay rewards.

The setup: how the researcher worked
The researcher prefers automation. They wrote a bash script (a program that runs in a command-line interface) that controls about 25 other tools and saves their results into separate text files. One of those scripts goes through a list of subdomains, sends a request to each one using curl (a command-line tool for making web requests), adds custom headers to each request, and then checks whether those headers appear in the response headers or the response body.
A header is extra information sent along with a web request or response. For example, when your browser asks for a page, it sends headers like User-Agent (which browser you use) and Accept (what content types you accept). The server replies with headers like Content-Type (what kind of content it is sending) and Location (where to redirect). The body is the actual content: the HTML of a page, an image, or in this case, a form.
No accounts, roles, or product versions are described. The only precondition is that the tester can send arbitrary request headers to the target subdomain and see both the response headers and the response body.
Finding the host header injection
While running the header-reflection script against the program, the researcher noticed that on dev-test.somedomain.com, the X-Forwarded-Host header was reflected in the response headers, specifically in the Location header. Injecting this header:
X-Forwarded-Host: www.bing.com
made the subdomain redirect to www.bing.com.
Let us break that down. X-Forwarded-Host is a non-standard header that proxies and load balancers sometimes add to tell the web application which hostname the client originally requested. If the application trusts this header and uses it to build redirects, an attacker can supply any hostname. Here, the application took the value www.bing.com and put it into the Location header of its redirect response. The Location header is what tells the browser to go to a different URL. So the browser, following the redirect, went to Bing.
Opening the subdomain in a browser with Burp Suite as a proxy confirmed the behaviour. Burp Suite is a tool that sits between your browser and the server, letting you see and modify requests and responses. In normal condition the subdomain redirects to www.somedomain.com with a 302 response that has no body, only headers. A 302 response is a standard HTTP status code meaning "Found" and is used for temporary redirects. With the injected header it redirects to www.bing.com instead.
The first idea was cache poisoning. Caching is when a server or a content delivery network stores a response so it can serve it faster to other users. Cache poisoning is an attack where you trick the cache into storing a malicious response, so that other users receive it. The researcher used another bash script that sends the request two or three thousand times and then opens the subdomain in the browser to check whether the cache had been poisoned and the redirect to www.bing.com was served to other users. That failed: the server was configured well against cache poisoning. The program would also never accept a bug that needs a man-in-the-middle to inject the header into a victim's browser, so the issue looked like a dead end. A man-in-the-middle is an attacker who can intercept and modify traffic between a user and the server, for example on a public Wi-Fi network.
Exploitation
Step 1: notice the body that should not be there
With the header injected, the 302 response contained a body with a form in it. In normal condition the response contains only response headers and no response body. That difference is what made the researcher keep going. A form is the part of a web page where you type information, like a username and password, and click a button to submit it.
Step 2: stop the redirect and inspect the body
Intercepting the response in Burp Suite, the researcher changed the status code from 302 Found to 200 OK and removed the Location header to stop the redirect. The subdomain still redirected to www.bing.com. Repeating the step and searching the body showed an injected meta tag.

A meta tag is a piece of HTML that goes in the head of a page and can tell the browser to do something, like refresh the page or redirect to another URL after a certain number of seconds. Here, the application had put a meta refresh tag into the body, using the same injected host value. So even after removing the Location header, the browser still followed the meta refresh to Bing. The image shows that injected meta tag in the body.
Step 3: remove the meta refresh
Deleting the meta tag in Burp Suite and forwarding the response put the browser in front of a login form. In normal case the researcher was not supposed to reach it, but through the host header injection the form was reachable. It was an admin login form. Forwarding means sending the modified response on to the browser.
Step 4: note the weaknesses that the program would not accept
The form sent the user and password over an insecure protocol (HTTP). HTTP is the basic protocol for web traffic, and it is not encrypted, so anyone who can intercept the traffic can read the username and password. HTTPS is the secure version, which encrypts the traffic. The form also had no rate limit on the number of login attempts. A rate limit is a restriction on how many times you can try something in a given time, like limiting login attempts to prevent guessing passwords. Neither was acceptable to the program as a finding on its own, so the researcher moved on to SQL injection.
Step 5: SQL injection in the login form
SQL injection is a technique where an attacker inserts SQL code into an input field, and the application mistakenly executes it as part of a database query. SQL is the language used to talk to databases. In a login form, the application typically runs a query like SELECT * FROM users WHERE username = '...' AND password = '...'. If the input is not properly sanitised, an attacker can change the logic of the query. The payload used was:
user : administrator’ or 1=1 --+pass : any password
Let us explain this payload. The username field contains administrator’ or 1=1 --+. The single quote after administrator closes the string in the SQL query. Then or 1=1 is a condition that is always true, so the query returns all rows. The --+ is a comment in SQL (the + is a space in URL encoding), which comments out the rest of the query, including the password check. So the query becomes something like SELECT * FROM users WHERE username = 'administrator' or 1=1 -- ' AND password = '...'. Because 1=1 is always true, the query returns the administrator user, and the login succeeds without a valid password. The password field can be anything.
With that, the researcher was inside the admin dashboard. The subdomain was a dev test subdomain, so there were no sensitive actions or data inside the dashboard.
Root cause
The X-Forwarded-Host value was reflected into the Location header and into a meta refresh in the body of the 302 response. Because the value was reflected into a meta refresh in the body as well as into the Location header, removing the Location header alone did not stop the redirect; the meta tag had to be removed too. Once the redirect was neutralised, the response revealed a hidden admin login form that was not otherwise reachable.
That form then accepted a classic authentication bypass payload. Parameterisation means using placeholders in SQL queries so that user input is treated as data, not as code. Escaping means adding backslashes or other characters to neutralise special characters. The existing defences did not stop the chain: cache poisoning was mitigated on the server, but the reflection itself was not. The report does not describe the server-side code, so the exact query construction is not shown.
Impact
Through the host header injection the researcher could reach an admin login form that was not reachable in normal use, and through SQL injection in that form could log in to the admin dashboard. The affected host was a dev test subdomain, so in this case there were no sensitive actions or data inside the dashboard. The program initially rejected the report because it read it as host header injection through a man-in-the-middle; after a detailed video showing that no victim is needed and that this is an access control issue, the report was accepted and resolved in 10 days. There was no bounty because the program is a VDP. A VDP is a vulnerability disclosure program, where companies invite researchers to report bugs but do not pay rewards.
Fix
The report does not say what change was made to resolve the issue. The takeaways point at the general direction: apply defence in depth, do not assume an attacker will not reach hidden forms or hidden pages, and apply filters on the inputs of those pages and forms. Defence in depth means having multiple layers of security, so that if one fails, others still protect you. In practice that means not trusting client-supplied host headers when building redirects or response bodies, and parameterising the login query.
Variants to test
- Send
X-Forwarded-Hostto every subdomain and compare the response headers and body with the baseline. A positive result is the value appearing inLocation, in a meta refresh, in links or in form actions. Baseline means the normal response without the header. - When a redirect is present, change the status code to 200 and drop
Location, then search the body for a second redirect mechanism such as a meta refresh. A positive result is a body that still navigates away. - After neutralising every redirect, look at what the body actually renders. A positive result is a login form, an admin panel or any page that is not reachable through the normal flow.
- On any login form reached this way, try the same authentication bypass payload and observe whether the response differs from a normal failed login. A positive result is a session or a dashboard instead of an error. A session is a way for the server to remember you are logged in, usually via a cookie.
- Check whether the login form is served over HTTP and whether repeated attempts are throttled. Both were present here but were not accepted by this program on their own.
Timeline
| Date | Event |
|---|---|
| 14 May | Report |
| 16 May | Not applicable |
| 18 May | Reopened |
| 24 May | Resolved |
Glossary
- Header: Extra information sent with a web request or response, like a label on a package.
- Body: The main content of a web response, such as the HTML of a page.
- Subdomain: A prefix to a domain name, like
dev-testindev-test.somedomain.com, often used for different environments or services. - Redirect: A response that tells the browser to go to a different URL.
- 302: An HTTP status code meaning "Found", used for temporary redirects.
- Location header: The header that contains the URL to redirect to.
- X-Forwarded-Host: A non-standard header used by proxies to indicate the original host requested by the client.
- Host header injection: A vulnerability where an application trusts the value of a host-related header and uses it in an unsafe way, such as in redirects or links.
- Cache poisoning: An attack that tricks a cache into storing a malicious response, so other users receive it.
- Man-in-the-middle (MITM): An attacker who intercepts and can modify traffic between a user and a server.
- Burp Suite: A tool for intercepting and modifying web traffic between a browser and a server.
- Meta tag: An HTML tag that provides metadata about the page, such as a refresh or redirect instruction.
- SQL injection: A vulnerability where an attacker inserts SQL code into input fields, altering the database query.
- SQL: The language used to query and manage databases.
- Authentication bypass: A way to log in without valid credentials.
- Rate limit: A restriction on how many times an action can be performed in a given time.
- HTTP: The basic protocol for web traffic, unencrypted.
- HTTPS: The secure version of HTTP, encrypted.
- VDP: Vulnerability disclosure program, where companies invite reports but do not pay bounties.
- Defence in depth: A security strategy of using multiple layers of protection.
- Parameterisation: Building SQL queries with placeholders so user input is treated as data, not code.
- Escaping: Adding special characters to user input to neutralise dangerous characters.
- Session: A way for a server to remember a user across requests, often using a cookie.
- Cookie: A small piece of data stored by the browser and sent with requests to identify a session.
- Baseline: The normal response without any malicious input, used for comparison.