GHSA-6MCX-X5H6-RPW2
PadMessageHandler TOCTOU: same-socket CLIENT_READY pad-swap redirects a queued USER_CHANGES onto a read-only/unauthorized pad (cross-pad write)
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-6MCX-X5H6-RPW2 divulgada · CVSS 5.3 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Etherpad: same-socket `CLIENT_READY` pad-swap TOCTOU redirects a queued `USER_CHANGES` onto a read-only / unauthorized pad (cross-pad write)
Target: `ether/etherpad-lite` (TypeScript, Node.js), HEAD `0cd01fce` (v3.3.2).
Class: CWE-362 race condition (TOCTOU on the shared per-socket `sessioninfos[socket.id]`) → CWE-862 broken access control (read-only / cross-pad write).
Impact: a user who only holds a read-only share link to a pad (or, in the stronger variant, can name a pad they cannot write) can write/overwrite arbitrary content into that pad by racing a `USER_CHANGES` against a same-socket `CLIENT_READY` that swaps the session's `padId`. The read-only enforcement and per-pad authorization are bypassed. Runtime-proven.
Channel: GitHub PVR on `ether/etherpad` (open). Finder credit.
Root cause (read at HEAD `0cd01fce`)
The socket message router runs each per-socket message handler concurrently and a thrown handler does not disconnect the socket (`src/node/handler/SocketIORouter.ts:80-92`): the rejection is only `ack`ed as an error. So multiple in-flight messages from one socket interleave, and a failed message leaves the socket alive.
`PadMessageHandler.handleMessage` keys everything off the mutable, shared `sessioninfos[socket.id]`:
- On `CLIENT_READY`, `thisSession.auth.padID = message.padId` (`:472`) — the pad is taken from the message, so a single socket can re-join a different pad — and `thisSession.padId` / `thisSession.readonly` are reassigned (`:487-490`) before `securityManager.checkAccess` runs (`:510`). On an access deny, the handler emits `{accessStatus}` and `throw`s (`:511-513`) — but the already-mutated `thisSession.padId = B` is never reset.
- `USER_CHANGES` are gated by `if (readOnly) throw …` (`:577`, using the snapshot at message-arrival time) and then enqueued: `padChannels.enqueue(thisSession.padId, {socket, message})` (`:583`).
- `handleUserChanges` (the actual write) runs later in the channel worker and reads `thisSession = sessioninfos[socket.id]` fresh (`:832`), writing to `thisSession.padId` (`:853`) — re-checking neither access nor readonly.
So the `padId` used for the authorization gate (at enqueue) and the `padId` used for the write (at apply) are read at two different times from shared mutable state. An attacker interleaves:
1. `CLIENT_READY(A)` — a pad they may write → `padId=A, readonly=false`.
2. `USER_CHANGES` (crafted for target pad B) → passes the readonly gate on A, enqueues on channel A.
3. `CLIENT_READY(B)` (the read-only id of B, or any pad they cannot write) → swaps `thisSession.padId=B` (on deny, still left as B).
4. The queued `handleUserChanges` reads `padId=B` and applies the changeset to B.
The in-code comment at `:492-496` ("`message.padId` must not be accessed … use `sessioninfos[socket.id].padId`") shows the cross-pad risk was considered — but routing through the *mutable* `sessioninfos[socket.id].padId` across the enqueue→apply async gap is exactly what enables the TOCTOU.
Runtime PoC (RUNTIME-PROVEN against a live instance)
Live Etherpad v3.3.2, default dirtyDB, public pads. `poc.ts` (socket.io-client + Etherpad's own `makeSplice`): a victim pad B ("secret_board") is shared read-only (`r.…`); the attacker holds only that read-only id plus a writable scratch pad A. A large "big" changeset keeps channel A busy so the malicious `USER_CHANGES` applies *after* the `padId` swap. Transcript in `req-resp/poc-run.txt`:
### CONTROL (normal read-only write is blocked):
[control] readonly USER_CHANGES -> ack={"Error","message":"COLLABROOM: write attempt on read-only pad"} (boundary holds)
### EXPLOIT (TOCTOU pad-swap cross-pad write):
[attack] attempt N: B CHANGED (rev ->+1). B.text[0:50]="PWNED_RO Welcome to Etherpad!\n\nThis pad text is sy"
=> CROSS-PAD WRITE CONFIRMED: a queued USER_CHANGES landed on read-only pad B via the CLIENT_READY padId-swap TOCTOU.- Control proves the read-only id normally rejects writes (`write attempt on read-only pad`).
- Exploit writes attacker content (`PWNED_RO …`) into pad B, advancing its revision — the read-only holder modified the pad. The race is probabilistic (hit within a handful of attempts here) and trivially retried.
Severity
`CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:N` = 5.3 (Medium).
- `PR:L` — the attacker needs a read-only share of the target pad (a low-trust, widely-distributed credential); `AC:H` — winning the race needs retries.
- `I:H` — arbitrary content write into a pad the attacker is only authorized to read; `C:N` (no new read), `A:N`.
Stronger variant (noted, not the headline PoC): because a *denied* `CLIENT_READY(B)` leaves `thisSession.padId=B` and does not disconnect, the same race lets a socket write into a pad it has no access to (e.g. a group pad) — `handleUserChanges` keeps the attacker's pad-A author, so the author check passes. That path additionally requires knowing B's current `baseRev`/length (trivial for a freshly-created or guessable pad), so it is harder to weaponize blindly; the demonstrated read-only-share bypass needs no such guessing.
Suggested fix
`handleUserChanges` should act on the pad captured at enqueue time (the channel key already *is* `thisSession.padId` at enqueue), not re-read the now-mutable `sessioninfos[socket.id].padId`; and it should re-assert `readonly`/access at apply time. Additionally, a denied `CLIENT_READY` must not leave `sessioninfos[socket.id].padId`/`readonly` mutated (reset on deny) and should disconnect the socket. Any one of these closes the window; all three is defense-in-depth.
Dup-gate
Distinct from all 8 published `etherpad` advisories (none touch `PadMessageHandler` message-ordering, `sessioninfos` mutation, or `CLIENT_READY` pad-swap) and from my two other 2026-06-27 etherpad findings (copyPad `:` injection; OIDC session fixation). FRESH.
## Evidence
- `poc.ts` — deterministic socket.io PoC (control = read-only write blocked; exploit = cross-pad write via the swap race).
- `req-resp/poc-run.txt` — captured control + confirmed cross-pad write.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmep_etherpad-lite |
Sin parche | — | — | 1.8.14 afectada |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/ether/etherpad/security/advisories/GHSA-6mcx-x5h6-rpw2Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
