Summary
Grav's API plugin before version 1.0.4 improperly trusts a client-supplied admin_base_url when generating password reset links, only validating the scheme but not the host.
This allows an unauthenticated attacker to inject a malicious reset URL pointing to their own server, capture the valid reset token when a victim clicks the email link, and subsequently take over the victim's account.
Affected context
This vulnerability occurs in Grav installations that:
- Use the Grav API plugin (grav-plugin-api) with versions prior to 1.0.4
- Expose the
/api/v1/auth/forgot-passwordendpoint for password recovery - Construct password reset URLs based on client-controllable inputs such as
admin_base_url,Referer, orOrigin
In these conditions, the service may embed attacker-provided hosts in password reset emails without verifying they match the legitimate application origin.
Exploit preconditions
- Attack surface: Public-facing password reset endpoint (
POST /api/v1/auth/forgot-password) - Required access: No authentication required; attacker only needs the victim's account identifier (e.g., email or username)
- Trigger point: Initiating a password reset while supplying a crafted
admin_base_urlor leveraging manipulatedReferer/Originheaders - Why exploitation is possible: The backend trusts and reuses client-provided URL components, validating only the scheme (http/https) and not ensuring the host matches the application's own origin, thus enabling redirect of the reset link to an attacker-controlled server.
Why this happens
The core issue is an origin validation failure in the password reset URL construction logic.
The sanitizeHttpUrl() function enforces that the URL scheme is HTTP or HTTPS but does not confirm that the host corresponds to the legitimate Grav instance or a whitelisted domain.
This fits CWE-601: Open Redirect, where user-controllable data influences navigation targets or callback URLs used in security-sensitive flows, causing trusted emails or responses to direct users to attacker-controlled endpoints.
Potential impact
- An attacker can cause password reset emails to include links to an attacker-controlled domain.
- Attackers may capture valid password reset tokens when victims follow malicious links.
- Full account takeover of affected Grav admin or user accounts is possible once the token is obtained.
- Potential escalation into broader site compromise if administrative accounts are seized.
- Erosion of user trust due to phishing-like behavior originating from legitimate system emails.
General mitigation guidance
Effective mitigation centers on strict origin and URL validation in password reset flows and other security-sensitive redirects.
Common patterns include:
- Deriving password reset URLs exclusively from server-side configuration, not from client-supplied parameters or headers.
- Enforcing a whitelist of allowed hosts or an exact match to the application's canonical base URL when constructing links.
- Ignoring
RefererandOriginheaders for generating reset links, or validating them only for CSRF checks rather than as URL sources. - Separating untrusted presentation URLs from security-critical callback URLs, keeping the latter fully server-controlled.
- Limiting the exposure window and capabilities of reset tokens (short lifetimes, single-use tokens, and robust logging for anomalous reset activity).
How teams detect issues like this
Organizations can detect and prevent similar issues through:
- Static analysis rules that flag use of client-supplied values (query parameters, headers, body fields) in URL construction for authentication or password reset flows.
- Code review practices that scrutinize redirect targets, password reset links, and callback URLs for origin validation and server-side control.
- Security testing that attempts to manipulate parameters like
base_url,redirect,next, or related headers to influence outbound links in emails or responses. - Automated scanning tools configured to identify open redirect patterns and unvalidated redirect targets in web applications.
- Policy checks in CI/CD that enforce patterns such as "no user input in security-sensitive URLs without explicit validation/whitelisting."

