/

CVE-2026-53513

Severity:

CRITICAL RISK

(9.6)

SSRF and OIDC Trust Flaws (CWE-918) in Better Auth

CVE-2026-53513

Analyzed

Vulnerability type

Category:

Server-Side Request Forgery (SSRF) and OIDC Misconfiguration

CWE:

CWE-20, CWE-345, CWE-441, CWE-918

Impact:

Server-Side Request Forgery and Account Hijacking

Severity:

CRITICAL RISK

(9.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Better Auth's SSO plugin allows attacker-controlled OIDC endpoints to be stored and later used without proper origin validation when discovery is skipped.

Under these conditions, an attacker can trigger non-blind server-side request forgery (SSRF) and may cause unintended account linking when email verification is implicitly trusted.

Affected context

This vulnerability affects applications using the @better-auth/sso plugin with custom OIDC configuration where skipDiscovery: true is enabled.

In this mode, the application accepts userInfo, token, and JWKS endpoint URLs from request data and stores them as part of the SSO provider configuration without validating their origin or trustworthiness.

The risk materializes during OIDC callbacks, when the server later fetches these attacker-supplied endpoints and, if trustEmailVerified: true is also configured, may implicitly trust identity assertions tied to those responses.

Exploit preconditions

  • Attack surface: HTTP API endpoints POST /sso/register and POST /sso/update-provider exposed by the Better Auth SSO integration.
  • Required access: Ability to call these endpoints with crafted OIDC configuration parameters (e.g., as an authenticated integrator or any role allowed to register/update SSO providers).
  • Trigger point: An OIDC login or callback flow that causes the server to request userInfoEndpoint, tokenEndpoint, and jwksEndpoint URLs that were previously controlled by the attacker.
  • Why exploitation is possible: The implementation stores attacker-supplied endpoint URLs when skipDiscovery: true is set and does not enforce origin validation or trust checks prior to making server-side requests or accepting identity data, enabling SSRF and potentially abusive account linking when emails are auto-trusted.

Why this happens

The underlying issue is a combination of insufficient input validation and weak trust establishment in an authentication integration flow.

Instead of deriving OIDC endpoints from a well-known discovery document or a vetted configuration, the system accepts arbitrary URLs for userInfo, token, and JWKS endpoints whenever skipDiscovery: true is used.

These unvalidated URLs are then persisted and invoked server-side as part of the OIDC callback, mapping to CWE-918: Server-Side Request Forgery, since the server becomes a proxy to arbitrary locations chosen by the attacker.

Additionally, the flow implicitly trusts identity information provided by those endpoints, reflecting CWE-345: Insufficient Verification of Data Authenticity and CWE-441: Unintended Proxy or Intermediary, while the initial lack of robust checks on the configuration inputs is consistent with CWE-20: Improper Input Validation.

Potential impact

  • Non-blind SSRF that can be used to reach internal or restricted network services from the authentication server.
  • Exfiltration or probing of internal HTTP endpoints, potentially aiding lateral movement or reconnaissance.
  • Malicious OIDC responses that can be accepted as legitimate when trustEmailVerified: true is configured.
  • Unintended account linking or account takeover scenarios if a victim's account is bound to identities controlled by the attacker.
  • Bypass of expected trust boundaries between external SSO providers and the application's internal network.

General mitigation guidance

Effective mitigation focuses on treating SSO/OIDC configuration as highly sensitive and strictly validated input.

Common defensive patterns include:

  • Enforcing strong origin validation on OIDC endpoints, limiting them to allowed domains or pre-approved providers, especially when manual configuration (skip discovery) is used.
  • Preferring standardized discovery documents from trusted issuers rather than accepting arbitrary endpoint URLs from requests.
  • Introducing URL safety checks (e.g., blocking private IP ranges, localhost, link-local addresses, and non-HTTP(S) schemes) before storing or using any remote endpoint in server-side calls.
  • Requiring explicit administrative workflows for registering or updating SSO providers, with additional review or out-of-band approval for any endpoint changes.
  • Avoiding blanket trust of email_verified or similar flags from untrusted issuers; instead, couple them with strong issuer validation and key verification.
  • Applying the principle of least privilege to the network environment, such as egress filtering and network segmentation, so that even if SSRF is triggered, access to sensitive internal services is minimized.

How teams detect issues like this

Organizations can detect and monitor for this class of vulnerability through a mix of code- and configuration-focused approaches:

  • Static analysis and code review: Flag any code paths that accept arbitrary URLs for security-sensitive endpoints (token, userInfo, JWKS) and subsequently make server-side HTTP requests to them. Look for conditions where discovery is skipped or issuer verification is relaxed.
  • Configuration review: Periodically audit stored SSO provider records to ensure endpoints match known issuers and do not point to internal IP ranges, localhost, or unexpected domains.
  • Network-level monitoring: Use outbound traffic monitoring and egress controls to detect unusual HTTP requests from authentication components to internal services or unfamiliar external hosts.
  • Automated security testing: Incorporate SSRF-focused tests into CI/CD pipelines, including negative tests that attempt to set internal or loopback endpoints for OIDC configuration and confirm they are rejected.
  • Runtime alerts: Configure logging and alerting for changes to SSO provider configuration and for OIDC flows that reference non-approved issuers or endpoints.

Sources

SourceLink
github.comgithub.com/better-auth/better-auth/commit/37f60cb176cb53147da7dfd5ec15afa5b486e81e
github.comgithub.com/better-auth/better-auth/pull/9574
github.comgithub.com/better-auth/better-auth/releases/tag/v1.6.11
github.comgithub.com/better-auth/better-auth/security/advisories/GHSA-5rr4-8452-hf4v

Frequently asked

questions

Yes, it can be remotely exploitable if the affected SSO registration or update endpoints are exposed to clients that can submit custom OIDC configuration. Once a malicious configuration is stored, subsequent OIDC flows can trigger SSRF and identity abuse without further user interaction.

The attacker must be able to call POST /sso/register or POST /sso/update-provider with crafted parameters, in an environment where skipDiscovery: true is allowed. In some deployments this may require administrative or integrator-level permissions; in others, misconfigured access control could expose these endpoints more broadly.

The safest pattern is to prohibit arbitrary endpoint configuration for OIDC providers and instead rely on discovery from trusted issuers or a curated list of allowed endpoints. Any manual configuration path should enforce strict origin and URL validation, combined with robust issuer and key verification before accepting identity data.

Design authentication and SSO features around explicit trust boundaries: never treat user-supplied URLs as trusted infrastructure, always validate issuers and endpoints against allowlists, and apply network-level defenses against SSRF. Incorporate security reviews for any feature that makes server-side HTTP requests based on configurable URLs, and encode these expectations into automated tests and static analysis rules.

Find out what's already
exploitable in your codebase.