SiteShadow
Back to vulnerability library

P01 Path Traversal Risk

What this means

SiteShadow flagged a file path that appears to be influenced by untrusted input (request params/body/query), which can allow reading/writing unintended files.

Why it matters

Safer examples

1) Use allowlists (recommended)

import os

ALLOWED = {"report.csv", "summary.json"}
name = name if name in ALLOWED else "summary.json"
path = os.path.join(os.environ.get("REPORT_DIR", "/srv/reports"), name)

2) Normalize + enforce a base directory

from pathlib import Path

base = Path("/srv/reports").resolve()
candidate = (base / user_path).resolve()
if base not in candidate.parents:
    raise ValueError("Invalid path")

3) Don't pass user input directly to file APIs

Avoid patterns like open(req.query.path) or send_file(request.args["path"]).

How SiteShadow detects it (high level)

References

---

← Back to Vulnerability Library

Request access View coverage