← /articles
2025-05-05 Β· 2 min read
BugBounty/2 min read

Beginners Guide to LFD

#web

Local File Disclosure (LFD), also known as Local File Inclusion (LFI) when chaining with RCE, is a vulnerability that allows an attacker to read arbitrary files from the server’s local filesystem. This typically arises when a web application reads files based on user input without proper validation or sanitization.

πŸ”“ An LFD bug might let you read sensitive files like /etc/passwd, .env, or app config files containing API keys, database credentials, or session secrets.

⚠️ Why It’s Dangerous

LFD vulnerabilities can be leveraged to:

  • πŸ—οΈ Read configuration files and environment variables
  • πŸ•΅οΈ Disclose sensitive user or system data
  • πŸ” Enumerate users and services
  • ⛓️ Chain with other vulnerabilities (e.g., log poisoning β†’ RCE)

πŸ”¬ Anatomy of an LFD Vulnerability

Suppose any website allows the user to fetch a image from the following endpoint

GET https://mybankingsite.com/view_file?image=/images/myavatar.jpeg HTTP/1.1

An attacker could change the path in the following manner to read a local file on the system, [This depends on how the application is implemented]

GET https://mybankingsite.com/view_file?image=../../../../../etc/passwd HTTP/1.1

Boom πŸ’₯ the contents of /etc/passwd might get exposed.

πŸ“Œ Pro Tip: Always try prepending your payload with ./ (current directory) to test how the app handles relative paths.

Try:

./etc/passwd
../../../../etc/passwd
....//....//....//etc/passwd

Sometimes the application may expect a extension or will automatically add it to the end of the request.

For Ex

GET http://mybankingsite.com/transaction?u=username HTTP/1.1 

will give us a csv file named username.csv

This can be bypassed by adding a nullbyte(%00) in some cases by adding a ”?” or other characters, depending on how the application works

GET http://mybankingsite.com/transaction?u=/etc/passwd?%00 HTTP/1.1

this may give us the content of etc/passwd file by ignoring the csv extension

πŸ§™β€β™‚οΈ Filter Bypasses and Encodings

πŸ“Œ NOTE: Some applications try to block traversal patterns like ../. Here’s how you can bypass:

URL Encoding:

.    β‡’ %2e
/    β‡’ %2f
../  β‡’ %2e%2e%2f

Bypass Tricks:

TechniquePayload
Dot-Slash…// or .././
Double Encoding%252e%252e%252f
Null Byte (Legacy)/etc/passwd%00
Add Random Suffix/etc/passwd?anything=1

Try combining these creatively to evade filters.

Happy Hunting πŸ”πŸž


Thanks for reading!

Follow along for more deep-dives into systems engineering, architecture, and security research.

← Back to ArticlesWritten by Sahil Singh Rawat