Description
Local File Inclusion (LFI) is a vulnerability that allows attackers to include local files, exploiting dynamic file inclusion mechanisms in the target application. This occurs due to the use of user-supplied input without proper validation. The content of the local file is reflected in the response, and if containing code, it might be executed by the application.
Recommendation
To mitigate LFI vulnerabilities, avoid passing user-submitted input to filesystem/framework APIs. If unavoidable, maintain an allow list of files that may be included, using an identifier to access selected files. Reject any request with an invalid identifier to eliminate attack surface.
References
- OWASP: Testing for Local File Inclusion
- Wikipedia: File inclusion vulnerability
- CWE-20
- CWE-22
- CWE-98
- CAPEC-252
- CAPEC-126
- OWASP 2021-A3