keystore misuse: base64 again, and a keystore that was only a story

huntress ctf 2026, day 13 · mobile android · all three modes

tools used: android apk toolkit, decoding engine and timed-attempt pipeline.

the prompt: "recover data protected by an app-controlled wrapping key despite nominal keystore use." each delivery was an apk with one question: the answer code its puzzle protects.

the key insight: the prompt describes a real android mistake, an app that uses the keystore by name but wraps its data with a key it controls itself. the apk did not contain that mistake. its puzzle file declared plain base64, the codec of days 3 and 9, and held no key, no wrapped blob and no keystore alias to unwrap. the answer was one base64 decode away.

challenge shape

single        1 field    one apk
time trial    1 field    one apk
mastery       3 fields   three apks

the field is answer (setK.answer in mastery): an ANS- code of sixteen uppercase hexadecimal digits.

artifact anatomy

the puzzle lives in assets/huntress_puzzle.json: a codec name and the encoded data, the same layout as every earlier day.

{"schema": "huntress.mobile.puzzle.v1", "day": 13, "codec": "base64", "data": "QU5TL..."}

no other key in the file, no string resource or class carried key material, and the manifest declared nothing keystore-related; the story lives in one dex label string (DAY-13:keystore_wrapper:app-controlled wrapping key).

extraction method

the codec name is resolved into steps, and every transform the decoding engine knows is also a codec name. the steps run over every reading of the data, and only a result of the answer's shape is returned; a codec that yields none falls back to a keyed search and then to the decoding engine's peel, and says so:

codec = _codec_text(puzzle.get("codec", "plain"))
data = _data_text(puzzle.get("data", ""))
try:
    steps = _steps(codec)
except ValueError:
    steps = []  # a codec name nobody has seen: the searches below
for out in _chain(steps, data, puzzle):
    found = _answer(out)
    if found is not None:
        return found

the base64 prefix is already a tell: every code encodes to text starting QU5TL (ANS and the top bits of -), and the sixth character is T when the first hex digit is 0 to 9 and U when it is A to F. by hand:

answer = base64.b64decode(puzzle["data"], validate=True).decode()

validation and answer formatting

the decoded text must match the answer pattern exactly, ANS- and sixteen uppercase hexadecimal digits; a reading that does not is never submitted. each mastery apk is decoded on its own.

failed approaches and pivots

none on the day. the story pointed at aes and an unwrapped key, so the same day the apk codecs learned aes in every common mode, with key and iv layouts an app would use; that work is described in the android apk toolkit.

automation across modes

the same decode answered the single, the time trial and the three mastery apks.

lessons

solve times

public scoreboard · day 13 finish: top 10

  • 0:03.0single#2 of 192 solvers
  • 0:04.7time trial#2 of 186 solvers
  • 0:06.5masteryfirst blood, +0.20 s
  • #4team day finishof 165 teams that cleared it, in 1:55.2
  • #2single 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 1.9s 1 0
time trial 1.6s 1 0
mastery 1.8s 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.7s 49.3s
mastery 110.0s 0.5s 109.5s

where we got stuck

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

{generated by a clanker}