Skip to content

OmniCTF 2026 Quals

OmniCTF 2026 Quals

Writeup for a fun rev challenge from OmniCTF 2026 Quals.

OmniCTF 2026 Quals

Challenge: credvault (Archive [external])

Category: rev

Description:

PktTrack’s mobile team extracted credvault from a rooted Android device. The binary implements com.android.credentialservice.CredVaultService, which issues elevated credential tokens to authorized clients.

The service was recently migrated to a new Parcel format. The mobile team signed off on the migration. Nobody checked the forwarding path.

TL;DR

credvault is a small TCP service that has some kind of “Parcel” protocol. To get the flag you have to pass the credential through three gates. The last gate (the “elevation” step) re-validates the same credential buffer with a second, much weaker check related to the hint “migration to a new Parcel format”. The two validators look at the same 24 bytes and their constraints do not conflict, so a single forged credential passes both. Send the forged credential, run the two gate opcodes, then ask for the flag.

First look

$ file credvault
credvault: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=c57da5b8bb490983b2d13cfb013e3761b5fe18c1, for GNU/Linux 3.2.0, stripped
Text
$ strings credvault
CREDVAULT_FLAG
socket
bind
listen
accept
9*3$"
CTF{local_test_only_not_a_real_flag}

So it is a socket server, the real flag comes from an env variable CREDVAULT_FLAG, and a test flag in the binary.

Throwing into Binja.

main

00401297    ssize_t rax_2 = read(fd: 3, buf: "CTF{local_test_only_not_a_real_flag}", nbytes: 127)
0040129f    if (rax_2 s<= 0)
004013fe        char* rax_6 = getenv(name: "CREDVAULT_FLAG")
00401406        if (rax_6 != 0)
00401417            strncpy("CTF{local_test_only_not_a_real_flag}", rax_6, 0x7f)
004012d0    unsetenv(name: "CREDVAULT_FLAG")
004012f9    int32_t fd = socket(2, 1, 0)
00401363    if (bind(zx.q(fd), &var_78, 0x10) s< 0)
00401363    else if (listen(zx.q(fd), 1) s< 0)
00401383    int32_t fd_1 = accept(fd, addr: 0, len: nullptr)
0040139f    __builtin_memset(dest: &var_60, ch: 0, count: 0x28)
004013b2    int32_t var_64_1 = 0xca1dcafe
004013ba    sub_401670(&fd_2)

Reading it:

It tries read(3, flagbuf, 127). On the live server fd 3 is where the real flag is piped in. Locally that read fails, so it falls back to getenv("CREDVAULT_FLAG"), and if that is unset it keeps the baked-in test flag.

unsetenv("CREDVAULT_FLAG") then wipes the variable, so the flag now only exists in that memory buffer.

Port is 1337 by default (or argv[1]), then socket / bind / listen / accept.

For each client it zeroes a small state struct (memset of 0x28 bytes), sets a marker 0xca1dcafe, and calls sub_401670(&fd_2) with a pointer to it.

The state struct is the whole game. sub_401670 treats it as an int32_t*, so the fields are:

  • arg1: the client fd
  • arg1[1]: the 0xca1dcafe marker
  • &arg1[2]: the 24-byte credential buffer the validators read
  • arg1[8]: cred_len, the stored credential length
  • arg1[9]: present, a credential has been loaded
  • arg1[0xa]: authorized, gate 1 passed
  • arg1[0xb]: elevated, gate 2 passed

The Parcel protocol (sub_401670)

sub_401670 is a request loop. It reads an 8-byte header (two little-endian dwords [u32 code][u32 length]), optionally reads length payload bytes (capped at 0x1000), and dispatches on the code. Valid codes are 0xca000001 to 0xca000005. Here is the function in HLIL:

int64_t sub_401670(int32_t* arg1)
004016db    while (sub_401580(*arg1, &var_1050, 8) == 0)
004016ec        int32_t rbx_1 = var_1050
004016f0        int32_t r15_1 = *arg1
004016f9        if (var_104c u> 0x1000)
004018ba            sub_4015c0(r15_1, 0xc0000002, 0, 0)
004018ba            break
00401701        if (var_104c != 0)                                  ; parcel has a payload
00401825            if (sub_401580(r15_1, &var_1048, zx.q(var_104c)) s< 0)
00401825                break
0040182b            uint64_t rbx_3 = zx.q(rbx_1 + 0x35ffffff)
00401838            switch (rbx_3)
004017c6                case 0:  int32_t var_1054 = arg1[1]         ; echo the marker
004017ca                         sub_4015c0(r15_1, 0, &var_1054, 4)
0040184c                case 1:  if (var_104c != 0x18) goto error   ; store credential
00401861                         *(arg1 + 0x28) = 0                  ; clear authorized + elevated
0040186c                         *(arg1 + 0x18) = var_1038           ; cred[16:24]
00401879                         *(arg1 + 8) = zmm0_1                ; cred[0:16]
0040187e                         *(arg1 + 0x20) = 0x100000018        ; cred_len = 0x18, present = 1
00401882                         sub_4015c0(rdi_8, 0, 0, 0)
00401789                case 2:  if (arg1[9] == 0) goto error       ; gate 1, needs present
00401789                         else if (sub_401520(&arg1[2], arg1[8]) == 0) goto error
004017a5                         else arg1[0xa] = 1                  ; set authorized
00401741                case 3:  if (arg1[0xa] == 0) goto error     ; gate 2, needs authorized
00401741                         else if (sub_401560(&arg1[2], arg1[8]) == 0) goto error
0040175d                         else arg1[0xb] = 1                  ; set elevated
004017e1                case 4:  if (arg1[0xb] == 0) goto error     ; needs elevated
00401800                         else sub_4015c0(r15_1, 0,          ; send the flag
00401800                             "CTF{local_test_only_not_a_real_flag}", strlen(...))
00401701        else                                                ; zero-length parcel
00401707            uint64_t rbx_2 = zx.q(rbx_1 + 0x35ffffff)
0040171a            switch (rbx_2)                                  ; same cases, but
0040172c                case 1: sub_4015c0(r15_1, 0xc0000002, 0, 0) ; storing needs a payload

The dispatch adds 0x35ffffff (which is -0xca000001) to the code and switches on the result, so code 0xca000001 is case 0, up to 0xca000005 as case 4. The zero-length and payload branches share the same cases, except storing a credential (case 1) only works with a 24-byte payload.

The reply helper sub_4015c0(fd, status, body, len) writes [u32 status][u32 len] followed by the body.

The five opcodes:

  • 0xca000001: echo the 0xca1dcafe marker
  • 0xca000002 with a 24-byte payload: store it as the credential, set cred_len and present
  • 0xca000003: gate 1, needs present, runs validator1, sets authorized
  • 0xca000004: gate 2, needs authorized, runs validator2, sets elevated
  • 0xca000005: needs elevated, sends the flag

So the path is: store credential, gate 1, gate 2, ask for flag. Both validators run on the same &arg1[2] buffer, so the only real question is what credential passes both.

The two validators

Gate 1, sub_401520 (the strict “new format” check):

uint64_t sub_401520(int32_t* arg1, int32_t arg2)
00401542    if (arg2 u<= 0x17 || *arg1 != 0xca110001 || arg1[2] != 1 || arg1[3] != 0
00401542            || arg1[4] != 0)
0040152f        return 0
0040154f    rax_1.b = (arg1[1] ^ 0xca110000) == arg1[5]
00401555    return zx.q(rax_1.b)

arg1 is the credential, indexed as dwords. It wants:

  • length >= 24
  • arg1[0] == 0xca110001
  • arg1[2] == 1
  • arg1[3] == 0
  • arg1[4] == 0
  • arg1[1] ^ 0xca110000 == arg1[5]

Gate 2, sub_401560 (the weak “forwarded” check):

int64_t sub_401560(void* arg1, int32_t arg2)
00401565    if (arg2 u> 0xf)
00401570        result.b = *(arg1 + 4) == 0xca110042
00401573    return result

Here *(arg1 + 4) is the same field as arg1[1] in validator1 (the second dword). It wants only:

  • length >= 16
  • arg1[1] == 0xca110042

The bug

Validator1 is the new Parcel format (magic, reserved zero fields, a checksum linking arg1[1] to arg1[5]). Validator2 is the old forwarded format that trusts a single field. The intended design is that a credential is validated once by whichever format it came in as. But both validators run on the same 24-byte buffer, and nothing stops one blob from satisfying both. That is the unchecked “forwarding path” from the description.

The constraints do not conflict. Validator2 pins arg1[1] = 0xca110042. Plug that into validator1’s checksum:

arg1[5] = 0xca110042 ^ 0xca110000 = 0x42

Everything else validator1 wants is a constant, and validator2 touches nothing else, so one credential passes both gates.

The forged credential

24 bytes, six little-endian dwords:

  • arg1[0]: 0xca110001
  • arg1[1]: 0xca110042
  • arg1[2]: 0x00000001
  • arg1[3]: 0x00000000
  • arg1[4]: 0x00000000
  • arg1[5]: 0x00000042

Exploit

Send the four parcels on one connection, then read the flag from the last reply.

Python
import socket, struct, sys

io = socket.create_connection((sys.argv[1], int(sys.argv[2])), timeout=10)
p32 = lambda x: struct.pack("<I", x)
cred = p32(0xca110001) + p32(0xca110042) + p32(1) + p32(0) + p32(0) + p32(0x42)

io.sendall(p32(0xca000002) + p32(24) + cred)   # store credential
io.sendall(p32(0xca000003) + p32(0))           # gate 1
io.sendall(p32(0xca000004) + p32(0))           # gate 2
io.sendall(p32(0xca000005) + p32(0))           # ask for flag

io.shutdown(socket.SHUT_WR)                     # server reads EOF and closes
data = b""
while True:
    c = io.recv(4096)
    if not c:
        break
    data += c
print(data)

Running it

Text
ncat --ssl credvault-2ecaa0343f05.inst.omnictf.com 1337

  ╔══════════════════════════════════════════════════════════╗
  ║   CREDVAULT  --  Android CredentialVault Service          ║
  ║              CTF  [ Android Mobile  /  pwn ]             ║
  ╚══════════════════════════════════════════════════════════╝

  An Android system service handles credential elevation through
  a serialized Parcel interface.  The service was recently
  migrated to a new Parcel format.  Something was left out.

  You have been given:  credvault

  Goal:
    
  Goal:
    1. Reverse credvault to understand the Parcel protocol.
    2. Find the vulnerability in the credential elevation path.
    3. Write solve.py (Python 3) that exploits it and reads the flag.
    4. Send solve.py here -- the server runs it against a live
       credvault instance and returns the output.

  Service address:  127.0.0.1 9999  (passed as argv[1] argv[2])
  Protocol:         See credvault (binary TCP, little-endian)

  Send your solve.py as base64.
  Paste it line by line, then send a line containing only: END

[] Waiting for solve.py (base64)...

aW1wb3J0IHNvY2tldCwgc3RydWN0LCBzeXMKCmlvID0gc29ja2V0LmNyZWF0ZV9jb25uZWN0aW9u
KChzeXMuYXJndlsxXSwgaW50KHN5cy5hcmd2WzJdKSksIHRpbWVvdXQ9MTApCnAzMiA9IGxhbWJk
YSB4OiBzdHJ1Y3QucGFjaygiPEkiLCB4KQpjcmVkID0gcDMyKDB4Y2ExMTAwMDEpICsgcDMyKDB4
Y2ExMTAwNDIpICsgcDMyKDEpICsgcDMyKDApICsgcDMyKDApICsgcDMyKDB4NDIpCgppby5zZW5k
YWxsKHAzMigweGNhMDAwMDAyKSArIHAzMigyNCkgKyBjcmVkKSAgICMgc3RvcmUgY3JlZGVudGlh
bAppby5zZW5kYWxsKHAzMigweGNhMDAwMDAzKSArIHAzMigwKSkgICAgICAgICAgICMgZ2F0ZSAx
CmlvLnNlbmRhbGwocDMyKDB4Y2EwMDAwMDQpICsgcDMyKDApKSAgICAgICAgICAgIyBnYXRlIDIK
aW8uc2VuZGFsbChwMzIoMHhjYTAwMDAwNSkgKyBwMzIoMCkpICAgICAgICAgICAjIGFzayBmb3Ig
ZmxhZwoKaW8uc2h1dGRvd24oc29ja2V0LlNIVVRfV1IpICAgICAgICAgICAgICAgICAgICAgIyBs
ZXQgdGhlIHNlcnZlciBoaXQgRU9GIGFuZCBjbG9zZQpkYXRhID0gYiIiCndoaWxlIFRydWU6CiAg
ICBjID0gaW8ucmVjdig0MDk2KQogICAgaWYgbm90IGM6CiAgICAgICAgYnJlYWsKICAgIGRhdGEg
Kz0gYwpwcmludChkYXRhKQo=
aW1wb3J0IHNvY2tldCwgc3RydWN0LCBzeXMKCmlvID0gc29ja2V0LmNyZWF0ZV9jb25uZWN0aW9u
KChzeXMuYXJndlsxXSwgaW50KHN5cy5hcmd2WzJdKSksIHRpbWVvdXQ9MTApCnAzMiA9IGxhbWJk
YSB4OiBzdHJ1Y3QucGFjaygiPEkiLCB4KQpjcmVkID0gcDMyKDB4Y2ExMTAwMDEpICsgcDMyKDB4
Y2ExMTAwNDIpICsgcDMyKDEpICsgcDMyKDApICsgcDMyKDApICsgcDMyKDB4NDIpCgppby5zZW5k
YWxsKHAzMigweGNhMDAwMDAyKSArIHAzMigyNCkgKyBjcmVkKSAgICMgc3RvcmUgY3JlZGVudGlh
bAppby5zZW5kYWxsKHAzMigweGNhMDAwMDAzKSArIHAzMigwKSkgICAgICAgICAgICMgZ2F0ZSAx
CmlvLnNlbmRhbGwocDMyKDB4Y2EwMDAwMDQpICsgcDMyKDApKSAgICAgICAgICAgIyBnYXRlIDIK
aW8uc2VuZGFsbChwMzIoMHhjYTAwMDAwNSkgKyBwMzIoMCkpICAgICAgICAgICAjIGFzayBmb3Ig
ZmxhZwoKaW8uc2h1dGRvd24oc29ja2V0LlNIVVRfV1IpICAgICAgICAgICAgICAgICAgICAgIyBs
ZXQgdGhlIHNlcnZlciBoaXQgRU9GIGFuZCBjbG9zZQpkYXRhID0gYiIiCndoaWxlIFRydWU6CiAg
ICBjID0gaW8ucmVjdig0MDk2KQogICAgaWYgbm90IGM6CiAgICAgICAgYnJlYWsKICAgIGRhdGEg
Kz0gYwpwcmludChkYXRhKQo=
END
END
[] Received solve.py (644 bytes)
[] Session flag generated.
[] Waiting for execution slot...
[] Slot acquired.
[] Starting CredVault service...
[] Service ready on port 9999.
[] Running solve.py...
════════════════════ OUTPUT ════════════════════════
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00^\x00\x00\x00OmniCTF{d1_692c9622c2269ce5_0d6ec7824a99a29dc23e1063435e75be_c8b5792c1ff96cc0c507e01ab139e90d}'
════════════════════ END OUTPUT ════════════════════
[*] Session ended.

Flag

OmniCTF{d1_692c9622c2269ce5_0d6ec7824a99a29dc23e1063435e75be_c8b5792c1ff96cc0c507e01ab139e90d}

Discussion

Loading discussion…

Related solves

Keep reading

Complete archive