Writeup · Cyberweek Africa 2026 - National CTF (Finals)

The Forgotten Relay

forensicshardsolvedFlag: FLAG{REDACTED}

Overview

The challenge is a fictional optical relay archive inspired by Kenya’s submarine fibre era (TEAMS reached Mombasa in 2009). The task has no exploitation in the usual sense. It is a data-forensics and verification puzzle chained to a physical step:

  1. Reconstruct the single authentic four-hop route MSA-LAND -> ARCHIVE from conflicting monitoring records.
  2. Use that route to derive which of four physical event markers (M1..M4) to visit, and read its WITNESS.
  3. Compute a checkpoint code and submit the technical evidence to the portal.
  4. The portal reveals a four-digit safe code. The registered captain opens their own room safe and takes a sealed slip (RELAY_SEAL + SEAL_NONCE).
  5. Compute the shared R5 and a per-team TEAM_TAG, then submit FLAG{LS05_<R5>_<TEAM_TAG>} to CTFd.

R5 is identical for every team and is the input to Chapter 6, so it must be kept.

Provided files

File Purpose
case_manifest.txt Rules, budgets, derivation formulas
optical_links.csv 15 directed edges (src, dst, lambda, loss, latency, status, service)
relay_receipts.csv 33 TX/RX receipts, each with a station-local timestamp and an HMAC
clock_offsets.csv Per-station clock offset in ms
node_rules.csv Wavelength conversion (input -> output) per node
venue_marker_directory.csv Where each marker M1..M4 is physically located
relay_probe.py Optional helper: checks receipts, does not find the path
vault_finish.py Optional helper: final R5 / TEAM_TAG calculation
fibre_lab_schematic.pdf Conceptual map only, explicitly not authoritative

Case parameters (from the manifest)

START_NODE=MSA-LAND  END_NODE=ARCHIVE  START_LAMBDA=41  REQUIRED_HOPS=4
SERVICE=FIBRE-09     REQUIRED_LINK_STATE=ACTIVE  REQUIRED_RECEIPT_QUALITY=LOCKED
MAX_TOTAL_LOSS_TENTH_DB=75   MAX_TOTAL_DELAY_MS=60
MIN_NODE_DWELL_MS=15         MAX_NODE_DWELL_MS=100

Recon

The receipt model

The helper script shows how a receipt is built. Each receipt is an HMAC-SHA256 (first 12 hex characters, uppercase) keyed with the bytes of R4:

msg = f"LS05|{service}|{edge_id}|{src}|{dst}|{lambda}|{origin_utc_ms}|{loss_tenth_db}|{latency_ms}"
receipt = hmac.new(bytes.fromhex(R4), msg.encode(), hashlib.sha256).hexdigest()[:12].upper()

Station clocks are skewed, so a receipt’s true time is utc = local_ms - offset[observer]. For a genuine edge:

  • A TX receipt must be observed at the edge’s src, with utc == origin_utc_ms.
  • An RX receipt must be observed at the edge’s dst, with utc == origin_utc_ms + latency_ms.

Seeing the noise

Running the probe with R4 shows several kinds of deliberate noise:

python3 relay_probe.py --r4 <R4>
Noise type Examples How to spot it
Forged TX receipts extra TX rows on E03 (15640), E05 (15500), E12 (15560) MAC=FAIL
Unstable RX one E02 RX row quality=UNSTABLE and clock check fails
Wrong service tag E13 (MAINT-TEST), E14 (MONITOR) service != FIBRE-09
Out of service E11 status=OUT_OF_SERVICE
One-sided evidence E08 has a TX but no RX cannot verify both endpoints
Time-shifted E15 at about 14700 ms cannot chain with the other hops
Parallel edges E02 / E12 (PORT-EXCH -> KIL-RING), E03 / E15, E03 / E11 pick by budget and timing

Candidate paths

Four-edge paths from MSA-LAND to ARCHIVE in the raw graph are:

E01>E02/E12>E03/E15>E04      via PORT-EXCH, KIL-RING, CBD-RELAY
E01>E07>E08>E04              via PORT-EXCH, MAINT-SPUR, CBD-RELAY
E01>E02/E12>E09>E10          via PORT-EXCH, KIL-RING, CACHE-NODE
E05>E06>E03/E15>E04          via STAGING-EXCH, KIL-RING, CBD-RELAY
E05>E06>E09>E10              via STAGING-EXCH, KIL-RING, CACHE-NODE

Exploitation

Step 1: Prune with wavelength rules

The signal starts at 41 nm. At each intermediate node the incoming wavelength must match input_lambda, and the next edge then carries output_lambda:

Node in -> out
PORT-EXCH 41 -> 43
STAGING-EXCH 41 -> 41
KIL-RING 43 -> 43
MAINT-SPUR 43 -> 43
CBD-RELAY 43 -> 42
CACHE-NODE 43 -> 42
  • The STAGING-EXCH branch (E05>E06>...) dies at KIL-RING. E06 delivers 41 nm but KIL-RING only accepts 43 nm.
  • Paths via PORT-EXCH are fine: 41 -> (convert) 43 -> 43 -> (convert) 42.

Step 2: Prune with receipt verification

  • E08 has no RX receipt, so the MAINT-SPUR path is out.
  • E11, E13, E14 are out (state or service tag).
  • E15 verifies, but its timing (about 14700 ms) puts it before the PORT-EXCH hop, so the dwell check fails.

Step 3: Prune with budgets

Two parallel pairs (E02 vs E12, and the KIL-RING exits E03 vs E09) remain. Loss budget is 75 tenths of a dB:

Route Loss (tenth dB) Delay (ms) Verdict
E01>E02>E03>E04 11+16+20+18 = 65 9+13+11+12 = 45 within budget
E01>E12>E03>E04 11+49+20+18 = 98 45 loss over 75
E01>E02>E09>E10 11+16+48+26 = 101 45 loss over 75
E01>E12>E09>E10 11+49+48+26 = 134 45 loss over 75

Step 4: Dwell time check

Dwell is the verified RX time at a node minus the verified TX time of the next edge (all in corrected UTC):

Node RX of previous TX of next Dwell
PORT-EXCH E01 RX = 15009 E02 TX = 15060 51 ms
KIL-RING E02 RX = 15073 E03 TX = 15140 67 ms
CBD-RELAY E03 RX = 15151 E04 TX = 15220 69 ms

All are inside the 15..100 ms window. Only one route survives.

Step 5: Automating the whole thing

The solver below re-implements the checks end to end so the answer does not depend on hand pruning. Run it from the extracted challenge directory with R4 as the only argument. It printed exactly one valid route.

#!/usr/bin/env python3
"""LS05 solver: validate receipts, search 4-hop routes, derive marker selector."""
import csv, hashlib, hmac, sys

R4 = sys.argv[1].upper()
rd = lambda n: list(csv.DictReader(open(n, newline="")))
links = {e["edge_id"]: e for e in rd("optical_links.csv")}
off = {r["station"]: int(r["offset_ms"]) for r in rd("clock_offsets.csv")}
rules = {r["node"]: (int(r["input_lambda"]), int(r["output_lambda"])) for r in rd("node_rules.csv")}

def mac(e, svc, origin):
    m = f"LS05|{svc}|{e['edge_id']}|{e['src']}|{e['dst']}|{e['lambda']}|{origin}|{e['loss_tenth_db']}|{e['latency_ms']}"
    return hmac.new(bytes.fromhex(R4), m.encode(), hashlib.sha256).hexdigest()[:12].upper()

good = {}  # edge -> {"TX": utc, "RX": utc}
for r in rd("relay_receipts.csv"):
    e = links[r["edge_id"]]
    origin = int(r["origin_utc_ms"])
    utc = int(r["local_ms"]) - off[r["observer"]]
    node = e["src"] if r["side"] == "TX" else e["dst"]
    want = origin + (int(e["latency_ms"]) if r["side"] == "RX" else 0)
    ok = (hmac.compare_digest(mac(e, r["service"], origin), r["receipt"])
          and r["observer"] == node and utc == want and r["quality"] == "LOCKED"
          and r["service"] == e["service"] == "FIBRE-09" and e["status"] == "ACTIVE")
    if ok:
        good.setdefault(r["edge_id"], {})[r["side"]] = utc

verified = {k for k, v in good.items() if {"TX", "RX"} <= v.keys()}
print("verified edges:", sorted(verified))

def dfs(node, lam, path):
    if len(path) == 4:
        if node == "ARCHIVE":
            yield path
        return
    for eid in sorted(verified):
        e = links[eid]
        if e["src"] != node or int(e["lambda"]) != lam:
            continue
        nxt = e["dst"]
        out = rules[nxt][1] if nxt in rules and nxt != "ARCHIVE" else int(e["lambda"])
        if nxt in rules and rules[nxt][0] != int(e["lambda"]):
            continue
        if path:
            dwell = good[eid]["TX"] - good[path[-1]]["RX"]
            if not 15 <= dwell <= 100:
                continue
        yield from dfs(nxt, out, path + [eid])

for p in dfs("MSA-LAND", 41, []):
    loss = sum(int(links[i]["loss_tenth_db"]) for i in p)
    delay = sum(int(links[i]["latency_ms"]) for i in p)
    if loss <= 75 and delay <= 60:
        route = ">".join(p)
        sel = hashlib.sha256(f"LS05|{R4}|{route}|CHECKPOINT".encode()).hexdigest()
        print(route, "loss", loss, "delay", delay,
              "lambdas", ">".join(links[i]["lambda"] for i in p),
              "marker M%d" % (1 + int(sel[:8], 16) % 4))

Output:

verified edges: ['E01', 'E02', 'E03', 'E04', 'E05', 'E06', 'E07', 'E09', 'E10', 'E12', 'E15']
E01>E02>E03>E04 loss 65 delay 45 lambdas 41>43>43>42 marker M4

Note that the forged and mismatched edges (E08, E11, E13, E14) are dropped at verification, and E05, E06, E07, E09, E10, E12 and E15 survive it but are then eliminated by wavelength rules, dwell time or the loss budget.

Step 6: Marker selection

selector = SHA256("LS05|" + R4 + "|" + route_string + "|CHECKPOINT")
marker_id = "M" + str(1 + int(selector[:8], 16) % 4)

For the authentic route this gives M4, which the directory places at the parking level, in a cordoned and supervised event station (indoor equivalent if required).

M1  Ground floor - organiser registration display
M2  Ground floor - dedicated event exhibit area
M3  Ground floor - approved investigation panel
M4  Parking level - cordoned, supervised event station

Step 7: Checkpoint code and portal

checkpoint_code = SHA256("LS05|" + R4 + "|" + route + "|" + marker_id + "|" + WITNESS)[:8].upper()
python3 -c "import hashlib; print(hashlib.sha256(b'LS05|<R4>|E01>E02>E03>E04|M4|<WITNESS>').hexdigest()[:8].upper())"

From the competition network, sign in to the portal with TEAM_ID and team PIN and submit:

Field Value
R4 <R4> (from Chapter 4)
route_string E01>E02>E03>E04
marker_id M4
WITNESS <WITNESS>
checkpoint_code <CHECKPOINT>
LOSS_TENTH_DB 65
DELAY_MS 45
Lambda sequence 41>43>43>42

On success the portal displays a four-digit safe code. It deliberately never shows the nonce or the flag.

Step 8: Safe, slip and final calculation

The registered captain, and only the captain, uses the code on their own room safe and collects the sealed slip containing RELAY_SEAL (16 hex) and SEAL_NONCE (32 hex). Back in the competition area:

R5       = SHA256("LS05|" + R4 + "|" + route + "|" + WITNESS + "|" + RELAY_SEAL)[:12].upper()
TEAM_TAG = HMAC_SHA256(key = bytes.fromhex(SEAL_NONCE),
                       msg = "LS05|" + TEAM_ID + "|" + R5 + "|" + checkpoint_code)[:12].upper()
FLAG     = FLAG{LS05_<R5>_<TEAM_TAG>}
python3 vault_finish.py --team-id TEAM-XX --r4 <R4> \
  --route "E01>E02>E03>E04" --marker M4 --witness <WITNESS> \
  --checkpoint-code <CHECKPOINT> --relay-seal <16HEX> --seal-nonce <32HEX>

The script’s own CHECKPOINT_CODE output matched the value computed independently, which confirmed that the route, marker and witness were all correct before the slip values were used.

Flag

`FLAG{REDACTED}

Vulnerability Analysis

Mitigations

  • Require paired TX and RX receipts from both endpoints with matching receipt codes and clock-corrected timing before accepting any edge.

  • Validate wavelength conversion, service tags, edge status, dwell windows, and loss/delay budgets as independent constraints, not as a single combined check.

  • Use distinct nonces or sequence numbers per receipt direction to prevent replay of one-sided receipts.

  • Treat every record as untrusted until two independent sides agree. Requiring both a TX and an RX receipt from the correct endpoints, with a valid MAC, removes forged and one-sided evidence.

  • Normalise clocks before comparing anything. Raw local_ms values look inconsistent. After subtracting per-station offsets, every genuine receipt matches the origin or origin+latency exactly, and forged ones do not.

  • Eliminate by independent constraints. Wavelength conversion, state and service tags, dwell windows and the loss and delay budgets each remove different decoys. No single filter finds the answer on its own.

  • Several decoys pass the cryptographic check. E12, E15 and the E09/E10 branch have valid receipts and fail only on budgets or timing. A valid MAC proves authenticity, not suitability.

  • Automate the search. A 40-line verifier plus DFS found the unique route and removes hand-pruning mistakes.

  • Chained challenges need disciplined secret handling. R4, R5, the witness, the seal and the nonce are all inputs to later steps. Keep them out of shared writeups and chat, and mask them the way the vault style guide requires.

  • Physical steps are in scope only as stated. Read the authorised marker and open your own safe, nothing else.

Techniques

  • HMAC Verification
  • Clock Skew Correction
  • Graph Path Search
  • Hash-Derived Selectors
  • Chained Challenge Secrets