Vulnerability GHSA-r44w-v6gf-x3p6
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.
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.
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.
Reproduction
1. Create an administrator account.
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
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.
References
Related Vulnerabilities
Other vulnerabilities affecting the same packages