require, require_once, include, include_once
Basic LFI
Common LFI Parameters
LFI Bypass Techniques
- Non-Recursive Stripping
- Null Byte
- URL Encoding
- Filter Tricks
PHP Wrappers for LFI/RFI
php://filter
php://filter
data://
data://
Restricted by
allow_url_include settingexpect://
expect://
phar://
phar://
Upload a ZIP file with a PHP shell, then access it:
zip:// and rar://
zip:// and rar://
php://input
php://input
HTML-to-PDF Path Traversal
Modern HTML-to-PDF engines (TCPDF, html2pdf) parse attacker-provided HTML with filesystem access:LFI to RCE Techniques
1
Via Log File Poisoning
Inject a PHP shell into Apache/Nginx access logs via User-Agent, then include the log:Common log paths:
2
Via PHP Session
3
Via /proc/self/environ
4
Via PHP Filters (No File Needed)
Use PHP filter chains to generate arbitrary PHP code without writing to disk. See php_filter_chain_generator.
5
Via phpinfo() (file_uploads=on)
If phpinfo() is accessible with
file_uploads=on, exploit the race condition between temp file creation and cleanup.6
Via Nginx Temp Files
If Nginx is running in front of PHP with LFI, abuse Nginx temp file storage to achieve RCE.
PHP Blind Path Traversal (Error Oracle)
Vulnerable functions:file_get_contents, readfile, finfo->file, getimagesize, md5_file, sha1_file, file
Arbitrary File Write via Path Traversal
When an upload handler builds a destination path from user-controlled data without canonicalizing:Token Harvest from Access Logs
If an app accepts session/auth tokens via GET (e.g.,?AuthenticationToken=), read access logs via LFI to steal tokens: