The dvwa file inclusion lab 2026 is Lab 5 of the DVWA series and one of the most practically valuable exercises in the collection — file inclusion vulnerabilities directly enable reading arbitrary server files, executing remote code, and chaining into critical web application compromises. This dvwa file inclusion lab 2026 guide covers Low, Medium, and High security levels across both local file inclusion (LFI) and remote file inclusion (RFI) attack types, using the path traversal dvwa technique to navigate the server’s directory structure.
The dvwa file inclusion lab exercise teaches the core principle: whenever a PHP application includes files using user-supplied input in a require() or include() call without sanitisation, the attacker controls what file the server loads. Local file inclusion dvwa technique uses path traversal dvwa sequences to read files outside the web root. Dvwa rfi exploit takes it further — if the server allows remote URLs, the attacker serves a malicious PHP file on their own server and the target application includes and executes it.
🎯 What You’ll Master in Lab 5
⏱️ 20 min read · 3 hands-on exercises
📋 What This Lab Covers
Complete Lab 4 (CSRF) before starting this lab. Navigate to http://127.0.0.1/dvwa/vulnerabilities/fi/ with Security Level set to Low.
How File Inclusion Works in PHP
PHP’s include() and require() functions load and execute a PHP file at the specified path. When the path contains user input without validation, the attacker controls which file gets included. The server reads and executes whatever path is supplied.
Low Security — Basic LFI & PHP Wrappers
⏱️ Time: 10 minutes · Target: DVWA at 127.0.0.1 — Low security
Part A — Read /etc/passwd with path traversal:
The ../ sequences traverse up the directory tree:
– Start: /var/www/html/dvwa/vulnerabilities/fi/
– ../../../../ → / (filesystem root)
– etc/passwd → /etc/passwd
Expected output: root:x:0:0:root:/root:/bin/bash (first line of /etc/passwd)
Part B — Read PHP source via PHP filter wrapper (without executing it):
?page=php://filter/convert.base64-encode/resource=index.php
The php://filter wrapper reads the file and base64-encodes it
instead of executing it. Copy the base64 output and decode:
In Kali terminal:
echo ‘BASE64_OUTPUT_HERE’ | base64 -d
You now see the raw PHP source code of index.php
📸 Screenshot /etc/passwd output and share in #dvwa-lfi on Discord.
Medium Security — Traversal Filter Bypass
Medium security adds a str_replace() call that removes ../ and ..\ from the input. The flaw: str_replace() is not recursive — it replaces the pattern once, but does not recheck the result. Nesting the traversal sequences inside each other defeats it.
⏱️ Time: 3 minutes · No tools required
Think through all the ways this fails:
1. What happens to “….//….//etc/passwd” after str_replace?
2. Can you URL-encode the slash to bypass the string match?
3. What about double URL-encoding (%252F)?
4. What if you use an absolute path (/etc/passwd) instead of traversal?
5. Why would a blacklist approach always lose to an attacker?
📸 Write your answers and share in #dvwa-lfi on Discord.
High Security — File Wrapper Bypass
High security uses fnmatch("file*", $file) — it requires the filename to start with the string “file”. The bypass is obvious once you know PHP’s file:// stream wrapper exists: file:///etc/passwd starts with “file” — the check passes, the file is included.
Impossible Security — Whitelist
The Impossible level defines an array of allowed filenames and checks if the input matches exactly. No traversal, no wrapper, no encoding — if the value is not in the whitelist array, the request is rejected. This is the only reliable defence against file inclusion.
RFI — Remote File Inclusion Explained
Remote File Inclusion occurs when the PHP configuration has allow_url_include = On (disabled by default in modern PHP). With RFI, the include() call fetches a remote URL — an attacker can host a PHP file on their own server containing a reverse shell, and the target server will download and execute it.
⏱️ Time: 15 minutes · Target: DVWA Docker container
📸 Screenshot the RFI output showing the id command result and share in #dvwa-rfi on Discord. Tag #dvwalab5
The dvwa lfi walkthrough at Low security starts with the simplest path traversal dvwa approach. The URL parameter page=include.php is the injection point. The local file inclusion dvwa payload: page=../../../../etc/passwd. Each ../ traverses one directory upward. The number of traversals needed depends on how deeply the web root is nested — the dvwa file inclusion lab 2026 Low level accepts the payload without any filtering. The response contains the contents of /etc/passwd — a confirmed dvwa lfi walkthrough success.
The php file inclusion technique for escalating LFI to code execution uses the PHP wrapper php://filter/convert.base64-encode/resource= to read PHP source files without executing them. This is the dvwa file inclusion lab technique that reveals database credentials from config.php: page=php://filter/convert.base64-encode/resource=../config. Decode the base64 output and you have the raw PHP source — including any hardcoded credentials. This dvwa lfi walkthrough technique maps directly to real bug bounty findings rated High to Critical.
🧠 QUICK CHECK — Lab 5
📋 Lab 5 Reference — File Inclusion Key Payloads
🏆 Lab 5 Complete — File Inclusion Mastered
LFI, PHP wrappers, filter bypasses, RFI — all four levels done.
Lab 4: CSRF
Lab 6: File Upload
📚 Further Reading
- DVWA Lab 4: CSRF — The previous lab — forge cross-site requests, change passwords, and understand anti-CSRF token implementation at all four security levels.
- DVWA Labs Hub — The complete 30-lab DVWA series from setup through advanced exploitation techniques and vulnerability chaining.
- SQL Injection Tutorial 2026 — SQL injection is frequently found alongside LFI on the same applications — both exploit insufficient input validation in different contexts.
- OWASP: Testing for LFI — OWASP’s comprehensive LFI testing guide covering all bypass techniques, PHP wrapper variants, and log poisoning for code execution.
- PHP Manual: Supported URL Wrappers — Official PHP documentation for all stream wrappers — php://, file://, data://, expect:// and their security implications for file inclusion vulnerabilities.

Leave a Reply