0xnhl

Tick Tock

/ Update
7 min read

Challenge Context#

We were given a netcat endpoint (nc chals3.apoorvctf.xyz 9001) and a prompt stating that the engineers are “obsessed with performance” and built a password verification service that “avoids doing more work than necessary.” We were also told the password consists entirely of digits (0-9).

The Vulnerability: Side-Channel Timing Attack#

The phrase “avoids doing more work than necessary” is a massive hint pointing toward an early-exit string comparison.

When checking the password, the backend code loops through the user’s input and compares it to the real password character by character. If it encounters a mismatch, it immediately returns False to save CPU cycles instead of checking the rest of the string.

Because of this early exit, a completely wrong password fails instantly. However, if the first character is correct, the server takes a tiny fraction of a second longer to fail, because it has to execute the next loop iteration. By measuring the server’s response time, we can leak the password one character at a time. In this specific challenge, the server artificially inflated that processing delay to exactly ~0.8 seconds per correct character.

The Exploit Code#

This script connects to the server once, sequentially guesses digits, and measures the response time. The digit that takes the longest to return “Incorrect password.” is appended to our known password base until the server eventually spits out the flag.

To keep the persistent connection synchronized, it makes sure to consume the password: prompt from the socket buffer after every single guess.

The Result & Remediation#

Running the script successfully leaks the 12-digit password (934780189098). Sending this to the server yields the final flag:

apoorvctf{con5t4nt_tim3_or_di3}

Tick Tock
https://nahil.xyz/vault/writeups/apoorvctf2026/cryptography/tick-tock/
Author Nahil Rasheed
Published at March 12, 2026
Disclaimer This content is provided strictly for educational purposes only.