← Local File Inclusion lesson
FoundationsLocal File InclusionIntermediate35 min+100 XP

Docs Traversal

The Documentation loads a file relative to a public pages directory without validating path traversal. Include the secret file.

“The page loader included a file. The attacker included a secret.”

CWE-98OWASP Top 10 A03:2021OWASP ASVS 12.3.1
The story
Inclusion asks the interpreter to bring another file into the current execution. If the user chooses the file, the user chooses part of the program.

The application builds an include path from a page or template parameter. Traversal escapes the pages directory, and wrappers or logs can turn a local file into readable data.

Your objective
  • Inspect the page parameter
  • Traverse out of the pages directory
  • Include the secret file and capture the flag
Boundary under test

Request parameter to include path

Field guide · request anatomy

Where to look before you type a payload

01Accept

A route chooses a template, language file, page or module by name.

02Resolve

The runtime joins the name with a base path and resolves traversal, wrappers or stream filters.

03Include

The file is read as code or data and executed in the current process.

04Execute

Any code in the included file runs with application privileges; even a non-PHP file may disclose source.

Progressive hints

Open one hint at a time. The first two build the model; the last two point at the boundary.

Hint 1

Find the page or template parameter.

Hint 2

Try `../` and observe errors or content changes.

Hint 3

The include root is /var/www/pages. Try ../secret/flag.txt.

Hint 4 · near the answer

Include `../secret/flag.txt` and capture the flag.

Guided workbench

Observe → Hypothesize → Test → Prove → Explain

This is the same loop a reviewer expects in a report. Your draft stays in this browser; nothing is submitted until you choose to export it.

0/15steps complete
Observe0/3
Hypothesize0/3
Test0/3
Prove0/3
Explain0/3

Evidence log

Write for a reviewer who was not in the room. Every claim needs a request, response or state change behind it.

Preview the evidence report
# Lab evidence report — Docs Traversal

- Family: Local File Inclusion
- Lab ID: web-lfi-docs
- Date: 2026-12-05

## Workflow

### Observe

- [ ] Open "Docs Traversal" and record /doc, the HTTP method and the role you are given.
- [ ] List every parameter, header, cookie and object identifier the normal flow exposes.
- [ ] Save a baseline response: status, body shape, timing and the fields that change by user.

### Hypothesize

- [ ] Name the server decision that protects /doc, and the evidence it should use.
- [ ] Use the clue as a constraint, not an answer: The loader joins the requested page to a public directory. Try ../secret/flag.txt.
- [ ] Predict the exact status, body or state change that would prove the decision is missing.

### Test

- [ ] Start from the baseline and change one value: the page include value.
- [ ] Keep the request replayable; vary encoding, method or identifier location only after the first result.
- [ ] Capture the full request and response for the winning attempt, including the flag.

### Prove

- [ ] Capture the flag and name the exact foreign object, role or state change it proves.
- [ ] Repeat from a clean session and confirm the result is not cached or stale.
- [ ] State impact precisely: what data or action did you actually obtain?

### Explain

- [ ] State the root cause without naming the payload: which decision failed?
- [ ] Name the control that prevents recurrence and the layer where it belongs.
- [ ] Write one regression test that fails before the fix and passes after it.

## Evidence

### Target and baseline

_Not recorded._

### Hypothesis

_Not recorded._

### Winning request

_Not recorded._

### Proof

_Not recorded._

### Root cause

_Not recorded._

### Control and regression test

_Not recorded._

## Analyst conclusion

The proof demonstrates the missing control above. The regression test should fail against the vulnerable behavior and pass after remediation.
Solution and debrief
Locked until you capture the flag.

The full request, the reasoning and the debrief unlock after a successful capture. That is deliberate: struggle first, then consolidate.

What a reviewer will ask

False positives to rule out

  • The page shows the filename but not its content: inclusion may be blocked while reflection remains.
  • A traversal payload returns an error: try wrappers, encoded separators and alternate parameters.
  • Only .php files are allowed: test null bytes on old runtimes, path truncation and wrapper syntax.

Regression tests to name

  • Traversal include: The request is rejected and no file is included
  • Wrapper: Only a fixed key map is accepted and wrappers never reach the include
  • Log poisoning: The include path cannot reach log files
The defender's move
  • Map page IDs to an allowlist of files instead of accepting paths.
  • Canonicalize and verify the resolved path inside the include root.
  • Disable dangerous wrappers and run with least privilege.
See the secure-code pattern and all 4 regression tests →
الخلاصة

تضمين ملف باسم يتحكم به المستخدم هو قرار ثقة خطير.