Local File Inclusion · Static Code Audit

LFI Vulnerability Tester

Find Local File Inclusion risk in your own PHP source before an attacker does. Paste your code, run a real static scan, and walk through a guided LFI hardening checklist — no live attacks fired at anyone's server.

  • 100% client-submitted code only
  • No remote target attacks
  • Instant, real results
Send Feedback

Static LFI Code Scanner

Paste PHP source below, or upload a .php file. The scanner reads only the code you provide and flags patterns known to cause Local File Inclusion — nothing is sent to any external server.

Guided LFI Security Self-Audit

Answer these questions about your application's configuration. Your score updates live and points you to the exact fix for anything marked at risk.

Answer the questions above to see your LFI hardening score.

Why use this LFI tester

🔍

Real static analysis

Regex and pattern-based detection of dynamic include/require calls, PHP stream wrappers, path traversal sequences, and unsafe superglobal usage — run entirely on the code you submit.

🛡️

No live attacks

This tool never sends payloads to a third-party URL. It respects the law and your target's infrastructure by working only on source code you own or paste yourself.

Instant feedback

Findings, severity, and remediation guidance render in your browser immediately, with copy and download options for your audit records.

📋

Actionable checklist

A guided, weighted checklist covering open_basedir, allow_url_include, input allow-listing, and log-poisoning defenses.

🌓

Dark & light theme

Comfortable for long audit sessions, with your preference remembered on this device.

📱

Fully responsive

Built to work cleanly on desktop, tablet, and mobile with no horizontal scroll.

How the LFI tester works

  1. 1

    Paste or upload your PHP code

    Add the source file(s) you want reviewed — the tool never fetches or attacks a remote URL for you.

  2. 2

    Run the static scan

    Pattern rules check for unsafe includes, path traversal, and dangerous wrapper usage in your code.

  3. 3

    Review findings

    Each match is shown with a line reference, severity, and a plain-language explanation of the risk.

  4. 4

    Fix and re-scan

    Apply the suggested remediation, then re-run the scan or checklist until your score is clean.

  5. 5

    Export your report

    Copy or download a plain-text report for your security records or ticket tracker.

Understanding Local File Inclusion (LFI)

Local File Inclusion is one of those vulnerabilities that sounds narrow until you see how often it turns up in real audits. At its core, an LFI attack happens when a web application lets user-supplied input decide which file gets pulled into the page, usually through PHP's include or require statements. A developer might write code that reads a page name from the query string and includes it directly, intending only to load a handful of known templates. Left unchecked, that same line becomes a doorway: an attacker can swap in a different path, walk up the directory tree with sequences like ../../, and pull configuration files, credentials, or logs the server was never meant to expose.

People often ask how LFI differs from RFI, or Remote File Inclusion, and the distinction matters for both testing and prevention. LFI stays confined to files already sitting on the local server, while RFI tricks the application into fetching and executing a file hosted somewhere the attacker controls. RFI tends to be blocked automatically once allow_url_include is disabled, which is now the default in modern PHP builds, but LFI does not disappear with a single setting. It depends entirely on how carefully the application validates the path it is handed, which is why LFI remains a fixture in cybersecurity assessments even as RFI has faded.

What makes LFI attractive to an attacker is how far it can escalate. A simple local file inclusion exploit might only disclose a configuration file, but in the right conditions the same flaw becomes a path to code execution. Log poisoning is the classic example: an attacker plants PHP code inside a request header, that string ends up written into a server log file, and then the vulnerable include statement pulls the poisoned log back in and executes it. Combined with PHP's stream wrappers, which can read, encode, or filter file contents on the fly, a seemingly minor LFI attack can unravel into full server compromise if the underlying include logic is not locked down.

Testing for LFI responsibly starts with the code, not the internet. Rather than pointing an automated tool at a production domain and firing path traversal strings at it, the more defensible approach is to read the source, or use a static scanner, and ask a direct question: does user input ever reach an include or require call, in any form, direct or indirect? That question alone catches the majority of local file inclusion bugs before they reach production, and it does not risk knocking over a service or triggering an intrusion alert on infrastructure that is not yours to test.

Prevention, thankfully, is well understood even if it is inconsistently applied. The strongest fix is to stop treating user input as a filename at all: map a small set of allowed page identifiers to their actual file paths in an array, and reject anything that is not an exact match. Where dynamic includes are unavoidable, strip path separators, reject null bytes, and canonicalize the resolved path before comparing it against an allowed base directory. Server-level settings help too. Setting open_basedir restricts PHP to a defined directory tree, disabling allow_url_include removes the remote-fetch avenue entirely, and keeping error messages generic denies an attacker the directory structure hints that make exploitation easier.

None of this requires exotic tooling. A disciplined code review, a static scanner tuned to flag dynamic includes, and a short hardening checklist covering PHP configuration will catch the overwhelming majority of local file inclusion issues in typical web applications. The goal is not to memorize every LFI attack variant that has ever been documented, but to build the habit of treating any path that touches user input as suspicious by default, and to verify — in your own codebase, on your own terms — that the habit actually held.

Frequently asked questions

What is LFI (Local File Inclusion)?

LFI is a web vulnerability where an application includes a local file whose path is influenced by user input, letting an attacker read sensitive files or, in some cases, execute code.

How is LFI different from RFI?

LFI includes files already on the local server, while RFI (Remote File Inclusion) tricks the application into including a file hosted on a remote, attacker-controlled server.

How do I test for LFI safely?

Review your own source code for dynamic include/require calls driven by user input, and use a static scanner or manual code review rather than firing payloads at production systems you do not own.

How do I prevent LFI vulnerabilities?

Avoid passing user input directly into include or require, use an allow-list of known filenames, disable allow_url_include, set open_basedir, and validate input against a strict pattern.

Can LFI lead to remote code execution?

Yes, in some configurations LFI can escalate to code execution through techniques like log poisoning or PHP wrapper abuse, which is why input validation and hardened PHP settings both matter.

Keep testing your stack

Local File Inclusion is one risk among many. Explore the full toolkit to cover the rest of your security surface.

Disclaimer: All product names, logos, and brands mentioned on this page are property of their respective owners and are used for identification purposes only. Use of these names, logos, and brands does not imply endorsement. This tool performs static, offline analysis of code you provide; it does not test, attack, or scan any third-party website or system.