Vulnerable-Web-Application CVE semgrep_id:PHPCS_SecurityAudit.BadFunctions.FilesystemFunctions.WarnFilesystem:35:35
Improper control of filename for include/require statement in PHP program ('PHP Remote File Inclusion')
Ссылка на строку:
Описание уязвимости
Название: Improper control of filename for include/require statement in PHP program ('PHP Remote File Inclusion')
Категория: SAST (Static Application Security Testing)
Описание: Обнаружен небезопасный механизм включения файлов, который может привести к локальной (LFI) или удалённой (RFI) подмене файлов, если пользовательский ввод достигает этого оператора. LFI и RFI могут позволить злоумышленникам получить доступ к конфиденциальным файлам. Рекомендуется явно указывать, что включать, или тщательно проверять пользовательский ввод.
CVE: semgrep_id:PHPCS_SecurityAudit.BadFunctions.FilesystemFunctions.WarnFilesystem:35:35
Уровень опасности: Критический
Сканер: Semgrep
Расположение уязвимости
- Файл: repo/FileInclusion/pages/lvl4.php
- Строка: 35
Идентификаторы
- Semgrep ID: PHPCS_SecurityAudit.BadFunctions.FilesystemFunctions.WarnFilesystem
- CWE: CWE-98 (https://cwe.mitre.org/data/definitions/98.html)
- OWASP: A03:2021 - Injection, A1:2017 - Injection
- PHPCS Security Audit Test ID: PHPCS_SecurityAudit.BadFunctions.FilesystemFunctions.WarnFilesystem
Исправление уязвимости
-
Явное указание включаемого файла:
include('secure_file.php');
-
Тщательная проверка пользовательского ввода:
if (isset($_GET['file']) && in_array($_GET['file'], ['allowed_file1', 'allowed_file2'])) { include($_GET['file'] . '.php'); } else { // Обработка ошибки }
Дополнительная информация
Для более подробной информации о данной уязвимости и методах её устранения можно ознакомиться со следующими ресурсами:
Описание:
Detected non-constant file inclusion. This can lead to local file inclusion (LFI) or remote file inclusion (RFI) if user input reaches this statement. LFI and RFI could lead to sensitive files being obtained by attackers. Instead, explicitly specify what to include. If that is not a viable solution, validate user input thoroughly.Исходный JSON:
{
"id": "8751cb734800ab7ef84ee30489cf62fa6cccff092b22e34fc5b2ea1c31ec78c5",
"category": "sast",
"name": "Improper control of filename for include/require statement in PHP program ('PHP Remote File Inclusion')",
"description": "Detected non-constant file inclusion. This can lead to local file inclusion (LFI) or remote file inclusion (RFI) if user input reaches this statement. LFI and RFI could lead to sensitive files being obtained by attackers. Instead, explicitly specify what to include. If that is not a viable solution, validate user input thoroughly.",
"cve": "semgrep_id:PHPCS_SecurityAudit.BadFunctions.FilesystemFunctions.WarnFilesystem:35:35",
"severity": "Critical",
"scanner": {
"id": "semgrep",
"name": "Semgrep"
},
"location": {
"file": "repo/FileInclusion/pages/lvl4.php",
"start_line": 35
},
"identifiers": [
{
"type": "semgrep_id",
"name": "PHPCS_SecurityAudit.BadFunctions.FilesystemFunctions.WarnFilesystem",
"value": "PHPCS_SecurityAudit.BadFunctions.FilesystemFunctions.WarnFilesystem"
},
{
"type": "cwe",
"name": "CWE-98",
"value": "98",
"url": "https://cwe.mitre.org/data/definitions/98.html"
},
{
"type": "owasp",
"name": "A03:2021 - Injection",
"value": "A03:2021"
},
{
"type": "owasp",
"name": "A1:2017 - Injection",
"value": "A1:2017"
},
{
"type": "phpcs_security_audit_source",
"name": "PHPCS Security Audit Test ID PHPCS_SecurityAudit.BadFunctions.FilesystemFunctions.WarnFilesystem",
"value": "PHPCS_SecurityAudit.BadFunctions.FilesystemFunctions.WarnFilesystem"
}
]
}
```