Gravitational plate of three masses and a slashed discABC0Static engraved plate. Three-dimensional view is unavailable or reduced motion is requested.

← back to fieldarticle

articleSep 18, 2020

Midnight Sun CTF 2019 gissa2 — high-level notes

Midnight Sun 2019 gissa2: integer width mismatch enables oversized reads and stack corruption under seccomp. High-level root cause and mitigations only.

Midnight Sun CTF 2019 gissa2 — high-level notes

CTF pwnable from Midnight Sun CTF 2019 (gissa2): interactive “guess the flag” style binary with seccomp filtering and modern-ish hardening (NX, PIE, RELRO per the source).

Challenge theme

  • Binary reads user guesses, compares against flag material loaded at start
  • Seccomp blacklist blocks several process/file syscalls (as enumerated in the original with seccomp-tools)
  • Core bug discussion: mismatched integer widths between caller and callee for size/counter state

Vulnerability class / root cause

  • Integer truncation / width mismatch: narrower stack fields (e.g. 16-bit) are passed into a wider parameter type; promotion and adjacent stack layout let a crafted size affect neighboring state and produce an oversized read → stack buffer overflow.
  • Secondary theme in the source: sandbox bypass ideas around filtered syscalls—treated here only as “seccomp policies need careful design,” without bypass recipes.

Impact (abstract)

Stack corruption can leak code addresses (PIE) and hijack control flow inside the challenge process, defeating the intended guess-only interaction. With weak sandboxing, that can mean reading sensitive files the process already opened or equivalent CTF win conditions.

Mitigations / lessons

  • Keep length fields a single consistent unsigned type; bounds-check against the actual buffer capacity before every read.
  • Avoid packing unrelated counters next to length fields in ways that widen incorrectly across ABIs.
  • Treat seccomp as defense-in-depth; still fix memory bugs. Design filters with deny-by-default and review for incomplete coverage.
  • Enable stack canaries and keep PIE/RELRO on for defense-in-depth.

Solve steps and PoC omitted.

related

  1. Sep 18, 2020/articleCSAW 2019 traveller — high-level notes
  2. Jul 10, 2026/articleR3CTF 2026 P1gROXY — HTML escape buffer sizing (high-level)
  3. Sep 18, 2020/articleCSAW 2019 popping_caps — High-level Heap Notes

graphfeed