The Path That Climbed Out

Medium

· Backend

Incident

SEV-1

BUG-DOTDOT

Priority: Critical · reported by bug bounty

Time to fix: 20 min

Failing checks on the shipped build

  • dot-dot segments are rejected

    expected an error to be raised

  • absolute paths are rejected

    expected an error to be raised

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

Path traversal · CWE-22

Inspired by the vulnerability class that never dies — from web servers in the 90s to container escapes today: a filename with ../ in it walks straight out of the sandbox and reads /etc/passwd.

filestore.py joins user-supplied paths onto a base directory. It must refuse to climb.

Code map

# Joins a user-supplied path onto the storage root.

def safe_join(base, user_path):
    return base + "/" + user_path

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

The Path That Climbed Out — Python Bug Hunt

Inspired by the vulnerability class that never dies — from web servers in the 90s to container escapes today: a filename with ../ in it walks straight out…

  • Language: Python
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Security, Path Traversal
  • Modelled on: Path traversal · CWE-22
  • Visible tests: ordinary paths join under the base; dot-dot segments are rejected; absolute paths are rejected
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical)
  • Ticket: BUG-DOTDOT
  • Reported by: bug bounty
  • Time to fix: 20 minutes, the target for a medium incident

Failing checks on the shipped build

  • dot-dot segments are rejected — expected an error to be raised
  • absolute paths are rejected — expected an error to be raised

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Briefing

Inspired by the vulnerability class that never dies — from web servers in the 90s to container escapes today: a filename with ../ in it walks straight out of the sandbox and reads /etc/passwd.

filestore.py joins user-supplied paths onto a base directory. It must refuse to climb.

Bug report

BUG-DOTDOT · Priority: Critical · Reported by: bug bounty

safe_join(base, user_path):

  • reject absolute paths and any ".." segment -> raise ValueError
  • otherwise return base + "/" + normalized path ("." segments dropped)

Observed: GET /files/..%2F..%2Fetc%2Fpasswd returns the real thing.

Logs

[files] serving "uploads/../../etc/passwd"

The code as shipped

src/fs/filestore.py (editable)

# Joins a user-supplied path onto the storage root.

def safe_join(base, user_path):
    return base + "/" + user_path

Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More Python bug hunts.