llamaCVEVulnerability Intelligence
/
Advisory · GitHub · PyPI · pyload-ng

GHSA-889W-M37P-88M5

pyLoad: Api.set_user_permission never invalidates the target's session

Sin parche publicado
Descargar PNG JSON
CVSS
—
high
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
ParcheSin parcheEl fabricante no ha publicado corrección
Exposición42 dDesde la divulgación, 9 oct 2026, 12:09 p. m.
Detección38 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir
Remediar en la ventana regular de mantenimiento
Estimación de Llama con el árbol SSVC de CISA a partir de la severidad declarada por GHSA (alta) y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico parcial. No hay versión corregida: aplique mitigaciones.
Anótala en tu libreta de pendientes serios.Esto huele a PoC esperando su momento.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada +1
Explotación
Remediación
Monitoreo
Detectada
9 oct 26
17 nov 26
21 nov 26
9 oct 26
20 oct 26
31 oct 26
10 nov 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-889W-M37P-88M5 divulgada
Divulgación Modificada Última actualización del registro
Monitoreo Detectada Ingresó al índice
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

### Summary
An admin who revokes or downgrades a non-admin user's permissions through pyLoad's own documented
`/api/<func>` RPC surface — e.g. `POST /api/set_user_permission` (or its legacy alias
`/api/setUserPermission`) — updates the target's database row but never invalidates that user's
existing Flask cookie session. The demoted user keeps their pre-revocation `role`/`permission` bits
on every subsequent WebUI page load and every subsequent `/api/<func>` call made with that cookie,
for up to the default `session_lifetime` of ~31 days, or until they voluntarily log out. No action
by the demoted user is required beyond already being logged in at the time of revocation.

### Details
The vulnerable method, verbatim, at `src/pyload/core/api/__init__.py:1652-1656`:

    @legacy("setUserPermission")
    @post
    def set_user_permission(self, user: str, permission: int, role: int) -> None:
        self.pyload.db.set_permission(user, permission)
        self.pyload.db.set_role(user, role)

It carries no `@permission(...)` decorator and its body never calls `clear_all_user_sessions` or any
other session-invalidation routine.

The only call site in the entire codebase that pairs a permission/role change with
`clear_all_user_sessions` is the WebUI's `update_users()` route,
`src/pyload/webui/app/blueprints/json_blueprint.py:442-444`:

        api.set_user_permission(name, data["permission"], data["role"])
        if was_changed:
            clear_all_user_sessions(name)

A repo-wide grep for `set_user_permission|setUserPermission` returns exactly 3 hits: the `@legacy`
alias registration (`core/api/__init__.py:1652`), the method definition itself (`:1654`), and this one
call site (`json_blueprint.py:442`). No other caller exists.

pyLoad's own public RPC dispatcher reaches `Api.set_user_permission` directly, bypassing
`json_blueprint.py` entirely. `src/pyload/webui/app/blueprints/api_blueprint.py:21-26` registers
`rpc(func, args="")` on `/api/<func>` and `/api/<func>/<args>` for `GET`/`POST`; line 68 dispatches
with `response = jsonify(getattr(api, func)(**json_request_body))` — i.e. it invokes any method on
the `Api` object by name, including `set_user_permission` (also reachable via form/multipart bodies
at `:72`/`:77`). The only authorization gate before that dispatch, at `api_blueprint.py:50`, is:

if not api.is_authorized(func, {"role": user_info["role"], "permission": user_info["permission"]}):

`is_authorized` (`core/api/__init__.py:1419-1432`) returns `True` outright when the caller's
role is `Role.ADMIN`; otherwise it requires `func_name in perm_map`. `set_user_permission` has no
`@permission` decorator, so it is absent from `perm_map` (the module comment at `core/api/__init__.py:37`
states "unlisted functions are for admins only"). This gate concerns only the caller's own
authorization — it says nothing about, and never touches, the target user's existing session.

### The stale session survives
The demoted user's session was populated once, at login, and is never refreshed:

  • `helpers.py:170,179,183-185` — `parse_permissions(session)` derives the caller's effective
  • These values are written once by `set_session()` (`helpers.py:223-234`), called only from
  • `is_authenticated(session)` (`helpers.py:261-266`) is exactly:
  • Inside `apikey_auth` (`helpers.py:393-404`), when no `X-API-Key` header is supplied, `flask.g.user_info`

The exposure window is bounded, not indefinite: `default.cfg:47` sets `session_lifetime = 44640`
(minutes, ≈31 days), wired into `PERMANENT_SESSION_LIFETIME` at `webui/app/__init__.py:130-131`, and
`SESSION_REFRESH_EACH_REQUEST = False` at `:128` means the window is a hard ~31 days from login, not
extended by continued activity.

## Attack Sequence
Starting privilege: an already-authenticated non-admin user, plus an admin who legitimately uses
pyLoad's own documented API instead of the WebUI page.

  1. Victim user logs in normally, obtains a Flask session cookie (`A`) with `role`/`perms` reflecting
  2. Admin revokes or downgrades the victim's permissions via
  3. Using cookie `A` (never invalidated), the victim loads any WebUI admin-gated page, or calls any
  4. This persists for up to ~31 days (default `session_lifetime`) or until the victim logs out,

This sequence was confirmed against a real, locally-run pyLoad instance, not just traced from source.
See Section 10 for the exact commands, real HTTP status codes and response bodies, and the
precondition that the admin step here used `X-API-Key` header auth rather than a cookie (explained
there).

## Suggested Fix
Move the `clear_all_user_sessions(name)` call into `Api.set_user_permission` itself (ideally also
adopting the apikey-cache purge pattern already used in `remove_user`,
`core/api/__init__.py:1626-1636`), so that every entry point — WebUI and `/api/<func>` RPC alike —
inherits session invalidation automatically, rather than requiring each caller to remember to invoke
it separately.

### PoC
This was executed for real against pyLoad's own code, not merely predicted from reading it. The
verifier pass that produced Sections 1-9 (`ghsa/CLAIMS-pyload.md`) source-traced every claim but never
ran a PoC; this section closes that gap.

Method and preconditions
  • Target: `pyload/pyload` at the pinned commit `31e341fd41d2dac9fffa3683a756edc54bcdeb77`
  • Transport: Flask's in-process test client (`app.test_client()`) against the real
  • Two users: `pyload`/`pyload` (pyLoad's own automatically-created default admin account) and a
  • Elevated-action probe: `GET /api/get_userdir` (`core/api/__init__.py:1434-1437`, decorated
  • The admin's `POST /api/set_user_permission` call used `X-API-Key` header authentication rather than
  • Full script, README with exact from-nothing run instructions, and the verbatim captured output are
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`).

pyload-poc.zip https://github.com/user-attachments/files/32062053/pyload-poc.zip

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Versiones

Rangos afectados

Afectada Corregida Última
pyload-ng≥ 0.5.0b3.dev98 ≤ 0.5.0b3.dev101
0.5.0b3.dev101
0.5.0b3.dev102
0.5.0b3.dev98
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
pypipyload-ng
Sin parche — — 0.5.0b3.dev102 no afectada
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Otrahttps://github.com/pyload/pyload/security/advisories/GHSA-889w-m37p-88m5
Otrahttps://github.com/pyload/pyload/commit/3e726ba271a6b1015e3a0ea6dc7e46a8f71a62ad
Otrahttps://github.com/pyload/pyload

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.