Natas Level 30
Natas Level 30 — a Perl database call quotes a single value, but not when it receives a list; learn how SQL injection survives an escaping function.
Table of Contents
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Username: natas30
URL: http://natas30.natas.labs.overthewire.org
Study guide
Level map: sign in as natas30 and find the password for natas31.
What this level teaches
How a subtle API behaviour defeats escaping, and why parameter handling in CGI scripts matters.
Key ideas
- Escaping function.
quote()normally turns a string into a safe SQL literal. - Repeated parameters. In Perl CGI, a parameter provided several times can become a list rather than a single value, which changes what other functions do with it.
- Second argument. The quote function can take an optional data type that changes how it formats the value.
- Read the library docs. The documented behaviour of
quote()with its second argument matters.
How to approach it
- Read the script and find where your input reaches the query.
- Look up how Perl CGI handles repeated parameters and what the quote function does with the extra argument.
How developers prevent it
Use placeholders in prepared statements instead of escaping manually, and treat parameters as having a single expected type.