MIR0811
TaintedFile
User-controlled input reaches the path argument of a filesystem function (fopen(), file_get_contents(), file_put_contents(), unlink(), new SplFileObject(), …), letting an attacker read or write files outside the intended directory. Writing tainted data to a constant path is not reported.
Example
Section titled “Example”<?phpreturn file_get_contents($_GET['path']); // TaintedFileHow to fix
Section titled “How to fix”Resolve the path with realpath() and reject it unless it is inside an allowed base directory, or reduce it to a file name with basename().
