Read the Vault's Timing
medium · 100 XP · machine with a lab · free · solves: 0
AegisGuard lost the six-digit PIN of its Model-7 vault. The vault firmware checks a PIN one digit at a time from the left and stops at the first wrong digit. Each correct leading digit adds the same fixed delay before the reply. Every reply also has random noise of 0 to 50 ms, and the network adds a little more.
Start the lab. The vault runs on host vault, TCP port 9000.
Protocol. The vault sends two banner lines when you connect. Send one command per line:
pin <six digits>: the vault repliesdenied, oropen <message>when the PIN is correct.- A line that starts with
error:reports a problem with your command. - Each connection allows 5000 attempts. Then the vault closes the connection. A new connection starts a new count with the same PIN.
client.py opens one connection and gives you Vault.try_pin(pin), which returns the reply and the response time in seconds. Run it alone to time one PIN: python3 client.py --repeat 5 123456.
Your task.
- For the first position, try each digit 0 to 9 and fill the other positions with any digits.
- Send each guess at least 5 times and take the median time. One sample is not enough, because the noise is larger than the step. If two digits are close, measure them again with more samples.
- Keep the digit with the clearly highest median, then move to the next position.
- If no digit stands out at a position, an earlier digit is probably wrong. Measure the earlier position again.
- When all six digits are known, send the PIN. The vault opens and shows the flag.
Then explain for yourself how a constant-time comparison, such as Python's hmac.compare_digest, removes this signal.
Tags: learn
Try next
- Recover the Hidden Suffix (medium)
- Recover Plaintext with a Padding Oracle (medium)
- Intercept a Diffie-Hellman Exchange (medium)