VAITP Dataset

← Back to the dataset

CVE-2026-49272

Token endpoint accepts missing/invalid device_code, issuing tokens improperly.

  • CVSS 8.5
  • CWE-287
  • Authentication, Authorization, and Session Management
  • Remote

OAuthLib is an implementation of the OAuth request-signing logic for Python 3.6+. From 3.3.0 until 4.0.1, OAuthLib's RFC 8628 device workflow does not require DeviceCodeGrant.validate_token_request to check that the device_code parameter is present and valid. A caller whose client request is accepted by the configured validator and who knows a valid client ID enabled for the device workflow can submit a missing or bogus device code to the token endpoint and obtain a bearer token without completing device authorization. This issue is fixed in version 4.0.1.

CVSS base score
8.5
Published
2026-11-05
OWASP
A07 Identification and Authentication Failures
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Authentication, Authorization, and Session Management
Subcategory
Insecure Authentication Mechanisms
Accessibility scope
Remote
Impact
Unauthorized Access
Affected component
OAuthLib
Fixed by upgrading
Yes

Solution

Upgrade OAuthLib to version 4.0.1 or later.

Vulnerable code sample

from oauthlib.oauth2 import DeviceCodeGrant

class MyDeviceCodeGrant(DeviceCodeGrant):
    def validate_token_request(self, request):
        # VULNERABLE: does not verify that device_code is present or valid
        if not self.validate_client(request):
            return False
        # Assume request.device_code may be missing or bogus and still proceed
        return True

Patched code sample

from oauthlib.oauth2 import DeviceCodeGrant
from oauthlib.common import add_params_to_uri

class MyDeviceCodeGrant(DeviceCodeGrant):
    def validate_token_request(self, request):
        # FIX: ensure device_code exists and matches a stored pending code
        if not self.validate_client(request):
            return False
        device_code = getattr(request, 'device_code', None)
        if not device_code or not self._is_valid_device_code(device_code):
            return False
        return True

    def _is_valid_device_code(self, code):
        # placeholder validation logic
        return bool(code) and len(code) == 32

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.

  • Merge pull request #954 from hekhuisk/improve-device-workflow (oauthlib/oauthlib)
    oauthlib/common.py · Request.__init__, oauthlib/oauth2/rfc6749/grant_types/base.py · GrantTypeBase.validate_client_public, oauthlib/oauth2/rfc8628/endpoints/device_authorization.py, oauthlib/oauth2/rfc8628/endpoints/device_authorization.py · DeviceAuthorizationEndpoint.create_device_authorization_response, oauthlib/oauth2/rfc8628/endpoints/device_authorization.py · DeviceAuthorizationEndpoint.validate_device_authorization_request, oauthlib/oauth2/rfc8628/endpoints/device_authorization.py · DeviceAuthorizationEndpoint.__init__, oauthlib/oauth2/rfc8628/grant_types/device_code.py, oauthlib/oauth2/rfc8628/grant_types/device_code.py · DeviceCodeGrant.validate_token_request, oauthlib/oauth2/rfc8628/request_validator.py

Cite this entry

@misc{vaitp:cve202649272,
  title        = {{Token endpoint accepts missing/invalid device_code, issuing tokens improperly.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-49272},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-49272/}}
}

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.