A simple diagram of the Host Header Injection risk path
Risk path: an input or context crosses a security boundary.
A simple three-step test path for Host Header Injection
Testing path: establish a baseline, make one controlled change, and verify the effect.

Issue

The HTTP Host header identifies the host and optional port a request targets. Servers and reverse proxies use it to route requests when they serve multiple hostnames. In HTTP/2 and HTTP/3, the :authority pseudo-header can carry this information instead. RFC 9110, Section 7.2

Host header injection occurs when an application or an intermediary trusts a request’s host information in a way that lets an attacker change server behavior. The header is input supplied by the client; it is not proof that the request came through the intended public hostname. Risky uses include building absolute links, choosing a redirect destination, selecting an upstream server, or deciding which virtual host or cache entry to use.

The name covers several different weaknesses. A changed Host value by itself does not establish a vulnerability. The security issue depends on what the application or infrastructure does with that value. OWASP identifies possible outcomes such as unexpected virtual-host routing, redirects, cache poisoning, and manipulation of password-reset links. OWASP Web Security Testing Guide: Host Header Injection

Common causes include:

  • Generating absolute URLs from the request’s Host value rather than a configured canonical origin.
  • Trusting X-Forwarded-Host or similar headers from arbitrary clients instead of accepting them only from configured proxies.
  • Inconsistent host validation or parsing across a CDN, proxy, web server, and application.
  • Routing requests to virtual hosts or internal services without an explicit allowlist.
  • Caching a response that depends on host-related input without ensuring that the cache key distinguishes that input.

Examples

Host value reflected in a reset link

Potentially unsafe pattern:

reset_url = "https://" + request.host + "/reset?token=" + token

If the reset handler accepts a request with Host: attacker.example.net, it may generate a link on that hostname. This is a confirmed link-generation flaw if the test email contains that host. Whether it can expose a reset token or affect an account depends on the email recipient following or fetching the link, and on how the token is handled.

Safer pattern:

reset_url = configured_public_origin + "/reset?token=" + token

The application should use a deployment-configured public origin, such as https://app.example.com, rather than deriving security-sensitive links from request headers.

Host-dependent response and cache behavior

Request:

GET /help HTTP/1.1Host: app.example.comX-Forwarded-Host: marker.example.net

If the response uses marker.example.net to construct a link, that shows the header influences the response. To establish a cache-poisoning issue, a tester must additionally demonstrate that a cache stores that response and later serves it to a request that did not include the marker. Do this only in a controlled environment.

Impact

Impact depends on the affected feature and on whether an attacker can make a victim or shared system use the manipulated response.

  • Password-reset poisoning: If a reset email’s absolute link is built from an untrusted host value, an attacker may cause the email to contain a link to another domain. If the recipient follows it and the reset token is exposed there, the token could be misused. This requires the application to generate the link from attacker-controlled input and the token to reach the attacker; changing the header alone does not prove account compromise. PortSwigger Web Security Academy: Password reset poisoning
  • Web cache poisoning: A response influenced by host-related input may be stored and served to other users if the cache uses a key that does not distinguish the input and the response is cacheable. Reflection in a single response does not prove that poisoning is possible. PortSwigger Web Security Academy: HTTP Host header attacks
  • Misrouting or access to another virtual host: An attacker may reach an unintended service if the front end routes requests using an unvalidated host value and that service is reachable through the same infrastructure. A changed response or a different site appearing is an indicator; sensitive access must be demonstrated separately.
  • Server-side requests: A proxy may be induced to contact an attacker-selected or internal destination if it uses untrusted host information when choosing an upstream. This requires a vulnerable routing path and a way to verify the request reached the destination. Do not infer access to internal data from a changed response alone.

The same input could also cause redirects or malformed links without exposing sensitive data. Report only the behavior and impact demonstrated by evidence.

Testing

Use authorized test accounts, synthetic objects and controlled mailboxes. Run a case only when its feature exists. Change one host-related value at a time and verify the specific effect described in the case.

Keep the connection destination, IP, port, TLS SNI and proxy route fixed when changing Host; the client must not reconnect to the replacement hostname. For HTTP/2 or HTTP/3, test :authority instead of adding a conflicting Host. Disable automatic redirects and retries.

Provision outside.example.test as a tester-controlled endpoint returning inert text; example names do not resolve automatically. Do not send application cookies or Authorization headers to that endpoint. Keep session and CSRF values valid across each comparison and redact secrets in evidence.

Where the proxy supports them, test X-Forwarded-Host or Forwarded host in separate pairs with Host kept canonical. Establish a baseline with the chosen header present, then change only its host value; preserve other parameters. Treat equivalent header variants as one finding when they share the same cause and impact.

Prevent password-reset link poisoning

Applicability

Conditional, common: an email-based password reset endpoint creates an absolute token-bearing URL. Omit for recovery flows without such links.

Objective

Determine whether changing Host redirects the reset token to an untrusted origin.

Security rule

Reset URLs must use the configured recovery origin or an explicitly approved origin for this account, independently of arbitrary client host input.

Controlled setup

Create reset-user in a dedicated tenant and test mailbox; seed its profile with HHI-RESET-01. Configure a private inert sink at outside.example.test. Record the allowed recovery origin. Use no real customer accounts.

Steps

  1. Submit the baseline and inspect the new message in the controlled mailbox; do not rely on the generic HTTP acknowledgement.
  2. Replay the identical request with only Host changed. Correlate the second email by delivery time/message ID; fresh server-generated reset tokens are expected.
  3. Inspect the destination of the actual recovery link. If explicit token-exposure validation is authorized, manually open only the test-account link in a clean browser without application credentials, and compare a restricted token fingerprint with sink logs. Disable mail-preview fetchers or identify their traffic.
  4. Invalidate both tokens using the approved test cleanup mechanism. Do not reset any real account or claim takeover from link generation alone.

Baseline request

POST /password-reset HTTP/1.1
Host: app.example.test
Cookie: reset_session=RESET_TEST_SESSION
Content-Type: application/x-www-form-urlencoded
 
email=reset-user%40mail.example.test&csrf=RESET_CSRF

Baseline result

A fresh email contains a usable recovery link at https://app.example.test and the expected test recipient; this proves the recovery workflow functions.

Test request

POST /password-reset HTTP/1.1
Host: outside.example.test
Cookie: reset_session=RESET_TEST_SESSION
Content-Type: application/x-www-form-urlencoded
 
email=reset-user%40mail.example.test&csrf=RESET_CSRF

Changed value: Host: app.example.test → outside.example.test

Values kept the same: Cookie, CSRF value, email, body bytes, method, path, content type, transport destination and SNI.

Expected secure result

Reject the unknown host before issuing a link, or send the test mailbox a link using the approved recovery origin.

Evidence confirming a finding

The actual reset link contains a live test-account recovery token at the untrusted origin. This establishes poisoned security-sensitive link generation. Token receipt at the controlled sink establishes exposure only; account takeover requires separately authorized proof of token usability.

Evidence to preserve

Sanitized paired requests/responses; recipient and ownership; email message IDs/timestamps; link scheme/host/path with token removed; restricted token fingerprint and sink receipt if validated; token invalidation record.

Likely false positives

An unrelated support link, an intentionally approved tenant recovery domain, an invalid/expired token, email rewriting by a security gateway, or fetches made only by scanners. Generic success messages prove nothing.

References

Prevent host-derived content from poisoning a shared cache

Applicability

Conditional: a shared cache serves HTML whose absolute resource URLs can depend on host metadata. Use an isolated staging cache or a dedicated test distribution with confirmed key isolation and purge control; otherwise omit active poisoning.

Objective

Determine whether one untrusted forwarded-host value contaminates a later canonical request.

Security rule

A clean canonical request must never receive a cached active-resource URL derived from another request’s untrusted host metadata.

Controlled setup

Create a cacheable synthetic page HHI-CACHE-01 at the dedicated route, with a harmless active asset. No accounts or cookies are used. outside.example.test serves inert asset responses; no JavaScript execution is necessary. Confirm the fixture route cannot collide with normal pages and document the actual cache key.

Steps

  1. Purge the fixture key, request the baseline, and confirm the canonical active-asset origin. Repeat once to establish that this route actually caches.
  2. Purge the same key again without changing configuration; submit the test request as the first fill request.
  3. Send the exact baseline request again, without a unique query or cache-bypass header. Confirm cache reuse using edge/origin logs and cache metadata; inspect the active asset URL in this clean response.
  4. Purge every affected layer and verify the clean page is canonical again. A second independent client may corroborate reuse but is outside the one-header comparison.

Baseline request

GET /hhi-fixtures/cache-01 HTTP/1.1
Host: app.example.test
X-Forwarded-Host: app.example.test
Accept: text/html

Baseline result

The synthetic page loads with a canonical active asset, and repeated requests show verified cache reuse.

Test request

GET /hhi-fixtures/cache-01 HTTP/1.1
Host: app.example.test
X-Forwarded-Host: outside.example.test
Accept: text/html

Changed value: X-Forwarded-Host: app.example.test → outside.example.test

Values kept the same: Host, method, route, Accept, absence of credentials, cache key, connection and SNI. The verification request is the baseline replay.

Expected secure result

Reject/ignore the override or keep its response isolated; the later canonical request must contain only approved asset origins.

Evidence confirming a finding

A later baseline replay receives an active-resource URL at outside.example.test from the poisoned stored response. Preserve the clean response body and verified cache reuse. Reflection only in the test response is insufficient; execution or broad production reach must not be inferred.

Evidence to preserve

Sanitized fill and clean request/response sequence, page marker and asset URL, key configuration, purge receipts, timestamps, cache-status/Age metadata and origin/edge correlation logs.

Likely false positives

Direct origin reflection on every request, browser-local caching, a cache key that includes the override, a diagnostic header without reuse, or an intentionally public external asset.

References

Preserve access restrictions when selecting a protected virtual host

Applicability

Conditional: public and restricted virtual hosts share an edge/origin, and a protected read-only fixture exists. Omit if there is no restricted virtual host.

Objective

Test whether Host selection exposes one protected read-only resource over the public ingress.

Security rule

Choosing a virtual host must not bypass the ingress authentication or network policy for protected content.

Controlled setup

Place HHI-PUBLIC-01 on the public fixture and HHI-ADMIN-PRIVATE-01 on the restricted host at the same path. A dedicated administrator verifies the private marker through the approved authenticated route separately. The actual comparison is anonymous, with no cookies, client certificate or authorization.

Steps

  1. Verify ownership, private policy, and the restricted marker using the approved admin workflow.
  2. Send the anonymous baseline through public ingress and confirm HHI-PUBLIC-01.
  3. Replay with only Host changed to the known authorized restricted virtual-host name. Read only the fixture; invoke no administrative operation.

Baseline request

GET /hhi-fixtures/access-check HTTP/1.1
Host: app.example.test
Accept: text/plain

Baseline result

The public fixture returns HHI-PUBLIC-01, establishing that the path and public transport work; the separate admin control establishes the private fixture exists.

Test request

GET /hhi-fixtures/access-check HTTP/1.1
Host: admin.example.test
Accept: text/plain

Changed value: Host: app.example.test → admin.example.test

Values kept the same: GET, fixture path, Accept, anonymous identity, absence of cookies/certificates, ingress IP, port and SNI.

Expected secure result

Reject public access or require the restricted host’s normal authentication/network controls; never disclose the private marker.

Evidence confirming a finding

The anonymous public-ingress response contains HHI-ADMIN-PRIVATE-01 whose policy requires restricted access. A different site, login page, server banner or status alone is not sufficient.

Evidence to preserve

Paired sanitized requests/responses, public/private marker ownership, documented ingress rule, admin control evidence without admin secrets, connection/SNI and routing logs, timestamps.

Likely false positives

Intentionally public administrative login pages, shared default hosts, a test client retaining admin credentials, or a restriction that never existed in the agreed policy.

References

Enforce tenant membership during host-based report reads

Applicability

Conditional: hostname selects a tenant and the same report key can exist in separate tenants. Omit for single-tenant apps or apps without host-based tenant selection.

Objective

Determine whether tenant A’s credentials can read tenant B’s report by changing only Host.

Security rule

Host-based tenant selection must still enforce the authenticated principal’s membership and report-read permission in the selected tenant.

Controlled setup

Create dedicated tenant A and B owners, one reader authorized only in A, and one report per tenant with key shared-fixture. Use HHI-TENANT-A-01 and HHI-TENANT-B-PRIVATE-01; disable public sharing. A B owner verifies B’s marker separately. Use a nonprivileged A bearer token that remains valid for both requests.

Steps

  1. Read A’s report with the baseline and record its marker and ownership.
  2. Repeat with only the hostname changed to B; keep A’s bearer token exactly unchanged.
  3. Inspect the returned report for B’s protected marker; independently confirm sharing and membership have not changed.

Baseline request

GET /api/reports/shared-fixture HTTP/1.1
Host: tenant-a.example.test
Authorization: Bearer TENANT_A_READER_TOKEN
Accept: application/json

Baseline result

A’s token returns only HHI-TENANT-A-01 from A’s owned report.

Test request

GET /api/reports/shared-fixture HTTP/1.1
Host: tenant-b.example.test
Authorization: Bearer TENANT_A_READER_TOKEN
Accept: application/json

Changed value: Host: tenant-a.example.test → tenant-b.example.test

Values kept the same: Bearer token, method, report key, path, Accept, transport IP/port/SNI and all other inputs.

Expected secure result

Deny the B read, or retain the authenticated A context where policy requires it; never return B’s protected report to the A-only reader.

Evidence confirming a finding

A-only credentials receive HHI-TENANT-B-PRIVATE-01 and the known B report content. A tenant name, empty shell, object ID or different error is insufficient.

Evidence to preserve

Sanitized pair, A reader role and memberships, both report ownership records, sharing policy, marker-bearing response, timestamps and correlation IDs.

Likely false positives

Cross-tenant membership, intentionally shared reports, global support privileges, duplicate marker placement, or a token actually issued to a multi-tenant principal.

References

Restrict host-controlled upstream destinations

Applicability

Conditional: a reverse proxy or application uses request authority to select an upstream. Omit when upstream selection is fixed and no such routing exists.

Objective

Determine whether Host can cause a server-side HTTP request to a disallowed controlled destination.

Security rule

Client authority must not select upstreams outside the configured permitted destinations.

Controlled setup

Provision a public synthetic fixture HHI-UPSTREAM-BASE-01 and a tester-owned inert HTTP sink at outside.example.test with path logging. Agree that this sink is outside the upstream allowlist. Do not use metadata endpoints, loopback, customer/internal systems, DNS rebinding or port scans. No account credentials are needed.

Steps

  1. Send baseline and confirm the known public fixture.
  2. Keep the client connected to the authorized ingress and change only Host. Do not follow redirects or browse to the sink.
  3. Correlate a full HTTP request at the sink with edge/application egress logs and the unique fixture path; a DNS lookup alone does not count.

Baseline request

GET /hhi-fixtures/upstream-01 HTTP/1.1
Host: app.example.test
Accept: text/plain

Baseline result

The approved upstream returns HHI-UPSTREAM-BASE-01 on the expected path.

Test request

GET /hhi-fixtures/upstream-01 HTTP/1.1
Host: outside.example.test
Accept: text/plain

Changed value: Host: app.example.test → outside.example.test

Values kept the same: Method, path, Accept, anonymous identity, transport destination, port, TLS SNI and redirect-following disabled.

Expected secure result

Reject the authority or use only configured upstreams. No server-side HTTP request reaches the disallowed sink.

Evidence confirming a finding

A correlated full HTTP request from the assessed server/proxy reaches the controlled disallowed sink. This proves unauthorized outbound functionality, not internal data access. Distinguish server traffic from the tester, mail scanners and monitoring.

Evidence to preserve

Sanitized pair, sink HTTP path/time and source, matching proxy egress correlation, fixed-destination client trace and agreed upstream policy.

Likely false positives

An intentionally general forward proxy, an approved upstream alias, DNS-only callbacks, automatic client redirects or unrelated scanner traffic.

References

Keep login and canonicalization redirects on approved origins

Applicability

Broadly applicable when a route redirects to login or a canonical absolute URL; omit if the app has no host-derived redirects.

Objective

Determine whether a client Host value controls a redirect destination.

Security rule

Login/canonicalization redirects must remain relative or use explicitly approved origins; client host input must not choose an external destination.

Controlled setup

Use an anonymous browser/proxy context, a public login entry route and inert outside.example.test sink. No accounts or private objects are required; label the run HHI-REDIRECT-01 in the evidence, not by adding request parameters.

Steps

  1. Send baseline without following redirects and confirm the normal login destination.
  2. Replay with only Host changed and parse Location as a URL, resolving relative destinations against the real public origin.
  3. If validating navigation is necessary, use only an isolated client with no application credentials; do not claim a browser-deliverable phishing chain without showing how a victim obtains the altered response.

Baseline request

GET /account HTTP/1.1
Host: app.example.test
Accept: text/html

Baseline result

The request produces the expected redirect to a relative /login path or https://app.example.test/login.

Test request

GET /account HTTP/1.1
Host: outside.example.test
Accept: text/html

Changed value: Host: app.example.test → outside.example.test

Values kept the same: GET, /account, Accept, anonymous identity, transport and SNI; automatic redirects remain off.

Expected secure result

Reject the unknown host or redirect to an approved origin; no Location directs the user to the untrusted sink.

Evidence confirming a finding

An actionable Location directs navigation to outside.example.test, demonstrating unauthorized redirect functionality. Arbitrary echoed text or a generic error is insufficient. Report the demonstrated redirect separately from unproven victim delivery.

Evidence to preserve

Sanitized pair, full Location scheme/host/path, configured redirect policy, transport trace, timestamp and any safe navigation evidence.

Likely false positives

Approved alternate login domains, tenant custom domains, relative locations that stay local, a client that changed network destination, or a deliberately documented general redirect service.

References

Keep active resource URLs on approved origins

Applicability

Broadly applicable to rendered HTML with absolute script or stylesheet URLs; omit if active resources are entirely relative or independently configured. This is an uncached response-generation test, separate from shared-cache reuse.

Objective

Determine whether Host changes the origin of one active resource loaded by a rendered page.

Security rule

Untrusted host metadata must not select executable or styling resource origins outside the application’s approved asset origins.

Controlled setup

Create a synthetic help page HHI-ASSET-01 with a known harmless asset. Use an isolated cache-disabled fixture or verified origin response; no authenticated data. Configure outside.example.test to serve inert text only. Record approved CDN origins and CSP policy.

Steps

  1. Fetch baseline and identify one actual script src or stylesheet href; confirm it belongs to the configured asset origins.
  2. Replay changing only Host, inspect that same resource attribute and resolve the URL as a browser would.
  3. If needed, render the captured synthetic response in an isolated no-credentials browser and observe whether policy allows the asset request. Do not serve executable code. Keep shared-cache testing in its own case.

Baseline request

GET /help HTTP/1.1
Host: app.example.test
Accept: text/html

Baseline result

The synthetic help page contains HHI-ASSET-01 and the expected approved active-resource URL.

Test request

GET /help HTTP/1.1
Host: outside.example.test
Accept: text/html

Changed value: Host: app.example.test → outside.example.test

Values kept the same: Method, /help, Accept, absence of credentials, connection, SNI and cache handling.

Expected secure result

Reject/ignore the untrusted host or retain approved active-resource origins.

Evidence confirming a finding

The test response sets an actual active-resource URL to the unapproved origin. A browser request to the inert sink establishes external loading where CSP allows it; do not claim script execution, victim delivery or cache poisoning from an attribute alone. Ordinary text and metadata reflection are not findings under this case.

Evidence to preserve

Sanitized pair, marker and exact asset attribute, approved origins, CSP headers, cache/origin evidence, optional browser network log and timestamps.

Likely false positives

Intentional third-party assets, inert canonical/SEO tags, escaped display text, a self-created test-browser navigation to the sink, or CSP blocking the request. CSP can limit impact without correcting URL generation.

References

Mitigation

Primary fixes

  • Use a configured canonical origin for absolute links. Build password-reset URLs, email links, and other security-sensitive absolute URLs from trusted deployment configuration. This removes request headers from the link-generation decision.
  • Validate accepted hostnames at the edge and in the application. Use an explicit allowlist of expected hostnames and ports. Reject unknown values rather than falling through to an unintended virtual host. Parse and compare hostnames consistently; avoid loose suffix checks that can accept lookalike names.
  • Handle proxy headers only across trusted proxy boundaries. Configure the edge proxy to remove client-supplied forwarding headers and set its own values. The application should trust these headers only when the request came from a known proxy and the proxy configuration is understood.
  • Route to fixed, configured upstreams. Do not use a client-controlled host value to select arbitrary upstream destinations. Apply network-level restrictions as an additional safeguard when services make outbound requests.
  • Make cache behavior match response behavior. If a response legitimately varies by host or another header, ensure the cache key accounts for that value, or prevent that response from being shared. Avoid caching personalized or security-sensitive responses as public content.

Additional defensive measures

  • Configure an explicit default virtual host that rejects unknown hostnames.
  • Avoid using host values as the sole basis for authentication or authorization decisions.
  • Log rejected host values and investigate unexpected traffic, while avoiding sensitive data in logs.

Retest

Repeat the original test cases through the same CDN, proxy, and application path. Confirm that unknown hosts are rejected or handled safely; reset emails always use the configured public origin; client-supplied forwarding headers cannot override proxy-set values; and a harmless marker cannot appear in a later clean user’s cached response. Review every public hostname and relevant protocol path, including HTTP/2 or HTTP/3 where deployed.