wasm up: one function compiled twice, and a role in the file name

huntress ctf 2026, day 16 · binary reverse engineering · all three modes

tools used: binary analysis toolkit and timed-attempt pipeline.

the prompt: "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 cumulative bundle gained a sixteenth day tag holding two webassembly modules: the same small function compiled two ways.

the key insight: the field names had day 15's shape. d16_analysis_compact_format is the ordinary format of the member whose file name says compact, and the toolkit had webassembly readers since day 7 and role routing since day

  1. the doors the prompt lists were not asked on day 16.

challenge shape

single        160 fields   one bundle, tags d01-d16
time trial    160 fields   a fresh bundle
mastery       800 fields   five bundles

the day 16 fields:

d16_artifact_sha256_1, d16_artifact_sha256_2
d16_analysis_{compact,direct}_{architecture,format}
d16_analysis_compact_config_{campaign,domain,mutex,url}

artifact anatomy

d16--variant-NNN-direct.wasm
d16--variant-NNN-compact.wasm

each module is a few hundred bytes. both modules have the same six sections: type, function, memory, export, code and data. there is no import section, no table and no element segment, so the module calls nothing outside itself and has no indirect calls; the one door is the exported linear memory. the exports are memory and evaluate, a function from i32 to i32.

the two builds differ only in the code section. the direct build branches:

local.get 0
i32.eqz
if (result i32)
  i32.const A
else
  local.get 0  i32.const 1  i32.eq
  if (result i32)
    i32.const B
  else
    local.get 0  i32.const 2  i32.eq
    if (result i32)  i32.const C  else  i32.const D  end
  end
end

the compact build evaluates every arm and picks with select, innermost first:

i32.const A  i32.const B  i32.const C  i32.const D
local.get 0  i32.const 2  i32.eq  select    ;; x == 2 ? C : D
local.get 0  i32.const 1  i32.eq  select    ;; x == 1 ? B : that
local.get 0  i32.eqz              select    ;; x == 0 ? A : that

both map 0, 1 and 2 to their constants and everything else to the fourth, so they are equivalent; branches against a branchless select chain is the "optimization" in the challenge's name.

the data section holds two active segments. the first is the lane's hcfg blob (the HCFG magic, a version, a one-byte xor key, the length, a crc32 and the xor'd json configuration). the second carries the schema name of the lane's dynamic-trace description. both segments are copied into linear memory at fixed offsets when the module is instantiated, so the configuration is what passes through the memory door.

extraction method

a field dNN_analysis_<role>_<field> is routed when <field> is a field a producer answers and <role> names exactly one member of the tag that has a sibling differing by that word alone (day 15). here the roles are direct and compact. the rest is old work: the format is named from the bytes, the architecture comes from the webassembly reader, and the configuration from the hcfg carrier search, which finds the raw magic in the data segment and validates it by its crc and its json. the blob's header layout and a parse in a few lines of python are in the hcfg section of the tool article; here the first data segment's bytes are the blob itself, so module.find(b"HCFG") on the raw file lands on it.

validation and answer formatting

the format is wasm and the architecture wasm32: the names the readers have produced for webassembly since day 7, graded for the first time on day

  1. the configuration values are read from the

validated json as stored; a blob that fails its crc or does not parse to an object is never used. the two sha-256 fields hash each member's delivered bytes.

automation across modes

the time trial and the mastery carry other variant numbers and other configurations; the role words pick the same members in each, and the carrier search finds each configuration from its own bytes.

the doors themselves were left for the next day: the webassembly reader now lists imports, exports, tables, memories, element and data segments and counts calls and indirect calls with a real instruction decoder (see day 16 additions).

lessons

solve times

public scoreboard · day 16 finish: 1st

  • 0:05.5singlefirst blood, +5.4 s
  • 0:11.0time trialfirst blood, +6.9 s
  • 0:18.0masteryfirst blood, +45.1 s
  • #1team day finishof 162 teams that cleared it, in 1:02.1
  • #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 the mode's first start on the game master to its correct submit.

mode work to flag attempts wrong submits
single 3.3s 1 0
time trial 4.1s 1 0
mastery 4.5s 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 80.0s 4.1s 75.9s
mastery 320.0s 4.5s 315.5s

where we got stuck

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

{generated by a clanker}