Diagnostic playbook
Local File Inclusion via page parameter (absolute path and traversal)
Web / Path Traversal / File Inclusion
Knowledge identity
Definition and taxonomy
Summary
A page parameter is passed to PHP include() allowing local file read. Filters on traversal sequences can be bypassed with absolute paths.
Severity rationale
Demonstrated arbitrary local file read: /etc/passwd contents returned in the response in the authorized lab. File disclosure of source/config/credentials is possible in a real app; here limited to seeded container files.
Aliases
LFI, Local File Inclusion, directory traversal
Standards
CWE-98 CAPEC-252 A01:2021-Broken Access Control
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
1. First Signal
What should make an agent suspicious
Symptoms
Passing /etc/passwd returns the passwd file contents; an invalid file name produces a PHP include() warning with the resolved path; allowlisted pages include file1..file4 normally.
Prerequisites
Authorized lab session. Parameter reaches include() with insufficient validation.
2. Recognition Logic
How to recognize this next time
If a page/file selector maps to an include() call, test absolute paths first (they bypass traversal filters), then relative traversal, then php://filter. A whitelist of allowed filenames (high) blocks all three.
3. Diagnostic Procedure
Safe checks, in order
- Confirm authorized scope. 2. Baseline a valid page. 3. Try absolute /etc/passwd. 4. Try relative traversal and watch for include() warnings. 5. At medium, confirm the str_replace bypass (absolute path). 6. At high, confirm the allowlist blocks inclusion. 7. Read only safe system files.
4. Proof
Evidence
DVWA fi: low and medium ?page=/etc/passwd returned root:x:0:0:root:/root:/bin/bash. Invalid files produced 'Warning: include(...): Failed to open stream' at index.php:36. High returned 'ERROR: File not found!' for traversal and php://filter.
5. Controls
Negative checks
Nonexistent page produced only a PHP warning, not file content; high-level allowlist returned File-not-found for all traversal/filter payloads (mitigated control).
6. Avoid Bad Memory
False positives and traps
PHP include() warnings alone are info disclosure but not proof of file read; only file contents in the response prove LFI. Warning paths can still aid further exploitation.
7. Why It Matters
Impact
Arbitrary local file disclosure (source code, config, credentials) and, with log poisoning or wrappers, potential code execution.
8. Why It Happened
Root cause
User input passed to include() without an allowlist; medium's str_replace on traversal/http strings does not cover absolute paths.
9. Fix
Remediation and prevention
Use an explicit allowlist of permitted filenames. Never include user input directly. Remove display_errors so path leaks are hidden. Disable allow_url_include and dangerous wrappers.
10. Re-test
Verification steps
- After fix, send /etc/passwd and confirm no file contents. 2. Send traversal and wrapper payloads - all rejected. 3. Confirm allowed pages still load. 4. Add regression tests.
Reference
Tools and sources
Tools used
curl for requests, docker exec for read-only source review
References
OWASP File Inclusion; CWE-98; PortSwigger Path Traversal
Intelligence
Products and history
Technologies
PHP, Apache
Affected products / versions
DVWA (Damn Vulnerable Web Application) current master
History
First documented in DVWA fi module in the 2026-08 benchmark run.
Exploit knowledge
Variants and references
Attack surface
page query parameter passed directly to include()
Exploit maturity
proof-of-concept
Known variants
Relative traversal (../), absolute path inclusion (/etc/passwd), PHP stream wrappers (php://filter), filter bypass via double-encoding or ....// nesting
Defensive signatures
page parameters containing /etc/passwd, ../ traversal, php://filter strings; response body containing local file contents or PHP include() warnings naming index.php:36
Reproduction commands
Low (no filter): curl -s -b $JAR "http://127.0.0.1:4280/vulnerabilities/fi/?page=/etc/passwd" # root:x:0:0... Medium (strips http:// https:// ../ ..\): curl -s -b $JAR "http://127.0.0.1:4280/vulnerabilities/fi/?page=/etc/passwd" # absolute path bypasses filter High (fnmatch file* allowlist): curl -s -b $JAR "http://127.0.0.1:4280/vulnerabilities/fi/?page=../../../../etc/passwd" # ERROR: File not found!
Exploit references
No external references stored; all evidence from the authorized local lab.
Case provenance