Summary
2FAuth can trust authentication headers supplied by a client when the reverse-proxy guard is enabled, even if the request did not pass through a trusted proxy. An unauthenticated remote client may create an administrator account on a fresh instance or impersonate a known account, potentially exposing 2FA secrets and administrative functions.
Affected context
The issue affects 2FAuth deployments using AUTHENTICATION_GUARD=reverse-proxy-guard when client-supplied authentication headers can reach the application without being validated by a trusted proxy. During identity lookup, an unknown REMOTE_USER may lead to account creation, with the first created account receiving administrator privileges. The configured mail header may also be used to synchronize an account's email address.
Exploit preconditions
- Attack surface: The web application's reverse-proxy authentication flow
- Required access: No prior authentication is required if an untrusted client can reach the application with accepted authentication headers
- Trigger point: Identity lookup through
RemoteUserProvider::retrieveById() - Why exploitation is possible: The application may accept identity and email headers without confirming that the request passed through a trusted proxy
- Relevant configuration:
AUTHENTICATION_GUARD=reverse-proxy-guard
Why this happens
The application treats proxy-provided identity headers as trustworthy without reliably establishing that they were added or validated by a trusted proxy. This can allow an unauthenticated client to influence account lookup and creation. Promoting the first created account to administrator and synchronizing email from a configured header increase the impact. This is an authentication failure mapped to CWE-287: Improper Authentication.
Potential impact
- An attacker may create an administrator account on a fresh instance.
- An attacker could impersonate a known account and redirect its email address.
- Unauthorized access may expose 2FA secrets and administrative functions.
- Changes made through an administrative account could affect other users or application data.
General mitigation guidance
Defensive patterns focus on establishing a clear trust boundary between the proxy and application:
- Accept identity headers only from explicitly trusted proxy connections.
- Configure the proxy to remove client-supplied identity headers and set its own authenticated values.
- Prefer application-managed authentication when proxy identity cannot be securely verified.
- Avoid automatically granting administrator privileges based solely on account creation order.
- Validate and constrain identity and email values before creating or updating accounts.
- Apply least privilege to application accounts and restrict direct network access to the application where practical.
How teams detect issues like this
Review authentication configuration and request paths to determine whether clients can reach the application without passing through a trusted proxy. Static analysis and code review can look for identity providers that trust request headers, create accounts during identity lookup, or assign elevated roles automatically. Monitor for unexpected account creation, new administrator assignments, and email changes, and use deployment policies to restrict which services may connect to the application. Automated code review tools may help identify header-based authentication trust patterns.

