Natas Level 13
Natas Level 13 — the server now checks that an upload looks like an image; learn what file signatures are and why checking them is not enough.
Table of Contents
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Username: natas13
URL: http://natas13.natas.labs.overthewire.org
Study guide
Level map: sign in as natas13 and find the password for natas14.
What this level teaches
That validating the first few bytes of a file does not make the whole file safe.
Key ideas
- Magic bytes. Image formats start with fixed bytes that identify them. Functions such as PHP’s
exif_imagetypelook only at those. - Polyglot files. A file can satisfy two formats at once, for example start like an image and contain a script after it.
- Same weakness, new gate. The execution risk from the previous level is unchanged; only the filter is different.
How to approach it
- Read the new check and work out exactly what it examines.
- Build a file that passes that check while still containing your payload.
- Use
xxdor a hex editor to see your file the way the server does.
How developers prevent it
Re-encode images with an image library (which discards extra content), store them outside the web root, and never rely on a header check alone.