GHSA-r44w-v6gf-x3p6

Suggest an improvement
Source
https://github.com/advisories/GHSA-r44w-v6gf-x3p6
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-r44w-v6gf-x3p6/GHSA-r44w-v6gf-x3p6.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-r44w-v6gf-x3p6
Published
2026-10-09T16:43:55Z
Modified
2026-10-09T17:00:12Z
Severity
  • 8.1 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H CVSS Calculator
Summary
pyLoad has an authentication bypass in API key validation (check_apikey cache)
Details

Summary

The API-key cache in check_apikey() allows an attacker to authenticate with a forged API key as long as the legitimate key for the same key_id has been used recently.

On a cache hit, the API key secret is never verified, resulting in a complete authentication bypass during the cache lifetime.


Affected Components

  • src/pyload/core/api/init.py

    • Api.check_apikey()
  • src/pyload/core/database/apikey_database.py

    • check_apikey()
    • _check_key()

The cache is used by normal API requests through:

  • src/pyload/webui/app/helpers.py

which calls:

api.check_apikey(api_key)

without providing a ttl, meaning the default 300-second cache is always enabled.


Root Cause

Successful API key validations are cached in:

self._apikey_cache

using the following structure:

{
    key_id: (timestamp, cached_data)
}

The cache key is based only on key_id, and that value is parsed directly from the user-supplied API key rather than being obtained from a trusted lookup.

When a cache hit occurs within the TTL, check_apikey() returns:

{
    "success": True,
    "data": cached_data
}

after checking only:

  • expires_at

At no point on this execution path is the supplied secret:

apikey[-43:]

compared against the stored key hash.


The actual secret verification exists only in:

_check_key()

which correctly uses:

hmac.compare_digest()

However, this function is only reached on a cache miss through the database layer's check_apikey() implementation.

Furthermore, the cached object cannot be used for verification because it intentionally does not include the stored key hash.

The cached record contains only:

  • id
  • user_id
  • name
  • created_at
  • expires_at
  • last_used

Since key_hash is absent, the cache lacks the information required to validate the presented secret.

As a result, once a legitimate request populates the cache, every subsequent request using the same key_id within the 300-second cache window is accepted without validating the secret.


Impact

key_id values are small sequential integers assigned when API keys are created (1, 2, 3, ...), making them trivial to enumerate.

The API key format is also publicly reconstructable from the source code.

An attacker therefore does not need to know any valid API key secret.

They only need a key_id whose legitimate key has been used within the previous five minutes, which is likely on an actively used deployment.

During that cache window, a forged API key follows exactly the same authentication path as a legitimate key and inherits the associated user's permissions.

This results in a complete remote authentication bypass.

I would classify the issue as Critical severity.


Estimated CVSS v3.1

AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H

(AC:H only because successful exploitation depends on the cache already containing an entry.)


Reproduction

1. Create an administrator account.


2. Generate an API key.

Example:

pl_11<43-character-secret>

where:

key_id = 1

3. Send a legitimate authenticated request.

curl \
  -H "X-API-Key: pl_11<real-43-char-secret>" \
  http://127.0.0.1:8000/api/status

Expected response:

HTTP/1.1 200 OK

4. Within 300 seconds, send the same request using a forged API key.

curl \
  -H "X-API-Key: pl_11xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  http://127.0.0.1:8000/api/status

Observed response:

HTTP/1.1 200 OK

The request succeeds even though the API key secret is entirely incorrect.


Control Test

If the forged API key is sent before any legitimate request has populated the cache, the server correctly returns:

HTTP/1.1 401 Unauthorized

The only difference between the failing and succeeding forged request is whether the cache already contains an entry for that key_id.

This isolates the vulnerability specifically to the cache-hit path.


Suggested Fix

Cache hits should never replace secret verification.

Possible approaches include:

  • Store a value derived from the complete API key (or its hash) in the cache and verify it using hmac.compare_digest() on every cache hit before returning success.

  • Alternatively, key the cache using a value derived from the entire API key secret (for example, a cryptographic hash of the complete API key) rather than using only key_id.

Regardless of implementation, the security invariant should remain:

The API key secret must be validated on every authenticated request, regardless of whether the cache is hit or missed.

Database specific
{
    "cwe_ids": [
        "CWE-287"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-10-09T16:43:55Z",
    "nvd_published_at": null,
    "severity": "HIGH"
}
References

Affected packages

PyPI / pyload-ng

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
0.5.0b3.dev101

Affected versions

0.*
0.5.0a5.dev528
0.5.0a5.dev532
0.5.0a5.dev535
0.5.0a5.dev536
0.5.0a5.dev537
0.5.0a5.dev539
0.5.0a5.dev540
0.5.0a5.dev545
0.5.0a5.dev562
0.5.0a5.dev564
0.5.0a5.dev565
0.5.0a6.dev570
0.5.0a6.dev578
0.5.0a6.dev587
0.5.0a7.dev596
0.5.0a8.dev602
0.5.0a9.dev615
0.5.0a9.dev629
0.5.0a9.dev632
0.5.0a9.dev641
0.5.0a9.dev643
0.5.0a9.dev655
0.5.0a9.dev806
0.5.0b1.dev1
0.5.0b1.dev2
0.5.0b1.dev3
0.5.0b1.dev4
0.5.0b1.dev5
0.5.0b2.dev9
0.5.0b2.dev10
0.5.0b2.dev11
0.5.0b2.dev12
0.5.0b3.dev13
0.5.0b3.dev14
0.5.0b3.dev17
0.5.0b3.dev18
0.5.0b3.dev19
0.5.0b3.dev20
0.5.0b3.dev21
0.5.0b3.dev22
0.5.0b3.dev24
0.5.0b3.dev26
0.5.0b3.dev27
0.5.0b3.dev28
0.5.0b3.dev29
0.5.0b3.dev30
0.5.0b3.dev31
0.5.0b3.dev32
0.5.0b3.dev33
0.5.0b3.dev34
0.5.0b3.dev35
0.5.0b3.dev38
0.5.0b3.dev39
0.5.0b3.dev40
0.5.0b3.dev41
0.5.0b3.dev42
0.5.0b3.dev43
0.5.0b3.dev44
0.5.0b3.dev45
0.5.0b3.dev46
0.5.0b3.dev47
0.5.0b3.dev48
0.5.0b3.dev49
0.5.0b3.dev50
0.5.0b3.dev51
0.5.0b3.dev52
0.5.0b3.dev53
0.5.0b3.dev54
0.5.0b3.dev57
0.5.0b3.dev60
0.5.0b3.dev62
0.5.0b3.dev64
0.5.0b3.dev65
0.5.0b3.dev66
0.5.0b3.dev67
0.5.0b3.dev68
0.5.0b3.dev69
0.5.0b3.dev70
0.5.0b3.dev71
0.5.0b3.dev72
0.5.0b3.dev73
0.5.0b3.dev74
0.5.0b3.dev75
0.5.0b3.dev76
0.5.0b3.dev77
0.5.0b3.dev78
0.5.0b3.dev79
0.5.0b3.dev80
0.5.0b3.dev81
0.5.0b3.dev82
0.5.0b3.dev85
0.5.0b3.dev87
0.5.0b3.dev88
0.5.0b3.dev89
0.5.0b3.dev90
0.5.0b3.dev91
0.5.0b3.dev92
0.5.0b3.dev93
0.5.0b3.dev94
0.5.0b3.dev95
0.5.0b3.dev96
0.5.0b3.dev97
0.5.0b3.dev98
0.5.0b3.dev99
0.5.0b3.dev100

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-r44w-v6gf-x3p6/GHSA-r44w-v6gf-x3p6.json"