ghsa-8jhw-6pjj-8723
Vulnerability from github
Published
2024-12-30 16:49
Modified
2024-12-30 18:45
Summary
Better Auth has an Open Redirect Vulnerability in Verify Email Endpoint
Details

Summary

An open redirect vulnerability has been identified in the verify email endpoint of Better Auth, potentially allowing attackers to redirect users to malicious websites. This issue affects users relying on email verification links generated by the library.

Affected Versions

  • All versions prior to v1.1.6.

Impact

Attackers could craft malicious email verification links that exploit the redirect functionality to send users to untrusted domains. This can result in:

  • Phishing attacks – Users may unknowingly enter sensitive information on fake login pages.
  • Reputation damage – Trust issues for applications using Better Auth.

Vulnerability Details

The verify email callback endpoint accepts a callbackURL parameter. Unlike other verification methods, email verification only uses JWT to verify and redirect without proper validation of the target domain. The origin checker is bypassed in this scenario because it only checks for POST requests. An attacker can manipulate this parameter to redirect users to arbitrary URLs controlled by the attacker.

Example Exploit: https://example.com/auth/verify-email?token=abcd1234&callbackURL=https://malicious-site.com

Patches

Upgrade to Better Auth v1.1.6 or later. This version enforces domain validation for callbackURL for /verify-email path and for all other GET endpoints.

Workarounds

You can also use hooks to pre-check URLs in your auth instance to prevent this without upgrading:

ts const auth = betterAuth({ hooks: { before: (ctx) => { if (ctx.path === "/verify-email") { const callbackURL = ctx.query.callbackURL; // Check if this is a trusted callback URL or not } } } })

Show details on source website


{
  "affected": [
    {
      "package": {
        "ecosystem": "npm",
        "name": "better-auth"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "1.1.6"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2024-56734"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-601"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2024-12-30T16:49:12Z",
    "nvd_published_at": "2024-12-30T17:15:10Z",
    "severity": "HIGH"
  },
  "details": "## Summary\nAn **open redirect vulnerability** has been identified in the **verify email endpoint** of Better Auth, potentially allowing attackers to redirect users to malicious websites. This issue affects users relying on email verification links generated by the library.\n\n## Affected Versions\n- All versions prior to **v1.1.6**.\n\n## Impact\nAttackers could craft malicious email verification links that exploit the redirect functionality to send users to untrusted domains. This can result in:\n\n- **Phishing attacks** \u2013 Users may unknowingly enter sensitive information on fake login pages.\n- **Reputation damage** \u2013 Trust issues for applications using Better Auth.\n\n## Vulnerability Details\nThe verify email callback endpoint accepts a `callbackURL` parameter. Unlike other verification methods, email verification only uses JWT to verify and redirect without proper validation of the target domain. The origin checker is bypassed in this scenario because it only checks for `POST` requests. An attacker can manipulate this parameter to redirect users to arbitrary URLs controlled by the attacker.\n\n**Example Exploit:**\n```\nhttps://example.com/auth/verify-email?token=abcd1234\u0026callbackURL=https://malicious-site.com\n```\n\n## Patches\nUpgrade to Better Auth **v1.1.6** or later. This version enforces domain validation for `callbackURL` for `/verify-email` path and for all other `GET` endpoints.\n\n## Workarounds\nYou can also use hooks to pre-check URLs in your auth instance to prevent this without upgrading:\n\n```ts\nconst auth = betterAuth({\n    hooks: {\n         before: (ctx) =\u003e {\n            if (ctx.path === \"/verify-email\") {\n               const callbackURL = ctx.query.callbackURL; // Check if this is a trusted callback URL or not\n            }\n         }\n    }\n})\n```",
  "id": "GHSA-8jhw-6pjj-8723",
  "modified": "2024-12-30T18:45:17Z",
  "published": "2024-12-30T16:49:12Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/better-auth/better-auth/security/advisories/GHSA-8jhw-6pjj-8723"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-56734"
    },
    {
      "type": "WEB",
      "url": "https://github.com/better-auth/better-auth/commit/deb3d73aea90d0468d92723f4511542b593e522f"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/better-auth/better-auth"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:H/SI:H/SA:H",
      "type": "CVSS_V4"
    }
  ],
  "summary": "Better Auth has an Open Redirect Vulnerability in Verify Email Endpoint"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.


Loading…