Packages / better-auth / Security
Beter Auth has an Open Redirect via Scheme-Less Callback Parameter
Affected releases · better-auth
- 1.x1.0.0 – 1.1.19Fixed in 1.1.20
- 0.8.x and older0.0.1 – 0.8.8No fix, no longer updated
On 1.x, the newest line:
npm install better-auth@1.1.20Affected
1.0.0 – 1.1.19
42 releases
Fixed
1.1.20 – 1.7.12
127 releases, latest
Affected
0.0.1 – 0.8.8
61 releases
Is your project affected?
Paste your package.json, or type the range you declare for better-auth. It is read in your browser and sent nowhere.
What happens
Summary
The application is vulnerable to an open redirect due to improper validation of the callbackURL parameter in the email verification endpoint and any other endpoint that accepts callback url. While the server blocks fully qualified URLs (e.g., evil.com), it incorrectly allows scheme-less URLs (e.g., //malicious-site.com). This results in the browser interpreting the URL as malicious-site.com, leading to unintended redirection.
bypass for : github.com/better-auth/better-auth/security/adv…
Affected Versions
All versions prior to 1.1.19
Details
The application’s email verification endpoint (/auth/verify-email) accepts a callbackURL parameter intended to redirect users after successful email verification. While the server correctly blocks fully qualified external URLs (e.g., evil.com), it improperly allows scheme-less URLs (e.g., //malicious-site.com). This issue occurs because browsers interpret //malicious-site.com as malicious-site.com, leading to an open redirect vulnerability.
An attacker can exploit this flaw by crafting a malicious verification link and tricking users into clicking it. Upon successful email verification, the user will be automatically redirected to the attacker's website, which can be used for phishing, malware distribution, or stealing sensitive authentication tokens.
Impact
Phishing & Credential Theft – Attackers can redirect users to a fake login page, tricking them into entering sensitive credentials, which can then be stolen.
Session Hijacking & Token Theft – If used in OAuth flows, an attacker could redirect authentication tokens to their own domain, leading to account takeover.