A file path or URL is taken from request input

tx0/php:path-from-requestrecommendedwarningsecurity/path-traversaldepth fastsecurity, cwe-22

What it finds

readfile('uploads/' . $_GET['file']): a file path or URL taken from the request lets the sender read or change other files with ../, or make the server fetch addresses of their choice. The file functions and curl_init are checked; basename around the value, or a fixed list of allowed files, prevents it.

From the rule's source, path_from_request.rs.

Example from the rule's tests
<?phpfunction upload(){    $logo = $_FILES['logo'];    if ($logo['error'] == 0 && is_uploaded_file($logo['tmp_name'])) {        $data = file_get_contents($logo['tmp_name']);        unlink($_FILES['logo']['tmp_name']);        file_put_contents('uploads/' . $logo['name'], $data);tx0 reports: request input from $_FILES reaches the file path or URL    }    return fopen('uploads/' . $_FILES['logo']['full_path'], 'r');tx0 reports: request input from $_FILES reaches the file path or URL}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/php:path-from-request" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/php:path-from-request] reason="..."

tx0 explain tx0/php:path-from-request shows the same in the terminal. Found a false positive? Report it.