Skip to Content

Local File Inclusion (LFI)

When an application chooses which file to display based on a parameter provided by the user, poor validation opens the door to LFI: reading sensitive server files, sometimes leading as far as code execution.

What is LFI?

Many websites determine which page to serve from a parameter (for example ?page=about). If the application includes the corresponding file without checks, an attacker can manipulate this parameter to point to other files on the server, hence the name "local file inclusion".

They can then read configuration files, logs, or even secrets. Under certain conditions, LFI can even lead to code execution. It is a textbook case of failed input control, close to broken access control and a classic finding in penetration testing.

What it enables

Read sensitive files

Configuration files, credentials, logs: valuable information for preparing a broader attack.

Traverse the directory tree

Using sequences such as "../" (path traversal), reach folders outside the intended location.

Go as far as code execution

Combined with other elements (logs, file upload...), LFI can sometimes result in code execution.

A stepping stone

Often a first step: the information obtained fuels a deeper intrusion.

A matter of trusting input

Like most web vulnerabilities, LFI stems from excessive trust placed in user-supplied data, here a file name or path. The habit to build is universal: never use input directly to access a resource without strictly validating it. It is the same principle that protects against dangerous file upload .

The principle: allowlists and controlled paths

Protection relies on a few simple rules: never build a file path directly from user input, use an allowlist of authorized pages/resources (for example via an identifier that maps to a known file), neutralize path traversal ("../"), and confine access to a dedicated directory. All of this is complemented by least privilege and validated by a penetration test.

Protect yourself, step by step

1

Ban dynamic paths

Do not build a file path from raw user input.

2

Use an allowlist

Map a supplied identifier to a known, authorized file rather than accepting a free-form name.

3

Neutralize path traversal

Filter/normalize paths to prevent directory traversal ("../").

4

Confine access

Restrict reads to a dedicated directory, excluding system files and secrets.

5

Least privilege

Limit the process privileges to reduce what can be read if a vulnerability is exploited.

6

Test & audit

Look for LFI and path traversal during audits and penetration tests.

Why work with BCIT?

Realistic tests

We test your file and path parameters to reveal exploitable LFI issues.

Actionable fixes

Concrete recommendations tailored to your language and architecture.

A full-picture view

From application security to audits, the whole chain.

Not ready to talk yet? Discover our cybersecurity diagnostic →

Are your file parameters under control? 🚀

Let's take 15 minutes to assess your applications' exposure to LFI and path traversal, and define the priority fixes.