/

CVE-2026-12746

Severity:

HIGH RISK

(8.1)

OAuth CSRF (CWE-352) in Dancer2 OAuth Provider Plugin

CVE-2026-12746

Deferred

Vulnerability type

Category:

Cross-Site Request Forgery

CWE:

CWE-352

Impact:

Authentication Session Compromise and Account Linking Abuse

Severity:

HIGH RISK

(8.1)

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

Dancer2::Plugin::Auth::OAuth::Provider before version 0.23 omits the OAuth 2.0 state parameter and does not verify that the callback matches a session-initiated authorization request.

As a result, an attacker can complete login CSRF by injecting their own OAuth provider identity into a victim's session, potentially persisting long-term account linkage and access.

Affected context

This vulnerability appears in Perl applications that use Dancer2::Plugin::Auth::OAuth::Provider for OAuth 2.0 login flows and rely on its default redirect and callback handling.

It becomes relevant where the plugin is responsible for constructing the authorization URL, managing callback handling, and storing tokens or identity links in a session or persistent account store.

Risk is elevated when applications bind provider identities to local accounts or use received provider tokens for ongoing access without additional verification of the login flow integrity.

Exploit preconditions

  • Attack surface: Web-based OAuth login endpoint and its associated callback URL.
  • Required access: Ability to initiate an OAuth 2.0 authorization with the provider (using the attacker's own account) and then cause a victim's browser to follow the resulting callback URL (e.g., via link, redirect, or injected request).
  • Trigger point: The victim's browser visits the crafted OAuth callback URL, allowing the plugin to exchange the code and store the attacker's token and identity in the victim's session.
  • Why exploitation is possible: The plugin does not issue or validate a state parameter, and the callback handler is not bound to the session that started the authorization, so it accepts any valid provider code as if the current session initiated it.

Why this happens

The underlying flaw stems from incomplete implementation of the OAuth 2.0 authorization flow's CSRF protections.

The plugin's authentication_url method constructs the provider authorization redirect without generating a unique state value tied to the initiating session, while the callback method exchanges the authorization code and commits the resulting token or identity into the current session without validating that the callback relates to a session-bound request.

This maps to CWE-352: Cross-Site Request Forgery (CSRF) where a web application performs security-sensitive actions based solely on a user's authenticated context, without verifying that the request originated from a genuine workflow initiated by that user.

Potential impact

  • An attacker's OAuth provider identity may be linked to the victim's account, causing misattribution of identity and access.
  • The attacker can retain ongoing access to the victim's account via their own provider credentials where account linkage is persistent.
  • Sensitive actions gated by provider login can be performed under the victim's session using the attacker's provider account.
  • Integrity of account ownership and audit trails can be compromised through unauthorized identity association.

General mitigation guidance

Effective mitigation focuses on binding OAuth authorization requests to user sessions and validating callbacks accordingly.

Common defensive patterns include:

  • Generating a cryptographically strong, per-request state value stored server-side in the user's session and including it in the authorization redirect.
  • Verifying the state parameter on the callback and rejecting any callback missing, mismatching, or replayed state values.
  • Treating OAuth callbacks as sensitive state-changing operations and enforcing explicit flow validation rather than accepting any valid provider code.
  • Limiting persistence of provider identity linkage and access tokens until after the login flow is verified and the session is confirmed as the rightful initiator.
  • Applying least-privilege use of provider tokens and minimizing long-lived bindings to reduce impact if a flow is compromised.

How teams detect issues like this

High-level detection approaches often involve reviewing OAuth integration patterns and state management:

  • Static analysis or manual code review checks that OAuth 2.0 flows generate a state parameter and that callbacks validate it against session data before token exchange.
  • Policy-based enforcement in code review requiring binding of external authentication flows to user sessions and rejecting callbacks that cannot be correlated to a prior request.
  • Logging and monitoring of OAuth callbacks with correlation identifiers to spot anomalous patterns, such as callbacks arriving without corresponding authorization requests in session history.
  • Automated tooling or linters that flag OAuth integrations lacking CSRF protection mechanisms, including absent state parameter handling or missing session correlation.

Sources

SourceLink
datatracker.ietf.orgdatatracker.ietf.org/doc/html/rfc6749#section-10.12
github.comgithub.com/biafra/perl-Dancer2-Plugin-Auth-OAuth/commit/806420fc2abbe13bede4461475f2f3dcd7daf5f2.patch
metacpan.orgmetacpan.org/release/BIAFRA/Dancer2-Plugin-Auth-OAuth-0.23/diff/BIAFRA/Dancer2-Plugin-Auth-OAuth-0.22
openwall.comopenwall.com/lists/oss-security/2026/07/04/9

Frequently asked

questions

Yes. An attacker can remotely initiate an OAuth authorization with their own provider account and then deliver the resulting callback URL to a victim's browser, causing the victim's session to accept the attacker's identity and token.

The attacker must be able to create or use a valid provider account and cause the victim's browser to follow a crafted callback URL while the victim is authenticated to the vulnerable application. No direct access to the application server is required.

Introduce robust state handling in the OAuth flow: generate a per-request state token associated with the user's session, include it in the authorization URL, and strictly validate it on the callback before exchanging codes or linking identities. Reject any callback that cannot be correlated to an initiated session-bound request.

Treat all external authentication flows as CSRF-sensitive, rely on well-tested OAuth libraries that fully implement state and callback validation, enforce security guidelines in code review, and document requirements that any OAuth integration must bind authorization requests to sessions with explicit state verification before persisting tokens or identity links.

Find out what's already
exploitable in your codebase.