spot the difference: two scala builds and the configuration they share
huntress ctf 2026, day 24 · binary · all three modes
tools used: binary-analysis toolkit and timed-attempt pipeline.
"two builds, one fix. diff the vulnerable function against its corrected twin and pinpoint exactly what changed, then prove the old one was really broken." the day's new tag was a pair of java archives built from scala: a vulnerable build and its corrected twin.
the key insight: as on day 23, the story is dynamic and the questions are static. the new tag's twelve fields ask for the two members' hashes, each member's format and the configuration record both builds carry; none asks about the diff. the diff is real, small and worth reading, and the answers come from the same readers as every earlier jar.
challenge shape
single 288 fields 24 tags (d01..d24), twelve fields each; d24:
two member hashes, two formats, the shared
config and the corrected build's config
time trial 288 fields the same over a fresh bundle
mastery 2304 fields the same over eight bundles
artifact anatomy
the d24 members are d24--sample-vulnerable.jar and d24--sample-corrected.jar. each is a zip with a manifest (a Main-Class and a Created-By naming a scala build factory) and two class files: a scala object compiled to a <Name>$ class holding the code, and a forwarder class with static stubs. the object's four public methods are encodedConfig, decodeConfig, score and main.
the configuration is the event's hcfg record, base64-encoded as one long string constant in the object class's constant pool (base64 of HCFG starts SENGR). the question spells the layout out:
offset size field
0 4 "HCFG"
4 1 version
5 1 xor key
6 2 payload length, little-endian
8 4 crc-32 of the decoded payload, little-endian
12 n payload: json, each byte xored with the key
the json has a campaign, a domain, an ipv4 address, a url, a mutex, windows and linux paths, a service name and a host model. the two builds carry byte-for-byte the same record.
the fix is in score. reconstructed from the bytecode, the vulnerable build is
def score(input: String): Int =
if (input.nonEmpty) input.charAt(0) else -1
and the corrected build is
def score(input: String): Int =
Option(input).filter(_.nonEmpty).map(_.charAt(0).toInt).getOrElse(-1)
nonEmpty on a String compiles to a call of StringOps.nonEmpty$extension, which calls length() on the string, so a null input throws a NullPointerException in the vulnerable build; Option(null) is None in the corrected one, and the method returns -1. that is the proof the prompt asks for: the old function crashes on a missing input. main reads a host-model environment variable and prints one json trace line describing the branch it took.
extraction method
nothing new: the binary toolkit answers each field by its producer.
- hashes: the tag's members in zip central-directory order, sha-256 over their exact bytes.
- format: classified by magic and parsed container; a zip whose entries include class files is
jar(both members gradedjar, from the enumelf,pe,pe_cli,jar,wasm,neko_bytecode). - configuration: the class-file reader walks every class's constant pool (days 6 and 8); each utf-8 constant of at least 80 base64-alphabet characters is decoded, and the first decode that is a crc-valid hcfg record is parsed as json.
- the corrected build's fields: a word of the field name (
corrected) that names exactly one member, whose sibling differs only by that word, routes the field to that member (day 15's stripped and symbolized pair, day 21's loader and plugin). the questions name the member the same way: "use the unique d24-- member whose basename ends corrected.jar"; the four plainconfig_*questions say "decode both d24-- role members and require their config objects to be byte-for-byte equal before using the common value".
for cls in class_files(jar):
for text in utf8_constants(cls):
if len(text) >= 80 and BASE64.fullmatch(text):
raw = base64.b64decode(text)
record = hcfg(raw) # None unless magic, bounds and crc agree
if record is not None:
return json.loads(record.payload)
by hand, unzip -p d24--sample-corrected.jar '*$.class' | strings -n 80 prints the long constants; the one starting SENGR base64-decodes to the record, which then parses like every other hcfg blob.
validation and answer formatting
the hcfg record is accepted only when its magic, its length and the crc-32 of the xor-decoded payload agree. the shared fields require the two builds' records to be byte-for-byte equal before using the common value; our producer takes the first valid record among the tag's members and does not compare them. in all ten bundles we received (the single, the time trial and the mastery's eight) the two records were identical, which we checked separately; a producer that compared them would fail loudly on a bundle where they differ, and that is the better design.
failed approaches and pivots
none on day 24.
automation across modes
the compound producers answered all 24 tags in every bundle; the mastery's eight bundles of 288 fields each were solved in about 0.2 seconds once downloaded.
lessons
- a patch-diffing story can still be graded on static facts: read the questions before reading the diff.
- when a question states a precondition ("byte-for-byte equal"), check it in code even when the data always satisfies it; the day it does not is the day it matters.
solve times
public scoreboard · day 24 finish: top 3
- 0:07.2singlefirst blood, +3.5 s
- 0:12.0time trialfirst blood, +4.1 s
- 0:18.8masteryfirst blood, +7.3 s
- #3team day finishof 139 teams that cleared it, in 3:47.1
- #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 start on the game master to its correct submit.
| mode | work to flag | attempts | wrong submits |
|---|---|---|---|
| single | 5.7s | 1 | 0 |
| time trial | 3.1s | 1 | 0 |
| mastery | 5.1s | 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 | 3.1s | 76.9s |
| mastery | 530.0s | 5.1s | 524.9s |
where we got stuck
- nowhere on day 24: a jar, a constant-pool config and a role pair were all shapes the producers already read; most of each mode's time was the bundle download (tens of megabytes per bundle).
flags: single, time trial, and mastery [redacted].
{generated by a clanker}