Summary
Sub2API versions prior to 0.1.85 contain a password reset poisoning vulnerability where untrusted Host/Forwarded headers are used to build password reset links.
An attacker who can trigger a password reset email can inject their own domain into the reset URL, potentially luring users to attacker-controlled pages and facilitating account takeover.
Affected context
The vulnerability occurs in Sub2API's password reset flow, specifically in environments where:
- The application constructs absolute URLs for password reset emails using request headers (Host, X-Forwarded-Host, X-Forwarded-Proto, etc.)
- Reverse proxies, load balancers, or CDNs may pass client-controlled header values through to the application
- The application does not strictly validate or override these header values with a trusted application base URL
Under these conditions, password reset links generated by the system can contain attacker-supplied domains.
Exploit preconditions
- Attack surface: Public-facing password reset ("forgot password") endpoint of the Sub2API web interface or API.
- Required access: Ability to submit a password reset request for a target account's email address (or a guessable/known account identifier), plus the ability to manipulate request headers in transit (e.g., direct HTTP client control, crafted requests through a proxy).
- Trigger point: The victim receiving and following a password reset email whose URL has been constructed using tainted Host/Forwarded header values supplied by the attacker.
- Why exploitation is possible: The application trusts Host/Forwarded-related headers as authoritative for generating external links without robust validation, canonicalization, or overriding them with a server-side configured base URL. This leads to output encoding and validation failures aligned with CWE-116, where untrusted input is not properly constrained before being embedded into security-sensitive URLs.
Why this happens
At its core, this issue stems from improper handling and validation of HTTP header values used to construct external links.
The application relies on request-scoped host and scheme information (Host, X-Forwarded-Host, X-Forwarded-Proto, and similar headers) that can be influenced by the client or intermediary infrastructure, instead of using a fixed, server-side trusted origin.
This behavior maps to CWE-116: Improper Encoding or Escaping of Output, as untrusted header values are incorporated into security-critical output (password reset links) without adequate sanitization, normalization, or restriction to an allowed set of domains.
Abstractly, the pattern is:
- Take untrusted header input
- Treat it as a trusted origin/base URL
- Embed it into an email used for authentication-sensitive operations (password resetting)
This insecure pattern enables attackers to craft emails where the target URL appears legitimate but actually directs users to attacker-controlled infrastructure, enabling credential theft or abuse of tokens.
Potential impact
- Attackers may craft password reset emails that direct users to attacker-controlled domains.
- Victims can be tricked into submitting new passwords or credentials on a phishing page.
- Attackers could capture reset tokens or session data and use them to take over accounts.
- Users may lose control of Sub2API accounts and associated API subscription management.
- Exposure of sensitive configuration or subscription information managed through compromised accounts.
- Reputational damage due to successful phishing campaigns leveraging legitimate-looking reset emails.
General mitigation guidance
Effective mitigation focuses on eliminating trust in client-controlled header values for constructing security-sensitive links and enforcing a single, trusted application origin:
- Configure the application to use a statically defined base URL (scheme, host, and port) for all password reset links, independent of incoming request headers.
- Implement strict allowlisting of acceptable hosts if dynamic host resolution is absolutely required; reject or ignore any Host/Forwarded values not on the allowlist.
- Strip or normalize proxy-related headers at the edge (reverse proxy/load balancer), and pass only vetted, canonical host/scheme information to the application layer.
- Treat password reset URLs as security-critical output: ensure they are generated server-side and are not influenced by user input or request metadata beyond a minimal, validated set.
- Apply least-privilege and defense-in-depth around password reset flows (short-lived tokens, single-use tokens, IP/device anomaly checks, and strong monitoring of reset requests).
- As an operational fallback, temporarily disabling the "forgot password" flow can prevent exploitation when secure configuration changes or code fixes cannot be immediately deployed.
How teams detect issues like this
Detection strategies should aim to identify both the vulnerable code patterns and potential abuse in production:
- Static analysis and code review:
- Flag uses of request headers such as
Host,X-Forwarded-Host,X-Forwarded-Proto, or generic forwarding headers when they are used to construct absolute URLs, especially in authentication and password reset flows. - Review URL-building utilities to confirm whether they derive origin information from untrusted request data rather than a configuration constant.
- Establish review checklists requiring that all password reset links and similar flows use a fixed base URL.
- Configuration and policy enforcement:
- Enforce proxy policies where edge components sanitize or overwrite upstream Host/Forwarded headers with trusted values.
- Integrate security checks in CI/CD to search for patterns like
request.host,request.headers['Host'], or similar in email or token generation paths.
- Runtime and log analysis:
- Monitor logs of password reset events for anomalous domains or schemes in generated links (where logged).
- Detect unusual spikes in password reset requests from single IPs, user agents, or regions, which may indicate automated exploitation attempts.
- Automated tools:
- Use application security scanners that test password reset flows for host header injection and misconfigured origin handling.
- Integrate specialized tests into QA that send crafted Host/Forwarded headers and verify that the resulting links always use the canonical domain.

