jni boundary: a native library, and an answer that was never across it

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

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

the prompt: "identify a java-to-native type or length assumption that changes backend authorization." the apk kept day 15's shape: dex code, a challenge-owned native library, and a puzzle asset whose codec is named native.

the key insight: the story is about the boundary between java and native code, but the puzzle's data already reads as the answer's own shape, and the solver accepts a reading only in that shape. a codec name it does not know costs nothing when one of its readings validates.

challenge shape

single        1 field    one apk
time trial    1 field    another apk
mastery       5 fields   five apks

the question names a case id and the app's package and asks for "the exact backend answer code returned for this case": ANS- and sixteen uppercase hex digits.

artifact anatomy

AndroidManifest.xml
classes.dex                     MainActivity, ChallengeActivity, JNIBoundary
assets/huntress_puzzle.json     {"schema": ..., "day": 16, "codec": "native", "data": ...}
lib/x86_64/libarena.so          the challenge's native library
META-INF/...                    the signature

the dex names the scenario (a jni_length key next to a "java-to-native validation mismatch" label) and an evidence endpoint that takes a case_id. the native library is a small elf that keeps its symbol table: two exported functions (a secret and the day number) and a read-only value in .rodata. in the single's apk that value and the puzzle's data are the same code.

the mastery's five apks carry earlier days' codecs, one per set: plain, hex, reversed, caesar with a key, and native again.

extraction method

the puzzle names its codec. a known name selects its transforms and key source; an unknown name selects none, so the data itself is checked first, and then the keyed and unkeyed searches run. the first reading in the answer's shape wins. for native the data is already an ANS- code.

def decode(puzzle, keys=None):
    codec, data = codec_text(puzzle["codec"]), data_text(puzzle["data"])
    try:
        steps = steps_for(codec)      # a known name: its transforms and key
    except ValueError:
        steps = []                    # an unknown name: the data as it is
    for out in chain(steps, data, puzzle):
        if is_answer(out):
            return out
    keyed = keyed_peel(data)          # single-byte keys, 2-4 byte keys
    if keyed is not None:             # recovered from the ANS- prefix
        return keyed
    text, path = peel(data, goal=is_answer)   # every transform, breadth-first
    return answer_in(text)

by hand, with nothing but the standard library:

import json, re, zipfile

apk = zipfile.ZipFile("jni_boundary.apk")
puzzle = json.loads(apk.read("assets/huntress_puzzle.json"))
assert puzzle["codec"] == "native"
assert re.fullmatch(r"ANS-[0-9A-F]{16}", puzzle["data"])  # the code, as stored

on the single, strings lib/x86_64/libarena.so | grep ANS- prints the library's .rodata copy of the same code.

validation and answer formatting

a reading is accepted only when it matches the question's pattern, ANS- plus sixteen uppercase hex digits; a reading that fails it is a crash, never a guess. the solver never reads the library; on the single its .rodata value and the puzzle's data agree, so either source would have done.

automation across modes

the same decoder answered the single, the time trial and all five mastery sets; each set's codec comes from its own puzzle asset.

lessons

solve times

public scoreboard · day 16 finish: 1st

  • 0:04.0singlefirst blood, +0.25 s
  • 0:06.0time trialfirst blood, +0.66 s
  • 0:08.8masteryfirst blood, +0.48 s
  • #1team day finishof 162 teams that cleared it, in 1:02.1
  • #1single 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.0s 1 0
time trial 0.6s 1 0
mastery 1.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 50.0s 0.6s 49.4s
mastery 170.0s 1.1s 168.9s

where we got stuck

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

{generated by a clanker}