DedSec Security Research ·
Here is a hypothetical. A dynamic scan of a staging environment returns three findings that all come from the same test: the scanner replaced the Host header with a hostname it controls and looked for that name in the response. The first, titled "Host header injection" and rated medium, is on /login, where the canary hostname came back inside the Location header of a redirect. The second, also titled "Host header injection" and rated high because it is on the home page, is a canary that came back in the page body. The third is on /forgot-password, where nothing reflected in the response at all, so the scanner reported it clean.
The second gets escalated, because high is high and it is the home page. The first is assigned to a developer. The third is never looked at. As in the earlier posts in this series, each call rests on the title and the rating rather than on what the scanner observed and what that observation can prove. The home-page reflection may be display text that never becomes a URL. The redirect is a real host-derived URL, but it only matters if something other than the tester's own browser ever receives it. And the reset form, which reflected nothing, may be the one that emails a victim a link pointing at the attacker.
This post is for whoever is holding a Host header finding from a dynamic scan, or a clean result on a reset or redirect endpoint that they are about to rely on. It covers where servers and frameworks get "the current host" from, which is not always the Host header, what happens with duplicated, absent and absolute-form requests, which forwarded headers each stack honours, the five things a host-derived value can break, why every one of them needs a second party to receive the poisoned value, what a scanner's evidence must show, the false positives and the false negatives, the fix, and the static-analysis view. It is the eleventh post in a series about confirming DAST findings, after reflected XSS, SQL injection, OS command injection, Nuclei template matches, ffuf content discovery, path traversal, open redirect, SSRF through URL-fetch parameters, XXE and CRLF header injection. It overlaps the open-redirect post, because a host-derived Location is a redirect whose destination the requester chose, the SSRF post, because a proxy that routes by Host is a URL fetcher with the URL in a header, and the out-of-band post, because the reset-email case can only be confirmed out of band.
Sources, and how each was checked. The measurements below were made on our test machine on 2 November 2026, in a scratch directory on an Ubuntu 24.04 machine, inside a Linux network namespace with only a loopback interface, with every server running as an unprivileged user. We confirmed the isolation before the runs: a lookup of the external name example.com failed, so nothing left the machine. The software was Python 3.12.3 (Ubuntu package 3.12.3-1ubuntu0.17), whose http.server and wsgiref modules we ran as servers; Node.js 22.22.2, whose core http module reports llhttp 9.3.0; Express 4.21.2 and Starlette 1.8.0 under uvicorn 0.54.0 with h11 0.16.0, all three already installed on the machine and used as found; nginx 1.24.0 as a reverse proxy and cache; and curl 8.5.0. We sent the malformed requests (duplicated Host, missing Host, an absolute-form request line) as exact bytes from a raw socket, because a normal client would correct them, and we captured what curl itself put on the wire with a listener that recorded the request bytes. Each server echoed back what it believed the host to be. We wrote deliberately vulnerable handlers that built a password-reset link, an absolute redirect and a script URL from the host, and a deliberately vulnerable nginx server block that chose its upstream from the Host header. The reset "email" was a line appended to a local file, not a message sent anywhere. RFC 9110 and RFC 9112 (HTTP semantics and HTTP/1.1 message syntax), RFC 7239 (the Forwarded header) and RFC 9113 (HTTP/2) are cited by name and described in our own words, because we had no copy of them on the machine to quote from. Django, Flask and Werkzeug were not installed, and we did not install them, so nothing in this post about them is measured. We did not measure any CDN, any commercial load balancer, any browser or any mail server. Where this post says something about those, it is written as mechanism or general practice, and it says so. The opening scenario is hypothetical, and no number in this post measures any scanner, ours included.
An application that builds an absolute URL — a link in an email, a redirect, a canonical tag, a script source, a callback URL handed to a third party — needs to know its own name. There is no single place to get it, and that is the root of the bug class. A request can carry the name in up to four places, and different components read different ones.
GET /login HTTP/1.1, but it can be a full URL, GET http://abs.example/login HTTP/1.1. That form is what a client sends to a forward proxy. RFC 9112 section 3.2.2 says that when an origin server receives the absolute form, it must ignore the Host header and use the host from the request target instead. So a request can name two hosts, and the specification says which one wins. The measurements below show that not every component follows it.X-Forwarded-Host, X-Forwarded-Proto and X-Forwarded-For, which are a convention rather than a standard, or the standard Forwarded header from RFC 7239, which carries the same information as parameters: Forwarded: host=...;proto=...;for=.... A client can send any of these itself. Whether the application believes them is a configuration choice, and it is a common way an application that validates Host still ends up using an attacker's hostname.Two smaller details matter for triage. A port is part of the authority, so app.example:1337 is a valid Host value, and some components strip the port before comparing names while others keep it when they build a URL. And in HTTP/2 the authority travels in the :authority pseudo-header; RFC 9113 tells clients not to send a Host header that disagrees with it and says a server should treat a mismatch as malformed. We did not measure any HTTP/2 component, so how a front end that translates HTTP/2 into HTTP/1.1 resolves a disagreement is not something this post shows.
The weakness is not that an application reads the Host header. Every virtual-hosting server has to. The weakness is that an attacker-chosen host is used to build something that someone or something other than the attacker will later trust. There are five common shapes.
Location: http://<host>/home, or a link in a page built the same way, sends the requester to the attacker's host. On its own request, that only redirects the attacker. It becomes an attack on someone else when it is combined with a cache or another delivery path.That last point is the one that should drive triage, and it holds for all five. A browser does not let a web page set the Host header of a request — Host is on the Fetch standard's list of forbidden request headers; this is browser behaviour we did not measure — and a victim clicking an ordinary link sends the real one. So the attacker can only put their hostname into their own requests. A host-derived value that is returned to the attacker and nowhere else harms no one. Every real impact in the list needs a second party that receives the value: a victim's inbox, a shared cache, or a proxy that acts on it. The finding is the second party, not the reflection.
We know of no CWE entry specific to Host header injection, so findings are filed under whatever the consequence is — CWE-640 (weak password recovery mechanism) for reset poisoning, CWE-918 for routing-based SSRF, and often CWE-20 (improper input validation) as a catch-all. The claim underneath them is the same and has two halves that a scanner often conflates:
A finding built on the first half alone is a common false positive in this class, and a clean result built on the absence of the first half is a common false negative, because the reset email, the cached copy and the proxied connection never appear in the response the scanner reads.
We sent the same thirteen requests to each server and had each one report what it believed the host to be. These are the results that matter for triage; the full output is in our lab notes.
Python 3.12.3, http.server. The handler's self.headers.get("Host") returned whatever the client sent, spoofed or not, with the port kept (app.test:1337). It accepted HTTP/1.1 requests with no Host at all (get returned None) and with two Host headers, where get returned the first and get_all returned both; it accepted malformed values such as app.test, c4n4ry.oob.test, [email protected] and a non-numeric port, app.test:c4n4ry, verbatim, and returned 200 to all of them. With an absolute-form request line, self.path was the whole URL, http://abs.oob.test/p, and the Host header still said app.test. The server does not apply RFC 9112's rule; it hands the application both values and leaves the choice to it.
Python 3.12.3, wsgiref. Its URL helpers, application_uri and request_uri, built the application's own URL from HTTP_HOST whenever one was present: a spoofed Host gave http://c4n4ry.oob.test/p, and with no Host they fell back to the configured SERVER_NAME and port, http://localhost:18002/p. With two Host headers, HTTP_HOST was the two values joined with a comma, app.test,c4n4ry.oob.test, and that string went into the built URL unchanged. Anything that builds a link with these helpers inherits the client's host.
Node.js 22.22.2, core http. req.headers.host was the client's value, spoofed or not, port kept. With two Host headers, req.headers.host was the first and the second was visible only in req.rawHeaders. An HTTP/1.1 request with no Host was rejected with 400 before the handler ran; an HTTP/1.0 request with no Host was accepted, with host undefined. Malformed values (comma, @, non-numeric port) were accepted verbatim. With an absolute-form request line, req.url was the whole URL and req.headers.host stayed app.test, the same split as Python.
Express 4.21.2. req.hostname followed the Host header with the port stripped (app.test:1337 gave app.test, and so did app.test:c4n4ry), while req.get("host") returned the raw header including the port. Malformed values with a comma or @ passed straight through req.hostname. The important result is the forwarding headers. With the trust proxy setting at its default, which reported as false, X-Forwarded-Host and X-Forwarded-Proto were ignored. With trust proxy set to true, req.hostname became the client-supplied c4n4ry.oob.test and req.protocol became https, from a request sent directly by the client with no proxy in between. req.get("host") still said app.test, so code that uses hostname and code that uses get("host") disagree on the same request. The RFC 7239 Forwarded header was ignored in both settings.
Starlette 1.8.0 on uvicorn 0.54.0. request.url, request.base_url and url_for were all built from the Host header, so a spoofed Host produced http://c4n4ry.oob.test/x from url_for. uvicorn rejected a request with two Host headers with 400 "Invalid HTTP request received.", where the Python and Node servers accepted it, and, like Node, it rejected an HTTP/1.1 request with no Host with the same 400. Starlette parsed the Host value before using it: for the comma, @ and non-numeric-port values, request.url fell back to the server's own socket address, http://127.0.0.1:18021/p, rather than using the malformed host, which we confirmed in its URL constructor. An absolute-form request line returned 404. X-Forwarded-Host was ignored. X-Forwarded-Proto was not: with uvicorn's defaults, a request from 127.0.0.1 carrying X-Forwarded-Proto: https produced https://app.test/p as the URL. Reading uvicorn's configuration source explains it: proxy-header handling is on by default and trusts 127.0.0.1 and ::1 unless FORWARDED_ALLOW_IPS says otherwise, and it applies X-Forwarded-Proto and X-Forwarded-For, not X-Forwarded-Host. That default is reasonable when a proxy on the same machine is the only thing that can connect; it means any other local process, or a misconfigured proxy that passes the client's header through, chooses the scheme.
nginx 1.24.0. nginx was the only component that applied RFC 9112's absolute-form rule. Given GET http://abs.oob.test/p with Host: app.test, it selected the server block by abs.oob.test, and $host, which it forwarded upstream, was abs.oob.test. It rejected duplicate Host headers, an HTTP/1.1 request with no Host, and a comma in Host, each with 400. It stripped the port from $host and selected the app.test server block for both app.test:1337 and app.test:c4n4ry, while $http_host kept the raw value; an HTTP/1.0 request with no Host was handled by the default server, and $host became that server's name. It passed a client-supplied X-Forwarded-Host through to the upstream untouched, because our configuration did not set or clear it.
curl 8.5.0, as the tester's tool. -H "Host: ..." replaced the Host header. Giving it twice did not send two: only the first went on the wire. -H "Host:" removed it, and with --http1.0 that produced a request with no Host at all. --request-target http://abs.oob.test/e with -H "Host: app.test" sent an absolute-form request line with a disagreeing Host, which is the exact disagreement case. -x (a proxy) sent the absolute form with a matching Host, and --connect-to connected to a different address while sending the real name, which is how to test a specific origin behind a load balancer without changing DNS. To send duplicate Host headers we had to use a raw socket.
Taken together, the results say one thing: a front end and an application can disagree about which host a request is for. nginx routed and forwarded by the request line while Python and Node kept the Host header; Node and Python took the first of two Host headers while wsgiref joined them; Express's hostname and get("host") disagreed when trust proxy was on and X-Forwarded-Host was sent, and on any port-suffixed Host in either setting. Any pair of components that disagree is a place where the host that was checked is not the host that is used.
Password-reset poisoning. Our deliberately vulnerable reset handler built the link from the Host header and appended the "email" to a file. A POST to /reset with Host: c4n4ry.oob.test wrote a message to [email protected] containing http://c4n4ry.oob.test/reset/confirm?token=TOKEN123. The HTTP status was 200, as it was for the legitimate request; we captured only the status code, and the body is the same fixed "If the account exists, an email was sent." for every request because the handler writes no request data into it. The only evidence was in the outbox. A scanner that reads responses sees nothing. The fixed handler, which took the base URL from configuration, wrote https://app.example.test/reset/confirm?token=TOKEN123 for the same spoofed request. A request carrying only X-Forwarded-Host was not poisoned, because this handler never read that header; whether a real handler does depends on its framework's trust-proxy setting, as the Express result shows.
Absolute redirects. Our /login handler built Location: http://<host>/home, and a spoofed Host produced Location: http://c4n4ry.oob.test/home. Our Express handler, which built the redirect as "//" + req.get("host") + "/home", produced Location: //c4n4ry.oob.test/home with Express's default settings; the // came from our handler, not from Express. That is a scheme-relative URL, which a browser resolves against the current scheme to the named host; that is browser behaviour we did not measure. Both are real host-derived URLs. Both only redirect the requester.
Cache poisoning through an unkeyed header. We put nginx's cache in front of a backend that built a script URL from X-Forwarded-Host, falling back to Host, and marked the response cacheable. nginx's default cache key is $scheme$proxy_host$request_uri, where $proxy_host is the upstream's name, not the client's Host. This ran on the server block that sits behind our explicit 421 default. A spoofed Host would have got the 421 before nginx proxied anything, so it could not reach the cache; but X-Forwarded-Host poisoning did not need a spoofed Host, because the Host was the legitimate app.test. An attacker request with X-Forwarded-Host: c4n4ry.oob.test was a cache MISS and returned <script src="https://c4n4ry.oob.test/static/app.js">. The next request for the same path, with no X-Forwarded-Host at all, was a cache HIT and returned the same poisoned script tag. On a catch-all server block that accepted any well-formed Host, the same thing happened with Host itself: a spoofed Host, then a normal request, and the normal request got the attacker's script URL from the cache. We measured one follow-up request in each case; by mechanism, every request for that cache key would get the poisoned copy until the entry expired, which we did not test.
Routing-based SSRF. A server block with proxy_pass http://$http_host; took its upstream from the client. Host: 127.0.0.1:18041 returned the body of an internal service bound only to loopback, INTERNAL-ADMIN-ONLY. Hostnames that needed DNS (localhost:18041, c4n4ry.oob.test) returned 502, because this block had no resolver configured; with one, names would resolve too. This is the configuration mistake in its plainest form, and the result shows how direct it is when present.
Virtual hosts. On the port where we had not declared a default, the first server block for the port answered every well-formed Host, including the spoofed one, and passed it to the application. On the port with an explicit default server that returned 421, the spoofed Host, the @ form and the absolute-form request naming an unknown host all got 421 and never reached the application.
A scanner testing for Host header injection sends a request with a hostname it controls in Host, and usually in X-Forwarded-Host and similar headers too, and looks for that name in what comes back. Which part of the response contains it decides what has been shown.
src, a link href, a canonical tag, a form action — is also a host-derived URL. Our /canonical handler returned <link rel="canonical" href="http://c4n4ry.oob.test/canonical">. Again the question is whether a cache stores it.c4n4ry.oob.test"><b>x into harmless text, but a plain canary hostname contains no characters that escaping changes, so the escaped and unescaped reflections looked identical. Escaping is not what decides this. What decides it is whether the value is used to build a URL or a routing decision. Display text with no URL around it is the second hypothetical finding.What is not a finding: a 400 for a duplicate, missing or malformed Host; a 421 Misdirected Request; or a response identical to the default virtual host's page. Each means the component rejected or ignored the spoofed host, which is the correct behaviour. A scanner that reports "the response changed when we changed Host" without checking that the change was a 400, a 421 or the default site is reporting a server doing its job.
The canary design matters, for the same reason it does in the open-redirect and SSRF posts. A hostname that is unique per request, under a domain whose DNS the tester controls, does three jobs: it is distinguishable from any name the application might legitimately print, an out-of-band hit can be tied to the exact request that planted it, and a hit days later — from a delayed email, a cache refresh or a log processor — can still be attributed.
And the false negatives, which matter more because they produce a clean result:
trust proxy set to true, a scan that only changed Host sees nothing.--connect-to if you are allowed to.The procedure below is general practice. Use a hostname under a domain you control, trigger reset emails only for accounts you own, and do not poison a shared cache that real users read — use a cache-busting query string so that only your own key is affected.
curl -s -i without -L, with -H "Host: <canary>". Note exactly where the canary appears: Location, a URL in the body, or text in the body.X-Forwarded-Host, then in Forwarded: host=<canary>. A result here, and not with Host, means a trust-proxy configuration issue rather than a Host-validation one.--request-target http://<canary>/path with the real Host; the real host with a port appended; and, from a raw socket, two Host headers in each order. Record which value each layer used.All of this is general practice except where it says it was measured. The root rule: an application should never learn its own name from the request.
TrustedHostMiddleware with allowed_hosts=["app.test"] rejected the spoofed Host, the comma, @ and non-numeric-port forms, and an HTTP/1.0 request with no Host, each with 400 "Invalid host header", and accepted app.test and app.test:1337, so it compared the name and not the port. Django has the equivalent. According to its documentation — the ALLOWED_HOSTS and USE_X_FORWARDED_HOST settings and HttpRequest.get_host — the host is validated against ALLOWED_HOSTS when the application asks for it, a non-matching host raises DisallowedHost, which Django turns into a 400 (SuspiciousOperation), and X-Forwarded-Host is consulted only when USE_X_FORWARDED_HOST is enabled. We did not test this, because Django is not installed on our machine. Other frameworks have their own form.trust proxy setting can be an address list instead of true; true let a direct client choose req.hostname and req.protocol in our test. uvicorn's FORWARDED_ALLOW_IPS should name your proxy and nothing else. And the proxy should overwrite, not pass through, the forwarding headers it sets: our nginx forwarded the client's X-Forwarded-Host untouched because we did not set it, so a trusted proxy can still carry an untrusted value.default_server that returns 421 stopped the unknown names in our test — a spoofed Host, the @ form, an HTTP/1.0 request with no Host and an absolute-form request naming an unknown host — before they reached an application. It did not stop a non-numeric port on a known name (a request with Host: app.test:c4n4ry reached the application; nginx forwarded Host: app.test, and the raw value survives in $http_host for any config that passes it on), and it does nothing about forwarding headers: the X-Forwarded-Host cache poisoning above happened on that same server block. Without a default, the first server block answered every well-formed Host. It is one layer, alongside the allow-list and the configured base URL, not a substitute for them.$http_host or any header.Static analysis models this as taint from a host source to a URL-building sink. The sources are the Host header and every way a framework exposes it — req.hostname, request.url, url_for, build_absolute_uri-style helpers, wsgiref's request_uri — plus the forwarding headers. The sinks are email bodies, Location headers, absolute URLs written into templates, and upstream connection targets. The SAST false positives post covers crediting a sanitiser against a sink it does not protect, and this class has its own version. The real sanitiser is usually not in the code path at all. It is a setting: an allow-list middleware, a framework's allowed-hosts list, a trust-proxy value, a proxy's default server. A rule that flags every url_for in a reset handler will fire on applications whose host allow-list makes it safe; a rule that ignores url_for will miss the ones without one. HTML-escaping, which a rule might credit, did nothing useful here, because a hostname needs no escaping to be dangerous. Being precise requires knowing the configuration as well as the code, which is also what confirming the dynamic finding required.
A confirmed DAST finding tells you that a deployed endpoint built something from a host you chose, and through which header. A SAST finding tells you which line builds the URL. Neither, alone, tells you whether a cache, a mailbox or a proxy turns it into an attack. That part is in the deployment.
Back to the three hypothetical findings.
In the scenario, the home-page finding was display text. The canary sat in a sentence naming the site, inside no URL, and the page built its links as relative paths. It was closed for this class with the response attached; the team added a host allow-list anyway, after which the same request got a 400.
In the scenario, the /login redirect was a real host-derived URL, and on its own it redirected only the request that carried the spoofed Host. What raised it was a second request: the redirect was cacheable at the CDN, which keyed on path and not on the forwarded host the application had trusted, so a clean request for a cache-busted copy of the path came back with the canary. It was re-rated as cache poisoning, fixed by building the redirect from configuration and limiting the forwarded-host trust to the CDN's addresses, and retested with the same two-request sequence.
In the scenario, the /forgot-password clean result was a false negative, and the most serious of the three. The application sat behind a load balancer with its framework's trust-proxy setting fully open, and the load balancer passed X-Forwarded-Host through. A reset triggered for a tester-owned account with the canary in X-Forwarded-Host produced an email whose link pointed at the canary, and a mail scanner fetched it within seconds, which was the out-of-band hit. The fix took the reset link's base URL from configuration, limited trust-proxy to the load balancer, and had the load balancer overwrite the forwarding headers. The retest triggered the reset with both Host and X-Forwarded-Host set to the canary and read the email.
AppSecD's dynamic and API testing runs Nuclei, Dalfox, SQLMap, Commix, Katana, Arjun, FFuf and Interactsh for out-of-band detection, plus 150+ native checks and API discovery across 50+ web frameworks. In its lifecycle this is the runtime stage: DAST and API testing run against the deployed application, because code review cannot see an injection that only appears once the application is assembled and running. Its static analysis includes dataflow taint analysis that traces source to sink across functions. Its AI layer assembles attack chains across findings, showing how separately unremarkable issues combine. Its findings are deduplicated across scans and tracked through new, reopened and fixed states, and they need maker-checker approval to close, so a finding cannot be closed unilaterally.
That is the whole claim, and data/products.ts, the single source of truth for what these products do, does not mention Host header injection at all. So this post does not claim that AppSecD has a dedicated Host header check, which headers, canary hosts or request forms it sends, whether it sends absolute-form, duplicated or port-suffixed Host values, whether its Interactsh out-of-band detection is applied to Host or forwarding headers or to password-reset flows, whether it distinguishes a host-derived URL from display text or a 400 or 421 from a finding, whether it tests cache poisoning or routing-based SSRF, how it rates the severity of such a finding, whether its attack-chain assembly links a host-derived redirect to a cache finding, whether its static rules account for host allow-lists or trust-proxy configuration, or how accurate any such detection would be. The measurements, the confirmation procedure, the fixes and the checklist above are general practice, not a description of how AppSecD works internally, and they apply to any scanner's output, ours included. The scenario in this post is hypothetical and does not describe any AppSecD deployment, user or finding.