universal appeal: the cpu types a mach-o advertises
huntress ctf 2026, day 20 · metadata forensics · all three modes
tools used: archive and file metadata, cross-lane field resolution and timed-attempt pipeline.
macos binaries, thin and universal, and the question of which cpu types a fleet of them "truly supports". the single asked one file for its cpu_type_set; the timed modes asked the same beside one question from every family the category has used so far.
the key insight: the property is a set over records. a thin mach-o has one header and one cpu type; a universal binary has a fat header and one fat_arch entry per architecture, each with its own cpu type. the answer is the set of those values, and the struct table that reads a single header field needed one more rule: a trailing set word collects the field over every record the file carries.
challenge shape
single 1 field macho cpu_type_set of one macos binary
time trial 25 fields one of each family (days 4-20) plus roster,
evidence-note and a synthesis hash order
mastery 125 fields five sets of the time trial's mix
the question: "determine macho.cpu_type_set for macos-001.bin", answer kind json, syntax "compact valid json array with exact values and order; no markdown or explanatory text".
artifact anatomy
thin (64-bit) offset size field
0x00 4 magic cf fa ed fe (little-endian)
0x04 4 cputype
0x08 4 cpusubtype
0x0c 4 filetype
fat (universal) 0x00 4 magic ca fe ba be (big-endian)
0x04 4 nfat_arch
fat_arch[i] +0 4 cputype
(20 bytes each) +4 4 cpusubtype
+8 4 offset +12 size +16 align
the thin magic's byte order sets the order of its fields; a fat header is always big-endian. ca fe ba be also opens a java class file, which is told apart by the value after the magic (a class version is far larger than any arch count).
extraction method
the metadata solver resolves a property name against a table of structs (family, struct, fields with their offsets and sizes, a byte-order rule). macho-cpu-type-set names the family macho, the field cputype, and the word set. two structs of the family own a cputype, the thin header and fat_arch; the solver keeps the struct whose records these bytes actually carry (a fat reader raises on a thin file and the other way round), reads the field once per record and serializes the values.
def struct_set(prop, data):
hits = structs_naming(prop) # header.cputype, fat_arch.cputype
readable = [(s, f, s.records(data)) for s, f in hits if s.reads(data)]
(s, field, records), = readable # exactly one struct reads these bytes
hexed = [f"0x{v:0{2 * size}x}" for v, size in (rec.int(field) for rec in records)]
return [compact_json(sorted(set(hexed))), compact_json(hexed)] # ranked
the same read without the table, for one file:
data = Path("macos-001.bin").read_bytes()
if data[:4] == b"\xca\xfe\xba\xbe": # fat: big-endian, 20-byte fat_arch
n = int.from_bytes(data[4:8], "big")
types = [int.from_bytes(data[8 + 20 * i:12 + 20 * i], "big") for i in range(n)]
else: # thin: the magic gives the order
order = "little" if data[:4] in (b"\xcf\xfa\xed\xfe", b"\xce\xfa\xed\xfe") else "big"
types = [int.from_bytes(data[4:8], order)]
print(json.dumps(sorted({f"0x{t:08x}" for t in types}), separators=(",", ":")))
validation and answer formatting
a name two readable structs own stays a crash (never a guess); a field that runs past the member end raises. the graded form is a compact json array of strings, each the raw cputype as 0x and eight lowercase hex digits: the u32 width, with the 64-bit abi flag in the top byte kept, not masked off. the grader rejected the architecture's name as the element and the cputype as a bare decimal json number. the order was never graded: every file in all three modes was a thin 64-bit little-endian mach-o with one cpu type, so the reader still returns the plausible orders as ranked candidates (sorted unique first, then record order).
failed approaches and pivots
- the first two submits serialized the set wrongly (the architecture's name, then the cputype as a decimal number); the third, the width-padded hex string, was right. the lesson is in the struct table: a field's rendering is fixed by its width, and a set inherits it.
automation across modes
the set rule is generic: any struct field in the table can be asked as a set, and the fat_arch entries make every universal binary's per-arch fields addressable by name (macho-fat-arch-cputype-u32-hex, offset, size, align). the other 24 families of the timed modes resolve through the same name-to-reader path as on earlier days.
lessons
- a property that aggregates (
set,list) is a struct read repeated over records plus one serialization rule; keep the records model and the rule falls out. - when two structs of a family name the same field, let the bytes choose: the struct that parses is the one the question means.
solve times
public scoreboard · day 20 finish: below top 10
- 0:38.6single#4 of 176 solvers
- 0:56.5time trial#5 of 171 solvers
- 0:58.4mastery#4 of 171 solvers
- #25team day finishof 150 teams that cleared it, in 12:50.9
- #4single orderof the day's 7, 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 the mode's first attempt start to its flag (server times).
| mode | work to flag | attempts | wrong submits |
|---|---|---|---|
| single | 37.8s | 1 | 2 |
| time trial | 0.6s | 1 | 0 |
| mastery | 0.9s | 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 | 50.0s | 0.6s | 49.4s |
| mastery | 170.0s | 0.9s | 169.1s |
where we got stuck
- the
setword: the struct table knewcputypebut no reader took the aggregate, so the single was read by hand and its serialization guessed (two wrong submits, 37.8s). the set rule and the fat_arch records now answer it from the table. - the timed modes started 17s after the single's flag while the reader for the new property was being written; writing the reader first and submitting from it would have removed the wait.
flags: single, time trial, and mastery [redacted].
{generated by a clanker}