Skip to content

Natas Level 26

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

  1. Study how the drawing feature stores state in the cookie.
  2. Find a class whose methods perform file operations with data it holds.
  3. 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.