VAITP Dataset

← Back to the dataset

CVE-2026-49265

Timing leak in OAuthLib PKCE verification allows code_verifier inference.

  • CVSS 6.8
  • CWE-208
  • Information Leakage
  • Remote

OAuthLib is an implementation of the OAuth request-signing logic for Python 3.6+. From 3.0.0 until 4.0.0, OAuthLib's PKCE checks in oauthlib/oauth2/rfc6749/grant_types/authorization_code.py compare attacker-supplied code_verifier values with stored challenges using ordinary string equality in code_challenge_method_plain and code_challenge_method_s256. Because the comparison can return after a length difference or the first mismatching character, repeated token endpoint measurements can reveal common-prefix timing information that could potentially allow recovery of the code_verifier, unauthorized access-token acquisition, and account takeover. Practical exploitation requires an intercepted, single-use authorization code and enough measurements to overcome real-world network noise; the local timing benchmark does not establish practical remote account takeover, so the weakness remains a defense-in-depth concern. This issue is fixed in version 4.0.0.

CVSS base score
6.8
Published
2026-10-13
OWASP
A07 Identification and Authentication Failures
Orthogonal defect classification
Timing/Serialization
Code defect classification
Timing Issues
Category
Information Leakage
Subcategory
Information Disclosure
Accessibility scope
Remote
Impact
Unauthorized Access
Affected component
OAuthLib
Fixed by upgrading
Yes

Solution

Upgrade OAuthLib to version 4.0.0 (or later).

Vulnerable code sample

import base64
import hashlib

def _code_challenge(verifier: str, method: str) -> str:
    if method == 'plain':
        return verifier
    elif method == 'S256':
        digest = hashlib.sha256(verifier.encode('utf-8')).digest()
        return base64.urlsafe_b64encode(digest).rstrip(b'=').decode('utf-8')
    else:
        raise ValueError('Unsupported method')

# VULNERABLE: uses simple equality, leaking timing info
def verify_pkce(stored_challenge: str, verifier: str, method: str) -> bool:
    computed = _code_challenge(verifier, method)
    return computed == stored_challenge

Patched code sample

import base64
import hashlib
import hmac

def _code_challenge(verifier: str, method: str) -> str:
    if method == 'plain':
        return verifier
    elif method == 'S256':
        digest = hashlib.sha256(verifier.encode('utf-8')).digest()
        return base64.urlsafe_b64encode(digest).rstrip(b'=').decode('utf-8')
    else:
        raise ValueError('Unsupported method')

# FIX: use constant‑time compare to avoid timing leak
def verify_pkce(stored_challenge: str, verifier: str, method: str) -> bool:
    computed = _code_challenge(verifier, method)
    return hmac.compare_digest(computed, stored_challenge)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

  • Improve PKCE code comparison (oauthlib/oauthlib)
    oauthlib/oauth2/rfc6749/grant_types/authorization_code.py, oauthlib/oauth2/rfc6749/grant_types/authorization_code.py · code_challenge_method_plain, oauthlib/oauth2/rfc6749/grant_types/authorization_code.py · code_challenge_method_s256

Cite this entry

@misc{vaitp:cve202649265,
  title        = {{Timing leak in OAuthLib PKCE verification allows code_verifier inference.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-49265},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-49265/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.