Skip to content
Adam Omar Saleh

Chronos Security logo, as used by CSCTF 2026CSCTF 2026Mobile

VaultKeeper

The note is an AES-GCM blob stored in a string resource. Its key is built from three values, and all of them can be recovered from the APK without running it:

Competition
Chronos Security logo, as used by CSCTF 2026CSCTF 2026
Category
MobileEasy
Source status
Source-documented · not platform-verified
Document
PDF edition3 min read

Brief

The challenge

Category
Mobile
Difficulty
Easy
Points
120
Author
Pratik Shetty
File
vaultkeeper.apk (SHA-256 79559746ad419b219c88b362ff89b667993bad726e3b7109501b075c007de2ed)

Responders seized a field handset during coordinated attacks on emergency communications. Recover that note from the APK. The surviving handover card carries authorization code ZHUU-SANS-9XJN-QPCQ. Analyze the package offline; you do not need to install it or complete its UI workflow.

Challenge page
Challenge page

TL;DR

The note is an AES-GCM blob stored in a string resource. Its key is built from three values, and all of them can be recovered from the APK without running it:

Python
key = SHA256( "KJSC-" + certSHA256[:8] + "-RECOVERY"   // recovery_token, derived from the signing cert            + "4972"                                    // archive digits, pinned by the receiver's HMAC check            + "ZHUU-SANS-9XJN-QPCQ" )                   // handover authorization code typed into the main screennote = AES-GCM-decrypt(key, iv = blob[:12], ct||tag = blob[12:])

01

Recon

The APK has a single classes.dex with no native libraries. The app's own code is in com.vaultkeeper:

  • IntroActivity, which is the launcher.

  • MainActivity, the vault screen with an input field and an unlock button.

  • ArchiveActivity, which takes a 4-digit code.

  • RecoveryDiagnosticsActivity, which handles the deep link vault://recover?stage=1.

  • RecoveryStage2Receiver, a broadcast receiver.

  • VaultDiagnosticsProvider, a content provider at content://com.vaultkeeper.provider.diagnostics/keys.

  • LegacyRecoveryActivity, a decoy that only prints "channel decommissioned".

jadx hung on this APK, so I dumped the bytecode with androguard instead (dump.py, dump2.py).

02

The intended UI workflow

On a device the unlock works in two stages:

  1. Stage 1. Open vault://recover?stage=1 with the extra recovery_token set to the value the content provider returns. RecoveryDiagnosticsActivity then sets stage1_complete.

  2. Stage 2. In ArchiveActivity, type 4 digits. The activity stores them as archive_digits_cache and shows archive_key = HMAC-SHA256("VK-7F42", digits)[:8].upper(). Send that key as the archive_key extra to RecoveryStage2Receiver. If it equals 3778F16D, the receiver sets stage2_complete.

  3. Unlock. Once both flags are set, the unlock button in MainActivity (handler H0/d, case 2) decrypts the note.

03

The decryption routine

From H0/d.onClick:

Python
token  = A.c.a0(context)                       // provider's recovery_tokendigits = prefs["archive_digits_cache"]input  = MainActivity EditTextkey    = SHA256(token + digits + input)blob   = Base64(getString(0x7f0f0038))AES/GCM/NoPadding, iv = blob[0:12], 128-bit tag, ct = blob[12:]

So the stage flags only gate the UI. What actually matters is the three key inputs.

04

Recovering each input offline

recovery_token. A.c.a0 takes SHA-256(signatures[0].toByteArray()), which is the SHA-256 of the DER signing certificate, keeps the first 8 hex characters, uppercases them and wraps them:

Python
cert SHA-256 = 1C28DC7E5AB079FF...recovery_token = KJSC-1C28DC7E-RECOVERY

Archive digits. String resource 0x7f0f0020 is the HMAC key VK-7F42. The receiver hard-codes the expected key 3778F16D, and only one 4-digit value out of 10,000 produces it:

Text
HMAC-SHA256("VK-7F42", "4972")[:8] = 3778F16D  →  digits = 4972

User input. This is the handover card's authorization code from the briefing: ZHUU-SANS-9XJN-QPCQ.

05

Decrypt

GCM authenticates the ciphertext, so a successful decrypt confirms all three inputs are correct.

Text
$ python solve.pyhmac key resource: VK-7F42recovery_token: KJSC-1C28DC7E-RECOVERYarchive digits: ['4972']note: CSCTF{intent_uri_and_a_broadcast_unlock_the_vault}

Solve script

solve.py:

Python
import base64, hashlib, hmacfrom androguard.core.apk import APKfrom cryptography.hazmat.primitives.ciphers.aead import AESGCM​a = APK("vaultkeeper.apk")res = a.get_android_resources()hmac_key = res.get_resolved_res_configs(0x7f0f0020)[0][1]blob = base64.b64decode(res.get_resolved_res_configs(0x7f0f0038)[0][1])cert_sha = a.get_certificates()[0].sha256_fingerprint.replace(" ", "")token = f"KJSC-{cert_sha[:8].upper()}-RECOVERY"​digits = [f"{i:04d}" for i in range(10000)          if hmac.new(hmac_key.encode(), f"{i:04d}".encode(), hashlib.sha256).hexdigest()[:8].upper() == "3778F16D"]​code = "ZHUU-SANS-9XJN-QPCQ"iv, ct = blob[:12], blob[12:]for d in digits:    key = hashlib.sha256((token + d + code).encode()).digest()    print(AESGCM(key).decrypt(iv, ct, None).decode())

Flag

Flag

CSCTF{intent_uri_and_a_broadcast_unlock_the_vault}

Source-documented · not platform-verified

Takeaways

  • Multi-stage UI gates (deep links, broadcasts, provider tokens) are just state flags. Go straight to the code that uses the secret and rebuild its inputs.

  • PackageInfo.signatures[0] is the DER signing certificate, so any key "bound to the device" this way is really bound to the APK and can be recovered offline.

  • A truncated HMAC over a 4-digit space reveals its input: brute-force all 10,000 values against the hard-coded comparison.

PDF edition

Writeup PDF

Formatted edition of this walkthrough, built from my source notes · 5 pages.