$ cat writeup.md…
$ cat writeup.md…
Hack.lu CTF 2026
Task: Express/EJS mail app with an admin bot that visits an attacker URL; no XSS and no server-side bug. Solution: cross-site search (XS-Search) using a nested-frame `history.length` oracle to leak the admin's flag mail character by character.
$ cat /etc/rate-limit
Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.
postbox — zero-inbox by design. cloud-native, AI-ready, omnichannel mail.
English summary: a small mail web app (Express 5 + EJS 7 + express-session + better-sqlite3) sits behind an nginx proxy. The admin account owns a mail whose subject/body contains the flag. A bot logs in as admin and then visits any attacker-supplied URL, sleeping 30 seconds. The goal is to read the admin's flag mail without ever obtaining their session.
POST /login — auto-registers on first login; username must match
^[a-zA-Z0-9_]{3,24}$, password 4-128 chars.GET / (login required) — inbox. Query params:
?q=<term> — search: instr(lower(subject),lower(?))>0 OR instr(lower(body),lower(?))>0
(parameterized, case-insensitive substring match).?sort=asc|desc?open=<slug>GET /msg/:slug/body.html — escaped mail view, scoped to owner_id (404 if
not owned; slug === 'none' renders "No message selected").GET /compose, GET /delete, POST /compose, POST /logout.GET /report (nginx location /report) proxies to the bot: JSON
{"url": "..."}, rate-limited 2/min.Every response sets Content-Security-Policy: default-src 'self'; base-uri 'none'; form-action 'self'
and Cache-Control: no-store. The session cookie pb.sid is HttpOnly but has
no SameSite and no Secure.
No XSS. Every dynamic value in the EJS views is emitted with <%= %>
(auto-escaped). The strict CSP additionally forbids inline and external
scripts. Template injection is not reachable.
No server-side bug. All SQL is parameterized (better-sqlite3 prepared
statements), all mail queries are owner-scoped, and the session secret is a
fresh crypto.randomBytes(32).
Plain frame counting fails. The inbox page always renders exactly one same-origin iframe:
<iframe id="preview" src="/msg/<%= openSlug %>/body.html"></iframe>
...
$ grep --similar