Natas Level 25
Natas Level 25 — a weak path filter and a logged User-Agent combine into log poisoning; learn how reading a log file can execute attacker-supplied code.
Table of Contents
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Username: natas25
URL: http://natas25.natas.labs.overthewire.org
Study guide
Level map: sign in as natas25 and find the password for natas26.
What this level teaches
Chaining two small weaknesses into a much bigger one.
Key ideas
- Naive filtering. A filter that removes
../once may be defeated by input that reconstitutes the sequence after removal. - Local file inclusion. If the application includes a file whose path you can influence, it will run any PHP it contains.
- Log poisoning. Applications log request details such as the User-Agent header. If you can include the log file, anything you put in that header becomes code.
- Request headers again. You control them, as in Level 4.
How to approach it
- Read how the language parameter is filtered and how the log filename is chosen.
- Plan the sequence: get your own text into the log, then include the log.
How developers prevent it
Resolve and validate paths against an allow-list, never include files by user-supplied name, and store logs where the web application cannot execute them.