Natas Level 26
Natas Level 26 — a cookie contains serialised PHP data the server later unserialises; learn how object injection can write files on the server.
Table of Contents
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Username: natas26
URL: http://natas26.natas.labs.overthewire.org
Study guide
Level map: sign in as natas26 and find the password for natas27.
What this level teaches
PHP object injection through unsafe deserialisation.
Key ideas
- Serialisation. PHP converts objects to strings and back; the conversion can call special “magic” methods such as a destructor.
- User-controlled objects. If the server unserialises a cookie, the client chooses which class is created and with what values.
- Gadgets. An existing class in the application (here, a logger) does something dangerous when its destructor runs.
- Read the source. Every class definition you need is visible.
How to approach it
- Study how the drawing feature stores state in the cookie.
- Find a class whose methods perform file operations with data it holds.
- Build a serialised object of that class, encode it as the cookie expects, and send it.
How developers prevent it
Never unserialise untrusted data. Use a data-only format such as JSON and validate it.