/

CVE-2026-12740

Severity:

HIGH RISK

(8.1)

OAuth CSRF (CWE-352) in Plack::Middleware::OAuth

CVE-2026-12740

Deferred

Vulnerability type

Category:

Cross-Site Request Forgery (CSRF)

CWE:

CWE-352

Impact:

Account Linking and Authentication Hijack

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

Plack::Middleware::OAuth through version 0.10 fails to bind OAuth 2.0 callback responses to the originating user session due to missing state parameter support.

As a result, attackers can perform login cross-site request forgery, causing a victim's session to be linked to the attacker's identity and access token whenever the victim processes a crafted OAuth callback.

Affected context

This vulnerability affects Perl applications that integrate OAuth 2.0 login using Plack::Middleware::OAuth's RequestTokenV2 and AccessTokenV2 flows.

It becomes relevant when the application relies on this middleware to initiate and complete provider logins, but does not add its own state parameter handling or callback correlation.

Environments where provider tokens or identities are persisted as account links are especially exposed, since incorrect associations can outlive the current session.

Exploit preconditions

  • Attack surface: OAuth 2.0 authorization endpoints and redirect/callback URLs exposed by the application.
  • Required access: Ability to initiate an OAuth login with the provider using the attacker's own account, and to induce the victim's browser to follow the resulting callback URL (e.g., via links, redirects, or embedded content).
  • Trigger point: The victim's browser requests the OAuth callback endpoint carrying a valid authorization code obtained by the attacker, which the middleware accepts without session correlation.
  • Why exploitation is possible: The middleware constructs OAuth authorization requests without a state parameter and processes callbacks without verifying that they correspond to the session that initiated the flow, so any valid code can be bound to any active session.

Why this happens

The underlying flaw is a missing anti-CSRF mechanism in the OAuth 2.0 login flow, mapping to CWE-352: Cross-Site Request Forgery.

RequestTokenV2 builds the provider redirect URL without a state value, and AccessTokenV2 exchanges the callback code for an access token and stores it in the session without verifying that this callback is tied to a specific, prior authorization request from that session.

This insecure pattern treats any successful OAuth callback as trustworthy, ignoring the need to bind the callback to the user's session and the original request, leaving the flow open to login CSRF and account-linking attacks.

Potential impact

  • Victim sessions may be associated with an attacker's OAuth provider identity.
  • Applications could incorrectly link victim accounts to attacker-owned provider accounts.
  • Attackers can retain ongoing access to victim accounts via their own provider credentials.
  • Audit trails and identity logs can be polluted with inaccurate user associations.
  • Downstream services relying on provider tokens may expose victim data to the attacker.

General mitigation guidance

Defenses typically focus on binding OAuth authorization flows tightly to user sessions and enforcing anti-CSRF protections.

Common patterns include:

  • Generating a cryptographically strong, per-request state value and storing it in the user's session before redirecting to the provider.
  • Including the state parameter in the provider authorization request and validating it on callback, rejecting any mismatch or missing value.
  • Ensuring that any access token or identity obtained on callback is only registered to the session that initiated the corresponding authorization request.
  • Designing account-linking logic to require explicit user action in the correct session context, rather than auto-linking on any successful callback.
  • Reducing trust in external identity assertions by layering additional application-side checks (e.g., step-up verification) before finalizing account association.

How teams detect issues like this

Detection efforts can focus on both code-level and behavioral indicators of insecure OAuth flows.

Potential approaches include:

  • Static analysis rules that flag OAuth middleware or custom OAuth code that omits state parameter generation and validation.
  • Code review checklists that explicitly require examination of authorization request construction and callback handling, looking for session-bound correlation.
  • Security testing and automated integration tests that attempt to reuse authorization codes across different sessions to see if callbacks are incorrectly accepted.
  • Policy enforcement in CI/CD pipelines requiring standard OAuth flow helpers or frameworks that implement state and CSRF protections by default.
  • Runtime monitoring for unusual patterns, such as frequent account links or logins completed from callbacks not preceded by session-specific initiation events.

Sources

SourceLink
datatracker.ietf.orgdatatracker.ietf.org/doc/html/rfc6749#section-10.12
github.comgithub.com/c9s/Plack-Middleware-OAuth/pull/13
rt.cpan.orgrt.cpan.org/Ticket/Display.html?id=179874
security.metacpan.orgsecurity.metacpan.org/patches/P/Plack-Middleware-OAuth/0.10/CVE-2026-12740-r1.patch
openwall.comopenwall.com/lists/oss-security/2026/07/04/10

Frequently asked

questions

It primarily affects OAuth-based login and account linking, but wherever access tokens are used to grant broader resource access, misbinding those tokens to the wrong session can extend the impact to authorization and data exposure.

An attacker needs an account with the OAuth provider and the ability to cause a victim's browser to visit a crafted callback URL. Direct server access is not required; typical web delivery mechanisms such as links, redirects, or hidden requests can be sufficient.

Implement a robust state parameter mechanism: generate a unique state value per authorization request, store it in the session, include it in the provider redirect, and validate it on callback before exchanging codes or registering tokens. Additionally, tie any resulting token or identity to the initiating session and require explicit confirmation for persistent account linking.

Use well-reviewed OAuth libraries or frameworks that implement state validation and CSRF protections by default, establish security-focused coding standards for authentication flows, and incorporate regular security reviews and automated tests that specifically probe login and account-link workflows for misbinding and CSRF vulnerabilities.

Find out what's already
exploitable in your codebase.