Skip to main content
Remote File Inclusion (RFI): The file is loaded from a remote server, potentially allowing code execution. Local File Inclusion (LFI): The server loads a local file based on user-controlled input. Vulnerable PHP functions: require, require_once, include, include_once

Basic LFI

Common LFI Parameters

LFI Bypass Techniques

PHP Wrappers for LFI/RFI

Restricted by allow_url_include setting
Requires the expect PHP extension to be loaded.
Upload a ZIP file with a PHP shell, then access it:

HTML-to-PDF Path Traversal

Modern HTML-to-PDF engines (TCPDF, html2pdf) parse attacker-provided HTML with filesystem access:
Fingerprint the renderer: every generated PDF contains a Producer field (e.g. TCPDF 6.8.2). Older versions have path filter vulnerabilities.

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)

Useful when you control a file path in a PHP function but don’t see the file contents. Exploit using the UCS-4LE encoding trick to exfiltrate file contents char by char via 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:
Then replay captured token:

curl —path-as-is for Path Traversal

Resources