Natas Level 12
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Username: natas12
URL: http://natas12.natas.labs.overthewire.org
Study guide¶
Level map: sign in as natas12 and find the password for natas13.
What this level teaches¶
How an unrestricted file upload can turn into remote code execution.
Key ideas¶
- Uploads become files on the server. If they land in a folder the web server executes, the file can run as a script.
- Never trust the client. The filename and extension arrive from the browser, and even hidden form fields can be edited.
- Execution depends on extension. The web server decides whether to run or merely serve a file by its name.
- What to run. A tiny server-side script that reads the password file is enough.
How to approach it¶
- Upload a harmless file, then find where it is stored and what name it was given.
- Inspect the form and the code to see which part of the name the server chooses and which part you do.
- Request the uploaded file from the browser to see what happens.
How developers prevent it¶
Store uploads outside the web root, generate the filename yourself, validate the file's true type, and serve uploads from a domain that never executes code.