Skip to main content
Local File Inclusion lets you read (and sometimes execute) files on the server by manipulating a path parameter. Remote File Inclusion is rarer and requires allow_url_include = On in PHP, but gives immediate RCE. Start by confirming LFI with /etc/passwd, then escalate toward RCE.

Basic Traversal

High-Value Files

Linux

Windows

PHP Wrappers

PHP stream wrappers are the most powerful LFI escalation path. No external file needed.

Read Source Code

RCE via php://input

Requires the LFI parameter to be passed via POST and allow_url_include = On.

RCE via data://

expect:// (RCE, rarely enabled)

Log Poisoning

Inject PHP into a file the server writes, then include it via LFI. The web server must have read access to the log.

Apache / Nginx Access Log

SSH Auth Log

If you can trigger SSH auth attempts, the username goes into /var/log/auth.log.

Mail Log

/proc/self/environ

If the server includes environment variables in /proc/self/environ and you control an HTTP header:

/proc/self/fd (File Descriptor Brute-Force)

Each open file descriptor in the current process is exposed at /proc/self/fd/N. FD 0-2 are stdin/stdout/stderr; higher numbers are open files including logs. Brute-force to find a writable fd that contains injected data.

PHP Session File Inclusion

If the app stores unsanitized input in a PHP session, include the session file.

Zip / Phar Wrappers

If the app accepts file uploads, upload a zip containing PHP and include it with the zip:// wrapper.

RFI (Remote File Inclusion)

Requires allow_url_include = On and allow_url_fopen = On in php.ini. Rare in modern setups, but still seen on old PHP or misconfigured apps.

LFI to RCE: Upload + Include

If you can upload a file anywhere on the server (avatar, attachment, temp file), you only need to know the path and include it.

PHP Filter Chain RCE

The most powerful modern LFI escalation: generates a PHP payload using chained php://filter conversions, achieving RCE with no allow_url_include, no writable path, and no upload required. Works on any PHP app where the LFI parameter reaches include().
The chain encodes arbitrary bytes into the php://filter conversion pipeline so the PHP interpreter assembles your payload from character-encoding artifacts rather than from any file on disk.

Nginx Temp File Inclusion

When file uploads go through Nginx, the multipart body is written to a temp file at /tmp/phpXXXXXX before the PHP process reads it. Race the include against the temp file window.
In practice, use Nginx-temp-file-LFI for automated exploitation of this race.

pearcmd.php (register_argc_argv)

If register_argc_argv = On in php.ini (common in Docker-based PHP images), /usr/local/lib/php/pearcmd.php can be abused via query string to write files.
The query string is parsed as $argv when register_argc_argv is on, so PEAR’s CLI commands execute server-side.

phpinfo() Race Condition

When a page exposes phpinfo(), it reveals the exact temp file path of any concurrent file upload before PHP cleans it up. Race the include against that temp path.

Escalation Decision Guide

Automation