Natas Level 27
Natas Level 27 — a registration and login system that compares trimmed values; learn how database column truncation can create a duplicate account.
Table of Contents
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Username: natas27
URL: http://natas27.natas.labs.overthewire.org
Study guide
Level map: sign in as natas27 and find the password for natas28.
What this level teaches
How the database and the application disagree about what a username is.
Key ideas
- Column limits. A column stores only so many characters; longer values may be silently cut, depending on the database mode.
- Padding and trimming. Trailing spaces may be ignored in comparisons.
- Two views of the same string. The application checks for an existing user using the full value, while the database stores a shortened one.
- Impersonation. A crafted registration can yield a second account that the lookup treats as the original.
How to approach it
- Read the register and lookup logic and note every length and comparison.
- Design an input that passes the “does it exist?” check yet is stored as the target name.
- Log in as the new account and see what the application returns.
How developers prevent it
Enforce uniqueness in the database with a unique constraint, normalise input before checking it, and run the database in strict mode so that over-long values are rejected rather than truncated.