Skip to content
imattas
Go back

tea-cash

Edit page

Challenge Description

You’ve stumbled upon a mysterious cash register that doesn’t keep money — it keeps secrets in memory. Traverse the free list wisely, and you might just find the flag hiding in a freed chunk.

Approach

The challenge name “tea-cash” is a play on words for tcache — the Thread Local Caching mechanism in glibc’s heap allocator. The description tells us the flag is hiding in a freed chunk, and we need to traverse the free list to find it.

Understanding Tcache

Since glibc 2.26, the tcache (Thread Cache) is a per-thread caching layer that sits in front of the traditional fastbin/smallbin/unsortedbin system. Key properties:

The Challenge Mechanism

Based on the description, this appears to be a tcache traversal / free list reading challenge:

  1. The program allocates a chunk, stores the flag in it, and then frees the chunk.
  2. The freed chunk goes into a tcache bin, but the flag data remains in memory (free() does not zero out the data).
  3. We need to interact with the program to allocate a new chunk of the same size, which will be served from the tcache — returning the same memory that previously held the flag.
  4. Reading this newly allocated chunk reveals the flag.

Alternative Mechanisms

Solution

  1. Connect to the remote service.
  2. Interact with the menu to understand available operations (allocate, free, read, write, etc.).
  3. Identify the flag chunk: The flag was stored in a chunk that has been freed.
  4. Retrieve the flag by either:
    • Allocating a chunk of the same size (tcache will return the freed chunk with the flag still in it)
    • Using a “view” or “traverse” feature if the program provides one
    • Exploiting a use-after-free condition
  5. Read the flag from the returned chunk.

Solution Script

python3 solve.py

Flag

picoCTF{...}  (placeholder - actual flag varies per instance)

Edit page
Share this post on:

Previous Post
SUDO MAKE ME A SANDWICH
Next Post
The Add-On Trap