Skip to main content
Vulnerability Database/CVE-2026-49265

CVE-2026-49265: OAuthLib PKCE Authentication Bypass Vulnerability

CVE-2026-49265 is an authentication bypass flaw in OAuthLib's PKCE implementation that could allow attackers to recover code verifiers through timing analysis. This article covers technical details, affected versions, and mitigation.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-49265 Overview

CVE-2026-49265 is a timing side-channel vulnerability in OAuthLib, an implementation of the OAuth request-signing logic for Python 3.6+. The flaw affects versions 3.0.0 through 4.0.0 and resides in the Proof Key for Code Exchange (PKCE) verification logic in oauthlib/oauth2/rfc6749/grant_types/authorization_code.py. The library compares attacker-supplied code_verifier values against stored challenges using ordinary string equality within code_challenge_method_plain and code_challenge_method_s256. Because Python string comparison short-circuits on length mismatch or the first differing character, repeated token endpoint requests can leak common-prefix timing information. The weakness is tracked under CWE-208: Observable Timing Discrepancy.

Critical Impact

Successful recovery of a code_verifier could enable unauthorized access-token acquisition and account takeover, though exploitation requires an intercepted single-use authorization code and sufficient measurements to overcome network noise.

Affected Products

  • OAuthLib versions 3.0.0 through 3.3.1
  • Python applications using OAuthLib as an OAuth2 provider with PKCE enabled
  • Downstream frameworks bundling vulnerable OAuthLib (for example, Django OAuth Toolkit, Authlib-integrated stacks)

Discovery Timeline

  • 2026-10-13 - CVE-2026-49265 published to NVD
  • 2026-10-13 - Last updated in NVD database
  • Fix release - OAuthLib v4.0.0 published on GitHub Releases

Technical Details for CVE-2026-49265

Vulnerability Analysis

PKCE protects OAuth 2.0 authorization code flows from interception attacks by binding the authorization code to a cryptographic secret held by the client. The client sends a code_verifier at the token endpoint, which the authorization server compares against the previously stored code_challenge. In vulnerable OAuthLib releases, this comparison uses Python's native == operator. The operator exits early when string lengths differ or when the first mismatching byte is reached. An attacker measuring token endpoint response time across many requests can infer prefix matches character by character.

The maintainers acknowledge that practical remote exploitation is constrained by network jitter and the single-use nature of authorization codes. The vendor classifies the issue as a defense-in-depth hardening.

Root Cause

The root cause is the use of non-constant-time string equality for a security-sensitive comparison. The fix introduces Python's hmac module, which provides hmac.compare_digest for constant-time comparison. The patch is visible in the authorization code grant module header:

python
 """
 import base64
 import hashlib
+import hmac
 import json
 import logging

Source: OAuthLib commit 74664d3

Attack Vector

Exploitation requires an attacker to first intercept a valid, unused authorization code, for example through a malicious redirect, log exposure, or network capture. The attacker then issues repeated token exchange requests with crafted code_verifier candidates and measures response latency at the token endpoint. By correlating timing deltas with candidate prefixes, the attacker iteratively reconstructs the verifier. Successful recovery allows exchange of the intercepted authorization code for an access token.

The following CHANGELOG excerpt documents the vendor-provided remediation:

text
OAuth2.0 Provider:
* **Breaking**: Removed JSONP support from token revocation endpoint.
* Improved PKCE Nonce comparison

Source: OAuthLib commit 74664d3

Detect Identity Attacks the Moment Authentication Fails

Singularity™ Identity surfaces credential misuse, lateral movement, and privilege escalation in real time, so you can contain the breach before it spreads.

Stop Identity Attacks

Detection Methods for CVE-2026-49265

Indicators of Compromise

  • High volumes of failed token endpoint requests reusing the same client_id and authorization_code with varying code_verifier values
  • Repeated HTTP 400 invalid_grant responses from /oauth/token within short time windows from a single source
  • Unexpected successful token issuance following a burst of failed PKCE verifications

Detection Strategies

  • Instrument the OAuth2 token endpoint to log client_id, source IP, and PKCE verification outcome for correlation.
  • Alert on repeated code_verifier submissions for the same authorization code, which should normally be single-use.
  • Baseline normal token endpoint request rates per client and flag statistical deviations.

Monitoring Recommendations

  • Forward web server and application logs for OAuth endpoints into a centralized SIEM for retention and correlation.
  • Track the installed version of the oauthlib package across Python environments using software bill of materials (SBOM) tooling.
  • Monitor dependency manifests (requirements.txt, poetry.lock, Pipfile.lock) in CI pipelines for pinned versions below 4.0.0.

How to Mitigate CVE-2026-49265

Immediate Actions Required

  • Upgrade OAuthLib to version 4.0.0 or later across all production, staging, and development environments.
  • Audit downstream frameworks (Django OAuth Toolkit, Flask-OAuthlib, Authlib) and update any that bundle vulnerable OAuthLib releases.
  • Enforce short authorization code lifetimes and single-use semantics at the authorization server.

Patch Information

The issue is fixed in OAuthLib 4.0.0. The patch replaces the vulnerable == comparison in code_challenge_method_plain and code_challenge_method_s256 with hmac.compare_digest, which performs constant-time comparison. Review the GitHub Security Advisory GHSA-xpv3-w29h-x7cv and PyPA Advisory PYSEC-2026-4114 for the complete fix details and the pull request discussion.

Workarounds

  • Rate-limit token endpoint requests per client and per source IP to raise the cost of timing measurements.
  • Deploy a reverse proxy or WAF rule that blocks repeated token exchanges reusing the same authorization code.
  • Terminate token endpoint traffic behind randomized latency or load-balancing layers that reduce timing signal fidelity until patching completes.
bash
# Upgrade OAuthLib to the patched release
pip install --upgrade "oauthlib>=4.0.0"

# Verify installed version
python -c "import oauthlib; print(oauthlib.__version__)"

# Audit dependency tree for transitive vulnerable versions
pip list --format=columns | grep -i oauthlib
pip-audit

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.