DL·SYS
Contact ↗

CSCTF 2026 · Pwn · 540 pts

echo_chamber.

One format string, four leaks, and a carefully placed fake stack — the heap has to sit high enough in BSS not to collide with RELRO on the way down.

Format string leakStack pivotret2libc
EventCSCTF 2026, Operation Dawn (online jeopardy)
CategoryPwn
Points540
StatusSolved during the event
TargetLive TCP service (libc 2.35)

TL;DR. A one-byte-at-a-time overflow before a printf("echo: %s", buf) leaks the stack canary, then the saved rbp, then the binary's own PIE-relative return address, each by overrunning the buffer just enough to expose the next value as part of the string. A final overflow pivots the stack into a fake frame built in BSS, chained twice to reach a libc base leak and finally system("/bin/sh").

Challenge

chamber reads 0x70 bytes into a 0x50-byte buffer, then printf("echo: %s", buf)s it in a loop, with no canary disabled and PIE enabled (libc 2.35).

Solution — four leaks

Step 1: send 0x58 bytes ending in a non-zero byte that overwrites the canary's low byte. %s then prints 7 canary bytes plus 6 bytes of the saved rbp (since the string read stops at the first zero byte, and the overwritten low byte is non-zero, the read runs past the canary into rbp).

Step 2: resend the real canary (with its low byte again forced non-zero) plus 8 more non-zero bytes over the saved rbp; %s now leaks the function's saved return address — a PIE-relative pointer back into chamber itself.

Step 3 — pivot: the string "bye" triggers a different overflow path; set the saved rbp to the buffer's own address and the return address to the function epilogue (leave; ret, which loads rsp from rbp). This pivots the stack onto a small chain of gadgets (pop rbp; ret plus two stack values) that makes the loop's printf print [main_rbp+8] — which is __libc_start_call_main+0x80, giving the libc base via a known offset.

Step 4 — fake stack: pivot rbp into a BSS address and ret into a gadget that reads a full fake stack frame from stdin into BSS. The one critical placement detail: this BSS address has to sit high in the writable page (pie+0x4c00); too low, and system()'s own ~0x3b8-byte stack frame runs backward into the read-only RELRO page just below BSS and segfaults inside libc's own system. With the chain built correctly — pop rdi; ret, the string "/bin/sh", then system — a shell pops.

Reliability

About 10% of connections leak a canary, saved-rbp, or PIE pointer that happens to contain a 0x00 byte, which truncates the %s leak early. The exploit script detects and retries those connections automatically rather than guessing the missing byte.

Flag

FlagCSCTF{HXDvjYAjfs7HmYiQgl0wNrn2}

What I took from it