This rule is emitted when user-controlled input can be passed into a sensitive file operation.
The risk here depends on the actual operation that contains user-controlled input, and how it is later on processed.
It could range from:
- Creating files
- Risk: Depending on the server configuration this may result in remote code execution. (e.g. writing a file in the web root)
- Modifying files
- Risk: Depending on the server configuration this may result in remote code execution. (e.g. modifying a PHP file)
- Reading files
- Risk: Sensitive data could be exposed from the filesystem. (e.g. config values, source code, user-submitted files)
- Deleting files
- Risk: Denial of Service or potentially RCE. (e.g. deleting application code, removing a .htaccess file)
<?php $content = file_get_contents($_GET['header']); echo $content;
Use an allowlist approach where possible to verify names on file operations.
Sanitize user-controlled filenames by stripping