
Differential PoC for CVE-2026-126937, a TOCTOU race in Zipline's POST /api/setup that creates multiple SUPERADMIN accounts; includes a Docker lab comparing 4.6.4 and 4.6.5.
| CVE | CVE-2026-126937 (GHSA-wgjv-p9mm-qw77, High 8.1 CVSS v3.1) |
| Component | Zipline — src/server/routes/api/setup.ts (POST /api/setup) |
| Affected | ≤ 4.6.4 |
| Fixed in | 4.6.5 (single transaction + pg_advisory_xact_lock) |
| CWE | CWE-367 (Time-of-Check Time-of-Use Race Condition) |
| Impact | On a fresh installation whose web setup has not been completed, concurrent unauthenticated requests to POST /api/setup each create an independent SUPERADMIN account — full administrative control of the instance |
| Vector | Network: barrier-synchronized POST /api/setup with distinct spoofed X-Forwarded-For headers (bypasses the per-IP limiter when CORE_TRUST_PROXY=true) |
| Trigger | Concurrent POSTs during the argon2 hashing window (~100–500 ms) |
| Credit | Reported by EQSTLab; found by min8282; advisory published by diced (Zipline) |
POST /api/setup reads the firstSetup flag through an unlocked
prisma.zipline.findFirst(), hashes the admin password with argon2 — which
suspends the async handler on the Node.js event loop for ~100–500 ms —
creates the SUPERADMIN user, and only then resets the flag. There is no
transaction, advisory lock, or unique constraint on role=SUPERADMIN. Every
request that enters the handler during the hashing window observes
firstSetup=true, passes the check, and independently creates its own
SUPERADMIN. This lab races the official diced/zipline:4.6.4 image with 20
barrier-synchronized threads (unique spoofed X-Forwarded-For per thread
against CORE_TRUST_PROXY=true) and measures the outcome: 15 of 20
requests created SUPERADMIN accounts inside a 323 ms window, three of which
were proven to authenticate — while the fixed 4.6.5 image, raced the same
way against the same database schema, created exactly one account and
rejected the other 19 with error 9001 through the new advisory-lock
transaction.
The handler in src/server/routes/api/setup.ts (4.6.4) is three separate,
non-atomic database operations:
const { firstSetup, id } = await getZipline(); // unlocked findFirst()
if (!firstSetup) throw new ApiError(9001); // check
const { username, password } = req.body;
const user = await prisma.user.create({
data: { username,
password: await hashPassword(password), // argon2: ~100–500 ms
role: 'SUPERADMIN',
token: createToken() },
select: userSelect,
}); // use
await prisma.zipline.update({ where: { id },
data: { firstSetup: false } }); // flag reset LAST
The violated invariant: the check, the user creation, and the flag reset must
be one atomic unit. 4.6.5 wraps the whole sequence in
prisma.$transaction protected by
SELECT pg_advisory_xact_lock(hashtext('zipline:first_setup')), so the
check and the flag reset are serialized: the first winner creates the
account, every other concurrent request then observes firstSetup=false and
receives error 9001.
The per-IP limiter (secondlyRatelimit(5) = 1 request per 5 s per IP) does
not help a reverse-proxy deployment: with CORE_TRUST_PROXY=true (the
default behind one) each request carrying a distinct X-Forwarded-For
header is treated as a separate client with its own bucket.
| service | image | role |
|---|---|---|
postgres | postgres:16-alpine | site databases (zipline, zipline_fixed) |
zipline-vuln | diced/zipline:4.6.4 | vulnerable side, CORE_TRUST_PROXY=true |
zipline-fixed | diced/zipline:4.6.5 | fixed side, same configuration, separate database |
poc | — | stdlib Python driver (barrier-synchronized race) |
All containers are CPU/memory bounded on the isolated cve126937lab network. Once setup completes, firstSetup stays false forever — the lab driver wipes the users and resets the row between measurements (run-lab.sh sweep).
./run-lab.sh build # PoC runner image
./run-lab.sh sweep # fresh window + check + exploit + DB differential
./run-lab.sh down
Single mode:
podman run --rm --network=cve126937lab cve-2026-126937-poc:local exploit
poc/poc.py — stdlib-only Python, four modes:
| mode | purpose |
|---|---|
check | classify the target state: firstSetup=true on a fresh instance means the exploitable window is open (exit 1); completed setup means closed (exit 0) |
exploit | full differential: 20 barrier-synchronized threads against both sides; asserts multiple SUPERADMINs on the vulnerable build, authenticates the created accounts via POST /api/auth/login, and asserts exactly one account on the fixed build |
probe | state observability (GET /api/setup) and the X-Forwarded-For acceptance that underlies the limiter bypass |
mitigation | the fix is the 4.6.5 advisory lock — the exploit mode's fixed-side result is the mitigation evidence; there is no client-side workaround |
Exit codes: 0 safe, 1 vulnerable, 2 target unreachable, 3 race not won this run (fresh window + retry), 4 internal error.
The race hit count is inherently probabilistic (event-loop scheduling); the state and the fix behavior are deterministic. The PoC reports the measured hit rate explicitly.
| reproduction path | vulnerable 4.6.4 | fixed 4.6.5 | evidence |
|---|---|---|---|
GET /api/setup on a fresh instance | firstSetup=true (window open) | firstSetup=true | evidence/poc-check.txt |
| 20-thread barrier race | 15 HTTP 200, 15 SUPERADMIN accounts in 323 ms | 1 HTTP 200, 1 SUPERADMIN, 19 rejected with 9001 | evidence/poc-exploit.txt |
| authentication of race accounts | POST /api/auth/login → 200 for the created SUPERADMINs | — | evidence/poc-exploit.txt |
| database state | 15 SUPERADMIN rows, all created within the window | exactly 1 SUPERADMIN row | evidence/db-superadmins.txt |
X-Forwarded-For acceptance | distinct header accepted (no limiter block) | — | evidence/poc-probe.txt |
podman compose; --cpus 2 --memory 4g per container; isolated cve126937lab network.firstSetup stays false — reset the site between measurements (run-lab.sh sweep does it via SQL).pg_advisory_xact_lock transaction — the fix serializes the whole check-create-reset unit rather than narrowing the window.CORE_TRUST_PROXY=true; with the flag off, all threads share one bucket and only a handful of requests land inside the window. The lab keeps the default proxy posture, matching real deployments.