← Host Header Injection lesson
Web InfrastructureHost Header InjectionAdvanced30 min+100 XP

Forwarded Host Header

The Edge Router is behind an edge proxy that forwards a host header, and the internal vhost trusts it. Reach the admin console.

“The request knew the app. The header told it who to trust.”

CWE-644OWASP Top 10 A05:2021OWASP ASVS 14.2.3
The story
HTTP carries hostnames in more than one place: Host, X-Forwarded-Host, X-Original-Host, absolute URLs. If the server uses one of them to choose a vhost or build a link, the client controls the destination.

A proxy forwards a host header and the application router trusts it. The attacker sends the internal hostname and reaches an admin vhost that should only be available internally.

Your objective
  • Inspect the proxy behavior
  • Send the trusted host header
  • Reach the internal admin vhost and capture the flag
Boundary under test

Client header to application host

Field guide · request anatomy

Where to look before you type a payload

01Receive

The request carries Host and possibly X-Forwarded-Host, X-Forwarded-Proto or Forwarded.

02Trust

The application or proxy uses the header to build absolute URLs or choose a virtual host.

03Generate

A reset link, redirect or canonical URL includes the attacker-controlled hostname.

04Deliver

The link is emailed, cached or returned to the user.

Progressive hints

Open one hint at a time. The first two build the model; the last two point at the boundary.

Hint 1

Inspect the proxy and host-related headers.

Hint 2

Send the trusted host header.

Hint 3

Send x-vhost: internal.relay.local to /admin.

Hint 4 · near the answer

Request the admin route with the header and capture the flag.

Guided workbench

Observe → Hypothesize → Test → Prove → Explain

This is the same loop a reviewer expects in a report. Your draft stays in this browser; nothing is submitted until you choose to export it.

0/15steps complete
Observe0/3
Hypothesize0/3
Test0/3
Prove0/3
Explain0/3

Evidence log

Write for a reviewer who was not in the room. Every claim needs a request, response or state change behind it.

Preview the evidence report
# Lab evidence report — Forwarded Host Header

- Family: Host Header Injection
- Lab ID: web-hostheader-forwarded
- Date: 2026-12-05

## Workflow

### Observe

- [ ] Open "Forwarded Host Header" and record /admin, the HTTP method and the role you are given.
- [ ] List every parameter, header, cookie and object identifier the normal flow exposes.
- [ ] Save a baseline response: status, body shape, timing and the fields that change by user.

### Hypothesize

- [ ] Name the server decision that protects /admin, and the evidence it should use.
- [ ] Use the clue as a constraint, not an answer: The router trusts x-vhost. The internal hostname is internal.relay.local.
- [ ] Predict the exact status, body or state change that would prove the decision is missing.

### Test

- [ ] Start from the baseline and change one value: the x-vhost header.
- [ ] Keep the request replayable; vary encoding, method or identifier location only after the first result.
- [ ] Capture the full request and response for the winning attempt, including the flag.

### Prove

- [ ] Capture the flag and name the exact foreign object, role or state change it proves.
- [ ] Repeat from a clean session and confirm the result is not cached or stale.
- [ ] State impact precisely: what data or action did you actually obtain?

### Explain

- [ ] State the root cause without naming the payload: which decision failed?
- [ ] Name the control that prevents recurrence and the layer where it belongs.
- [ ] Write one regression test that fails before the fix and passes after it.

## Evidence

### Target and baseline

_Not recorded._

### Hypothesis

_Not recorded._

### Winning request

_Not recorded._

### Proof

_Not recorded._

### Root cause

_Not recorded._

### Control and regression test

_Not recorded._

## Analyst conclusion

The proof demonstrates the missing control above. The regression test should fail against the vulnerable behavior and pass after remediation.
Solution and debrief
Locked until you capture the flag.

The full request, the reasoning and the debrief unlock after a successful capture. That is deliberate: struggle first, then consolidate.

What a reviewer will ask

False positives to rule out

  • The Host header is reflected in a debug page: reflection is not takeover; check whether it reaches a reset link, redirect or cache.
  • The proxy rejects an unknown Host: test X-Forwarded-Host and alternate casing if the origin trusts it.
  • The reset link uses a relative path: that is safer; look for redirects or email templates that absolutize it later.

Regression tests to name

  • Reset link: The email link still points to the canonical domain
  • Forwarded host: The edge strips or overwrites it before the origin
  • OAuth redirect: The registered redirect URI is unchanged
The defender's move
  • Allowlist accepted hostnames and build absolute URLs from configuration.
  • Do not trust forwarded host headers from untrusted clients.
  • Route virtual hosts from a validated server name.
See the secure-code pattern and all 4 regression tests →
الخلاصة

الهوست ليس مجرد عنوان؛ إنه ادعاء يجب التحقق منه.