VAITP Dataset

← Back to the dataset

CVE-2026-123816

API key cache bypass via key_id allowing unauthorized access

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

pyLoad is a free and open-source download manager written in Python. Prior to 0.5.0b3.dev101, Api.check_apikey caches successful validation in self._apikey_cache using only the attacker-controlled key_id. After a legitimate key populates the cache, a forged API key with the same key_id reaches the cache-hit path without comparing apikey[-43:] to the stored hash through hmac.compare_digest. Key identifiers are small sequential integers, so an unauthenticated remote attacker can enumerate an active identifier and inherit the cached key owner's permissions during the 300-second cache lifetime. This issue is fixed in version 0.5.0b3.dev101.

CVSS base score
8.1
Published
2026-11-09
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
Privilege Escalation
Affected component
pyLoad
Fixed by upgrading
Yes

Solution

Upgrade pyLoad to version 0.5.0b3.dev101 or later.

Vulnerable code sample

import hmac

class Api:
    def __init__(self):
        # cache maps key_id -> True (validation passed)
        self._apikey_cache = {}

    def check_apikey(self, apikey: str) -> bool:
        """
        Validate an API key. The key format is "<key_id>:<secret_hash>"
        where <secret_hash> is the last 43 characters of an HMAC.
        """
        try:
            key_id, secret = apikey.split(":", 1)
        except ValueError:
            return False

        # VULNERABLE: cache keyed only by attacker‑controlled key_id
        if key_id in self._apikey_cache:
            return True

        # Simulated verification against a data store
        stored_hash = self._lookup_hash(key_id)
        if stored_hash is None:
            return False

        # compare the provided secret to the stored hash
        if hmac.compare_digest(secret, stored_hash):
            self._apikey_cache[key_id] = True
            return True
        return False

    def _lookup_hash(self, key_id: str) -> str | None:
        # Placeholder for DB lookup; returns the last 43 chars of the true HMAC
        fake_db = {
            "1": "a"*43,
            "2": "b"*43,
        }
        return fake_db.get(key_id)

Patched code sample

import hmac

class Api:
    def __init__(self):
        # cache maps key_id -> stored_hash (validation passed)
        self._apikey_cache = {}

    def check_apikey(self, apikey: str) -> bool:
        """
        Validate an API key. The key format is "<key_id>:<secret_hash>"
        where <secret_hash> is the last 43 characters of an HMAC.
        """
        try:
            key_id, secret = apikey.split(":", 1)
        except ValueError:
            return False

        # FIX: cache includes the validated hash, ensuring secret is re‑checked
        cached_hash = self._apikey_cache.get(key_id)
        if cached_hash is not None and hmac.compare_digest(secret, cached_hash):
            return True

        stored_hash = self._lookup_hash(key_id)
        if stored_hash is None:
            return False

        if hmac.compare_digest(secret, stored_hash):
            self._apikey_cache[key_id] = stored_hash
            return True
        return False

    def _lookup_hash(self, key_id: str) -> str | None:
        fake_db = {
            "1": "a"*43,
            "2": "b"*43,
        }
        return fake_db.get(key_id)

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.

  • fix GHSA-r44w-v6gf-x3p6 security advisory (pyload/pyload)
    src/pyload/core/api/__init__.py · Api.check_apikey, src/pyload/core/api/__init__.py · Api.delete_apikey, src/pyload/core/api/__init__.py · Api.remove_user, src/pyload/core/api/__init__.py · Api.__init__, src/pyload/webui/app/helpers.py · apikey_auth

Cite this entry

@misc{vaitp:cve2026123816,
  title        = {{API key cache bypass via key_id allowing unauthorized access}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-123816},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-123816/}}
}

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.