← All lessons

Lessons: #path-traversal

4 min read

Path Traversal in PHP and Laravel: Safe File Paths

Never concatenate request input onto a filesystem path. Reject null bytes, backslashes and absolute paths, resolve the result with realpath(), and allow the file only when it stays inside a known base directory. realpath() returns false when the path does not exist, so new files need a parent-directory check.

Get new briefs by email

Short alerts when a PHP or WordPress vulnerability needs action.

Double opt-in via Buttondown; unsubscribe any time. See our privacy policy.