High severityPHPFile InclusionHIGH confidence
Path Traversal File Read
Untrusted request input flows into a filesystem read/write function, allowing path traversal (CWE-22).
Standards mapping
- OWASP Top 10
- A01:2021 - Broken Access Control
- OWASP ASVS
- V12.3.1 (L1)
Vulnerable vs. safe
Flagged by this check
return readfile($file);Passes - the safe pattern
return readfile(basename($file));Why it matters & how to fix it
Untrusted request input flows into a filesystem read/write function, allowing path traversal (CWE-22). An attacker can use ../ sequences or an absolute path to read or write files outside the intended directory. Resolve the path with realpath() and verify it stays within an allowed base directory; strip directory components with basename().
References
Rule ID integsec-php-path-traversal-file-read - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentest