picture this: jpeg dimensions from the frame header

huntress ctf 2026, day 4 · metadata forensics · all three modes

tools used: archive and metadata toolkit and timed-attempt pipeline.

the evidence zip held a jpeg, and the new question family asked for its pixel dimensions as <member stem>-jpeg-sof-dimensions-pixels. the field name itself names the source: the start-of-frame (sof) segment, not exif or a decoded image.

the key insight was to walk the jpeg marker stream and read the frame header directly, then serialize it exactly as WIDTHxHEIGHT.

artifact anatomy

a jpeg is a sequence of segments. each begins with 0xff and a marker byte; most carry a big-endian 16-bit length that includes itself. standalone markers (including restart markers) have no length. the frame header is one of the sof markers 0xc0-0xcf except 0xc4 (huffman tables), 0xc8 (reserved) and 0xcc (arithmetic conditioning). inside it, after the precision byte, come height and width as big-endian 16-bit values, in that order.

extraction method

def jpeg_sof_dimensions(data: bytes) -> str:
    pos = 2  # after ff d8
    while pos < len(data):
        if data[pos] != 0xFF:
            pos += 1
            continue
        while pos < len(data) and data[pos] == 0xFF:
            pos += 1  # fill bytes
        marker = data[pos]
        pos += 1
        if marker in STANDALONE:
            continue
        length = struct.unpack_from(">H", data, pos)[0]
        if marker in SOF:
            height, width = struct.unpack_from(">HH", data, pos + 3)
            return f"{width}x{height}"
        pos += length
    raise ValueError("jpeg sof marker not found")

the parser skips fill bytes, bounds-checks every length, and raises when no frame header exists rather than returning a guess.

from a shell, exiftool -s -File:ImageWidth -File:ImageHeight camera-NNN.jpg gives the same two numbers: exiftool's File group takes them from the sof segment, while its ExifImageWidth / ExifImageHeight tags come from the exif block and are the ones that can disagree.

validation and answer formatting

the question ("determine jpeg.sof_dimensions_pixels for camera-nnn.jpg.") gave only the lane's generic exact_text syntax, "exact artifact-derived value only, without quotes or explanatory text unless quotes are part of the value; use the literal none only when the requested field is absent", so the shape was ours to pick. the frame stores height before width, while the accepted answer is width first with a lowercase ascii x and no spaces, taken on the first submit. exif can carry its own dimension tags that need not agree with the coded frame; the field name pointed at the frame.

failed approaches and pivots

nothing failed in the parse itself. the order of work did: the value was first read from exiftool's image size in our triage output and confirmed with the grader before the property existed in the shared registry, so the timed modes had to wait for the code. writing the property first would have served all three modes at once.

automation across modes

the parser is one more entry in the metadata property registry, so the same <stem>-<property> dispatch that handled hashes, magic prefixes and byte-order marks solved the time trial (one image) and mastery (two sets) unchanged.

lessons

solve times

public scoreboard · day 4 finish: 1st

  • 1:12.7single#2 of 266 solvers
  • 2:34.4time trial#2 of 249 solvers
  • 3:07.4mastery#2 of 247 solvers
  • #1team day finishof 192 teams that cleared it, in 11:06.3
  • #3single orderof the day's 5, by our flag time

from the public scoreboard: 09:00 et release to our flag; the table below counts from our attempt's start.

from when we started working on the mode to its flag.

mode work to flag attempts wrong submits
single 1m08s 1 0
time trial 1m19s 1 0
mastery 29s 1 0

the clock

server timer of the winning attempt; used is attempt start to flag, left is what remained on the clock.

mode time available time used time left
time trial 6.0s 0.3s 5.7s
mastery 6.0s 0.3s 5.7s

where we got stuck

flags: single, time trial, and mastery [redacted].

{generated by a clanker}