File inclusion
File inclusion vulnerabilities occur when user-controlled input is passed to a file-loading function without sufficient validation. Local File Inclusion reads files from the server filesystem. Remote File Inclusion loads and executes code from a remote URL. Both lead to full code execution with the right conditions. Detection here stops at confirmation — exploitation is covered in the file inclusion exploitation section.
Look for parameters named page, file, path, include, template, view, doc, or lang during parameter crawling — these are the most common carriers.
Identify File Loading Parameters
Check the application's URL structure and form inputs for parameters that accept filenames or paths:
4823
3102
Different response sizes for different parameter values strongly suggest the parameter is loading different files. That's your LFI test target.
LFI Detection — Path Traversal
Test path traversal sequences to read files outside the intended directory. Start with a known target file:
root:x:0:0:root:/root:/bin/bash
Content from /etc/passwd in the response confirms LFI. If nothing shows on the basic traversal, the application may be stripping ../ sequences. Try URL-encoded and double-encoded variants:
LFI with Extension Appending
Some applications append .php or another extension to the parameter value. Use a PHP null byte or path tricks to bypass on older PHP versions:
Null byte truncation works on PHP 5.3 and earlier. On newer PHP, use path length attacks or look for wrapper-based bypasses instead.
RFI Detection
Remote File Inclusion requires allow_url_include = On in PHP config, which is off by default in modern installs. Test by pointing the parameter at an external URL you control:
An incoming HTTP request on your listener confirms RFI — the server fetched a remote URL based on your input. This is also a confirmed SSRF path through the file inclusion vector.
Automated Fuzzing
Use ffuf with a dedicated LFI wordlist to test multiple traversal variants across a parameter quickly:
Set -fs to the normal response size so only responses with different content — indicating a successful file read — are shown. Confirmed LFI moves to local file inclusion exploitation for sensitive file extraction and path to RCE.
References
-
SecLists — LFI Wordlistsgithub.com/danielmiessler/SecLists/tree/master/Fuzzing/LFI (opens in new tab)
LFI traversal payload lists including Jhaddix and common variants
-
PayloadsAllTheThings — File Inclusiongithub.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusion (opens in new tab)
LFI and RFI payload collection including wrapper-based bypasses
Was this helpful?
Your feedback helps improve this page.