$ cat writeup.md…
$ cat writeup.md…
fortid2026
Task: Python http.server + sqlite3 on-call board injects the `sort` parameter into ORDER BY; the flag is in an unlisted row that is never selectable. Solution: blind SQLi in ORDER BY using the returned doctor identity as a base-5 oracle to exfiltrate farewell_note char by char.
$ cat /etc/rate-limit
Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.
Dr. Bye Bye has retired from St. Codd's Hospital.
The hospital insists that retired records can never be displayed. Can you recover Dr. Bye Bye's private farewell note anyway?
A small Python http.server + sqlite3 application serves an "on-call board".
GET /api/on-call?sort=<expr> returns the doctor who is currently on call. The
retired doctor Dr. Bye Bye (id=404, listed=0) stores the flag in the
farewell_note column, but the query filters WHERE listed = 1, so that row is
never returned by design. Goal: recover the hidden farewell note
(FortID{...}).
CREATE TABLE doctors ( id INTEGER PRIMARY KEY, slug TEXT NOT NULL UNIQUE, name TEXT NOT NULL, specialty TEXT NOT NULL, room TEXT NOT NULL, listed INTEGER NOT NULL CHECK (listed IN (0, 1)), farewell_note TEXT ); INSERT INTO doctors VALUES (10, 'ada-pulse', 'Dr. Ada Pulse', 'Cardiology', 'C-101', 1, NULL), (30, 'max-well', 'Dr. Max Well', 'Radiology', 'R-204', 1, NULL), (50, 'paige-turner', 'Dr. Paige Turner', 'Neurology', 'N-303', 1, NULL), (70, 'ella-ment', 'Dr. Ella Ment', 'Pathology', 'P-118', 1, NULL), (90, 'zoe-last', 'Dr. Zoe Last', 'Emergency medicine','E-001', 1, NULL); -- flag row inserted separately, hidden from the WHERE clause: -- (404, 'doctor-bye-bye', 'Dr. Bye Bye', 'Retired', '-', 0, <FLAG>)
def select_on_call(order_expression): query = f""" SELECT name, specialty, room FROM doctors WHERE listed = 1 ORDER BY {order_expression} LIMIT 1 """ ... row = connection.execute(query).fetchone()
The sort query parameter (up to 600 chars) is concatenated directly into
the ORDER BY clause — classic SQL injection. Only name, specialty, room
of one of the five listed rows are ever returned. Errors are caught and hidden:
...
$ grep --similar