Summary
Pigeon's registration and email verification flows construct verification URLs using the HTTP Host header without validation, allowing an attacker to inject a malicious domain into verification links.
If a victim follows a verification email that points to an attacker-controlled domain, the attacker can steal the verification token and potentially take over the victim's account.
Affected context
This vulnerability appears in Pigeon deployments that:
- Build absolute email verification URLs using
$_SERVER['HTTP_HOST'](or equivalent host data) directly - Do not validate or canonicalize the Host header against an expected application domain
- Send these URLs to users during registration or when resending verification mail
It is most relevant where the application is reachable through untrusted networks or via reverse proxies that forward user-controlled Host headers.
Exploit preconditions
- Attack surface: Public web endpoints handling registration and email verification (e.g.,
/register,/resendmail) - Required access: Ability to send crafted HTTP requests with a manipulated
Hostheader; no prior authentication is typically required - Trigger point: The moment the application constructs an absolute email verification link using
$_SERVER['HTTP_HOST']and sends it to the user's email address - Why exploitation is possible: The application treats the Host header as a trusted source of canonical domain information, without validation or restriction, enabling an attacker to inject an arbitrary domain into application-generated links.
Why this happens
The root cause is unvalidated use of the HTTP Host header to construct security-sensitive URLs, such as email verification links.
By directly interpolating $_SERVER['HTTP_HOST'] into the URL template, the application allows user-controlled data to influence the structure and destination of generated links.
This maps to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component, where downstream components (email clients, browsers, and the verification endpoint) consume attacker-influenced URLs.
The bug is conceptual: the server implicitly trusts an input channel (Host header) that is meant for routing, not for constructing authoritative URLs, creating an injection point for phishing and token theft.
Potential impact
- Users may be redirected to attacker-controlled domains when clicking verification links.
- Attackers could capture email verification tokens and use them to complete registration flows on behalf of victims.
- Successful exploitation can lead to account takeover, especially for newly registered accounts.
- Users' trust in application emails and domains can be undermined, enabling broader phishing and social engineering.
- In multi-tenant or proxied environments, misrouting of verification flows and logging confusion can occur.
General mitigation guidance
Effective mitigation involves decoupling security-sensitive URL construction from user-controlled headers and enforcing strict domain validation:
- Use a configured, canonical application base URL (from environment variables or configuration files) instead of
$_SERVER['HTTP_HOST']when generating absolute links. - Enforce whitelisting or exact matching of the effective host against known, allowed domains if host information must be derived from the request.
- Centralize URL generation in a helper routine that always uses trusted configuration and cannot be influenced by the incoming Host header.
- Where reverse proxies or load balancers are involved, ensure clear trust boundaries and avoid passing raw Host headers directly into application logic.
- Treat all request headers, including Host and X-Forwarded-* headers, as untrusted input and avoid using them in authentication, verification, or password reset flows without strong validation.
These patterns reduce the risk that attacker-controlled headers can affect verification, reset, or sign-in links.
How teams detect issues like this
Detection can focus on both code-level signals and runtime behavior:
- Static analysis patterns:
- Flag uses of
$_SERVER['HTTP_HOST'],Hostheader, or framework-specific host accessors in code paths that generate absolute URLs for verification, password reset, or login links. - Identify URL-building utilities that concatenate raw request header values into links sent via email or other out-of-band channels.
- Code review signals:
- Look for direct string concatenation or templating where the host portion of a URL is not sourced from configuration.
- Review registration, verification, and password reset handlers for assumptions that the Host header is trustworthy.
- Check for missing domain whitelisting or validation in functions that depend on the notion of "site URL" or "base URL".
- Policy and automated enforcement:
- Establish guidelines that mandate a single, configuration-driven base URL for all security-related links.
- Use automated code-scanning tools or linters to flag reliance on request headers for canonical URLs.
- Log suspicious patterns such as frequent requests with mismatched Host headers and monitor them to identify potential exploitation attempts.

