Directory Traversal vs. File Inclusion: PenTest+ Comparison
Directory Traversal allows an attacker to read arbitrary files on the server by escaping the web root directory, whereas File Inclusion (LFI/RFI) allows an attacker to actually execute or include local or remote files within the web application's code execution context.
Directory Traversal (Path Traversal)
Directory Traversal (often known as the `../` attack) aims to access files and directories that are stored outside the web root folder.
By manipulating variables that reference files, an attacker can read sensitive configuration files, password files (like `/etc/passwd`), or source code.
Local File Inclusion (LFI)
LFI is similar to Directory Traversal but more dangerous. It occurs when an application includes a file as part of its execution script without proper validation.
Instead of just reading a file, the application attempts to execute its contents. If an attacker can upload a malicious script (e.g., an image containing PHP code) and then include it via LFI, they can achieve Remote Code Execution.
Remote File Inclusion (RFI)
RFI takes the concept further by allowing the attacker to include a file hosted on an external, remote server.
This is typically caused by improper handling of external URLs in `include` functions. The application reaches out to the attacker's server, pulls down the malicious script, and executes it locally.
Studying for the Exam
Distinguishing between simply reading a file (Traversal) and executing it (Inclusion) is a common testing point.
To ensure you grasp these nuances perfectly, running through high-quality practice exams like Cert Sensei is the best way to study and prepare for the CompTIA PenTest+.
❓ Frequently Asked Questions
What is Directory Traversal?
Directory Traversal allows an attacker to access files outside the web root directory by manipulating file references.
How does Local File Inclusion (LFI) differ from Directory Traversal?
While Traversal reads files, LFI includes a file as part of an execution script, potentially allowing Remote Code Execution.
What is Remote File Inclusion (RFI)?
RFI allows an attacker to include and execute a malicious file hosted on an external, remote server.