Bypass Me
- Vulnerability
- Secret recoverable from memory at runtime
- Impact
- Bypass a setuid root password check
- Tools
- nm, lldb, expect
- Binary
- setuid ELF 64-bit, not stripped
Vulnerability Analysis
Root Cause: The program filters input by blacklisting digits, but that filter is irrelevant — the real password is held in cleartext in process memory and can be read straight out of a CPU register at the comparison point, no matter what the filter allows through.
- CWE-184: Incomplete List of Disallowed Inputs —
sanitize()only blocks digits; it does nothing to stop the actual attack, which never depends on what characters are typed - CWE-312: Cleartext Storage of Sensitive Information — the decoded password sits unencrypted in memory, so any debugger attached to the process can read it directly
Severity: No CVSS score applies — this is a lab-built binary, not a scored vulnerability in a shipped product. The practical effect is a full authentication bypass on a setuid-root binary.
Summary
A setuid-root binary, bypassme.bin, asks for a password and rejects anything wrong. Typing a password with digits in it shows the first crack: the program silently strips every digit before checking it, so it isn't comparing what I actually typed. But chasing that filter is the wrong path entirely — the binary is dynamically linked and not stripped, so I can just attach a debugger, break at the string comparison, and read the real password straight out of a register.
Key insight: Input sanitization only decides what reaches the comparison — it does nothing to protect the secret the comparison is made against. If that secret is sitting in plaintext in memory, a debugger bypasses the filter entirely.
Recon
The password prompt over SSH is interactive, so I automated the login with an expect script rather than typing it by hand each run:
# automated via login.exp
ssh -o StrictHostKeyChecking=no -p <port> ctf-player@<host>
# (challenge-issued SSH password, not the binary's password)
Once in, I checked what I was dealing with:
ctf-player@pico-chall$ ls -la
-rwsr-xr-x 1 root root 21672 Mar 6 20:10 bypassme.bin
ctf-player@pico-chall$ file bypassme.bin
bypassme.bin: setuid ELF 64-bit LSB shared object, x86-64, version 1 (SYSV),
dynamically linked, ... not stripped
Setuid root, dynamically linked, and not stripped — symbol names survive, so the logic is easy to map before touching a debugger.
Finding the sanitization logic
Entering a numeric password first showed the filter in action:
[3 tries left] Enter password: 6dd28e9b
Raw Input: [6dd28e9b]
Sanitized Input:[ddeb]
Every digit (0–9) is stripped before the comparison. Any password containing numbers gets silently rewritten first — so brute-forcing the raw string makes no sense.
Listing the binary's symbols points straight at the authentication flow:
ctf-player@pico-chall$ nm -C bypassme.bin
0000000000001457 T auth_sequence()
0000000000001333 T decode_password(char*)
00000000000013c4 T sanitize(char const*, char*)
decode_password suggests the real secret is obfuscated and only decoded at runtime — which means the plaintext has to exist in memory at some point, however briefly.
Dynamic analysis with lldb
Rather than reverse the decoding, I let the program decode it for me and read the result at the comparison point.
Step 1 — break on main. Shared libraries aren't mapped until execution starts, so a breakpoint on a library function set too early stays "pending". Breaking on main first guarantees the environment is ready:
(lldb) b main
(lldb) run
Step 2 — intercept the comparison. auth_sequence eventually calls strcmp to check the sanitized input against the real secret:
(lldb) b strcmp
(lldb) c
[3 tries left] Enter password: AABBCC
Step 3 — read the registers. In the x86-64 calling convention, strcmp(rdi, rsi) compares the string in RDI against the string in RSI — one of those two is the sanitized input I just typed, and the other is the real secret:
(lldb) register read rdi rsi
rdi = 0x00007fffd5f33b50
rsi = 0x00007fffd5f33c50
(lldb) x/s $rdi
0x7fffd5f33b50: "AABBCC"
(lldb) x/s $rsi
0x7fffd5f33c50: "SuperSecure"
RDI held my sanitized input, confirming RSI is the program's own decoded secret — sitting in memory as plain text, with nothing stopping a debugger from reading it directly.
Result
Running the binary again with the leaked value instead of guessing:
ctf-player@pico-chall$ ./bypassme.bin
Enter password: SuperSecure
Authenticating...
<flag redacted>
Takeaways
- Symbols are gold. An unstripped binary lets
nm/objdumpmap the logic before a debugger is even opened. - Sanitization is not security. Filtering user input does nothing if the underlying secret can be read straight out of memory.
- Dynamic beats static here. Obfuscated decoding logic is tedious to reverse by hand but trivial to bypass by reading the result at runtime.
- Break on main first. Setting a library breakpoint before the process starts risks a "pending" breakpoint that never fires.
- Automate the boring parts. An
expectscript made the SSH login reproducible and removed manual typing mistakes from the loop.
References & Standards
- Common Weakness Enumeration
- CWE-184: Incomplete List of Disallowed Inputs
- CWE-312: Cleartext Storage of Sensitive Information
- Security Guidance
- OWASP Input Validation Cheat Sheet