Skip to main content

Settings

Color Mode

Theme Skin

Background

Appearance preferences are saved in this browser only.

Environment

Current Environment Production

Built with JEKYLL_ENV=production. Changes require deployment.

Quick Links

Theme & Build

Jekyll v3.10.0
Last BuildNov 24, 17:25

Page Location

Page Info

Layout default
Collection wargames
Path _wargames/natas/natas31.md
URL /wargames/natas/natas31/
Date 2026-04-07

Natas Level 31

Natas Level 31 — a CSV upload feature passes a file handle to Perl's diamond operator; learn how that can read arbitrary files.

Table of Contents

Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.

Username: natas31
URL:      http://natas31.natas.labs.overthewire.org

Study guide

Level map: sign in as natas31 and find the password for natas32.

What this level teaches

How a language feature meant for convenience becomes a file read vulnerability when input is user-controlled.

Key ideas

  • The diamond operator. In Perl, <> reads from files named on the command line or from standard input, and its handling of special names is surprising.
  • CGI file uploads. An upload parameter can be either a file or a plain string depending on how the request is built.
  • Dual nature of a value. The script treats a value as a file handle in one place and as a name in another.
  • Read the documentation. Perl’s perlop description of <> and <<>> explains the behaviour.

How to approach it

  1. Study how the script reads the uploaded file.
  2. Work out how to make the same parameter mean something different to the second use.

How developers prevent it

Use the safe double-diamond form, avoid reading from user-supplied names, and test upload handling with unexpected input shapes.