Day 16 - Wasm Up (binary-reverse-engineering)
GM id: binary-reverse-engineering-day-16-webassembly-optimization-equivalence Agent: agent-2 | Lane: binary-reverse-engineering | 160 answer ids (Single / Time Trial), 800 (Mastery)
Result - every mode CORRECT
| Mode | Result | Flag |
|---|---|---|
| Single Solve | CORRECT | Tokenbe2cbd8e8fbb533080b925755e0e72b2 |
| Time Trial | CORRECT | Tokena7220f7810a88737d346487c757d49ca |
| Mastery | CORRECT | Token401269f4f03755353fcd6e7060352979 |
The challenge
WebAssembly runs in a sandbox, but the sandbox has doors: imports, memory, indirect calls. Map every door in this module and inventory what passes through.
The artifact is the lane's usual cumulative AES-ZIP evidence bundle (artifact_0.bin (challenge artifact, not published), 32,253,202 bytes, password infected), 19 members: the d01..d15 binaries from every earlier day in this lane plus the new Day 16 block - two WebAssembly modules:
d16--variant-000-direct.wasm 570 bytes
d16--variant-000-compact.wasm 561 bytes
"Optimization equivalence" is the point of the pair: both export the same evaluate function (same type (i32) -> i32) and the direct build spells the logic as nested if/else blocks while the compact build is the same function folded into select instructions - different code sections, identical semantics, identical embedded config.
What was already solved at claim
The banked lane adapter (challenges/_lib/autosolve_binary.py) answered 156 of 160 fields at claim time and correctly HELD the rest rather than guessing. The residue was exactly four ids, all of them the new wasm layer:
d16_analysis_direct_format d16_analysis_direct_architecture
d16_analysis_compact_format d16_analysis_compact_architecture
Note what the contract does not ask: there is no d16_analysis_machine. Every earlier day pairs analysis_machine with analysis_architecture; a wasm module has no executable-header machine field, and the question set reflects that. That absence is the clue that *_architecture is a real, separate fact here, not a restatement of a machine code.
The member-tag routing (direct / compact in the field id, the Day 15 "Stripped" shape) and the HCFG config extraction already worked on the wasm bytes - the config answers were among the 156 accepted - so only the two label families needed building.
Solving the new layer
1. Classify from the bytes
00000000: 0061 736d 0100 0000 \0asm, version 1 (MVP)
autosolve_binary.kind() returned "unknown" for \0asm, which is why the two label fields had no handler. Added the container:
if b[:8] == b"\x00asm\x01\x00\x00\x00" or (b[:4] == b"\x00asm" and len(b) >= 8):
return "wasm"
2. The format label
The GM's format vocabulary in this lane is the short lowercase container token, never a tool sentence - 96+ graded samples give elf, pe, pe_cli, jar (accepted_values.py show). So the wasm container token is wasm, not WebAssembly (wasm) binary module version 0x1 (MVP).
3. The architecture label
A wasm module carries exactly one piece of address-width evidence: the limits flags byte of its memory type. Section id 5 of both members is:
05 83 80 80 80 00 section 5, LEB size (5-byte padded)
01 one memory
00 01 limits flags 0x00, min 1 page
Flags bit 0x04 is the memory64 bit; it is clear, so the module addresses 32-bit memory -> the wasm target name is wasm32. _wasm_arch() walks the sections LEB-aware (the generator pads every section size to 5 bytes, so a naive single-byte size read desynchronises immediately) and returns wasm64 when that bit is set, wasm32 otherwise.
4. The doors the prompt asks about (read, then answered where asked)
Section inventory of both members, identical:
sections : type, function, memory, export, code, data
exports : memory (memory 0), evaluate (func 0)
imports : 0 <- the "doors": this module imports nothing
tables : none -> no indirect call surface
So the sandbox doors are: no imports, one exported 1-page memory, one exported function evaluate, no table and therefore no call_indirect. What passes through the exported memory is the data segment - and that is where the lane's usual payload lives.
5. The HCFG record inside the data segment
Data segment 0 is an active segment at i32.const 0x400 holding the familiar record:
offset 125 (direct) / 116 (compact)
'HCFG' 01 c1 6f 01 e5 27 cf f6 magic, version 1, xor key 0xc1, len 367 LE, crc32 LE
XOR the 367 payload bytes with 0xc1:
{"campaign":"BR16-000","domain":"node-000.day16.example.invalid","ipv4":"198.51.100.60",
"url":"https://node-000.day16.example.invalid/api/BR16-000","mutex":"Global\\HuntressBR16_000",
"windows_path":"C:\\ProgramData\\HuntressLab\\day16\\BR16-000.dat",
"linux_path":"/var/tmp/huntress-lab/day16/BR16-000.dat",
"service":"HuntressLab-Day16-000","host_model":"workstation"}
Both members carry byte-identical configs - the "equivalence" again. A second data segment at i32.const 0x800 holds the marker strings huntress.binary.dynamic_trace.v1 and sandboxed_module_inventory.
Submitted values for the four new ids
| id | value |
|---|---|
d16_analysis_direct_format | wasm |
d16_analysis_compact_format | wasm |
d16_analysis_direct_architecture | wasm32 |
d16_analysis_compact_architecture | wasm32 |
(context) d16_artifact_sha256_1 | d7b5f809180c62f5033830a3d53158db6eae315046fa6b50a3caed52155a5269 |
(context) d16_artifact_sha256_2 | 1c68c4062584495311c2f4894c3db30ba37e6372c17d8eede1e96a247751fdee |
Verification before any GM call
scripts/local_check.py replays the saved contract plus the real artifact bytes through autosolve_binary.analyse() offline, with no GM call at all. It printed:
sure=160 probe=0 unknown=0
Only then was AUTOSOLVE rerun. One submit per mode:
binary: 160 sure, 0 probe, 0 unknown (3.7s)
AUTOSOLVE single_solve: CORRECT in 9.8s
AUTOSOLVE time_trial: CORRECT in 4.4s (160 sure, 0 probe, 0 unknown)
AUTOSOLVE mastery: CORRECT in 70.5s (800 sure, 0 probe, 0 unknown)
The timed variants mutate the bundle but not the slot shapes, so the same extractor that solved the Single derived every answer from each attempt's own bytes - no re-analysis inside a 30 s window.
Regression cover added
challenges/_lib/_test_binary_universe.py gained a self-contained wasm shape (no compiler needed): build_wasm(tag, memory64=False) emits a minimal valid module - type / function / memory / export / code / data - with the HCFG record as its active data segment. Three new checks:
- a
direct+compactpair: 12 fields correct (formatwasm, architecturewasm32, config routed per member tag); analysis_machineon a wasm module stays HELD (no header field to read - never guessed);- a memory64 module answers
wasm64.
RESULT: PASS - 45 shapes, 1369 field answers correct, 59 checks, 0 wrong. Re-ran the neighbours: _test_binary_container_catalog.py 19/19 PASS, _test_binary_hdr_struct.py PASS.
Lessons
- A missing question is evidence. The absence of
d16_analysis_machinesaid the generator knew a wasm module has no e_machine, which made*_architecturea distinct fact (the address width) rather than a second spelling of a machine code. - The grader's vocabulary is the short lowercase container token. 144 graded
analysis_formatsamples (elf/pe_cli/jar) settle the spelling for any new container:wasm, not afilesentence. - Parse wasm section sizes as LEB128. The generator pads every size to 5 bytes (
86 80 80 80 00= 6); a single-byte size read desynchronises on the first section. - Only one layer changed. The spine (member-tag routing, HCFG scan, sha ordering, 156 of 160 fields) was already banked - extending
kind()plus two label branches was the whole build.