SSRF

Source + configuration review

A URL previewer becomes a bridge into a localhost-only admin panel. The important question is not “can my browser reach it?”—it is “who makes the second request?”

WebFetch ProPHP streamsApache IP ACLDocker networkingLoopback trustCWE-918
  1. 1. User chooses a URLGET /fetch.php?url=…The destination is controlled through one query parameter.
  2. 2. PHP fetches itfile_get_contents($url)The connection comes from the application's container.
  3. 3. Apache trusts loopback127.0.0.1 → /internal/The new request satisfies the source-IP restriction.
  4. 4. The response returnshtmlspecialchars($content)Internal HTML is displayed as text, including the flag.
Two HTTP requests, two network perspectives. The access-control rule does not fail to recognize the IP; the fetcher gives an untrusted user access to a trusted request origin.

The scenario

WebFetch Pro lets employees enter a URL and preview its content. The public handler passes that value directly to PHP's stream reader. There is no destination allowlist, scheme restriction, port policy, or resolved-IP check.

The same Apache instance serves /internal/, a simulated diagnostics and credentials panel. Its directory is restricted to requests from IPv4 or IPv6 loopback. A browser arriving through Docker's published port is normally outside that trust boundary; PHP requesting http://127.0.0.1/internal/ is inside it.

This is a beginner, response-visible SSRF exercise. No filter bypass, brute force, command injection, or additional vulnerable service is required for the intended solve.

What was reviewed—and what was not run

The twelve files in SSRF/ were read, including all PHP source, Apache rules, Docker configuration, Markdown guides, and the supplied Python tester. Official documentation was consulted for technical corrections. No container was built or started, no PHP or Python was executed, no lab endpoint was contacted, and no HTML file was opened or run. Behavior below is source-defined or author-reported, not a fresh execution transcript.

What a complete solve means

  • Identify the user-controlled url parameter and its server-side fetch sink.
  • Explain why host port 8080 and container port 80 are different.
  • Compare direct denial with a server-originated loopback request.
  • Recognize the internal response in the returned <pre>, not just a 200 status.
  • Explain the missing destination authorization and propose defenses beyond string filtering.

The central idea

A server-side fetch borrows the server's reachability. An IP-only rule cannot tell whether a trusted process is acting for an untrusted user.

The central trap

Escaping the response prevents HTML interpretation. It does not stop the server from requesting or disclosing the wrong resource.

Reveal the intended payload and source-defined flag

The URL below is the value entered into the fetch form—not the browser's outer application URL.

Container-local destination · reference text only
http://127.0.0.1/internal/
Literal in internal/index.php · also reported by the guide
FLAG{ssrf_internal_service_access}

The flag is present in the supplied source. Knowing this literal from a source review is not proof that a running deployment was exploited.

How SSRF works

Checked against fetch.php

Trace input to destination, then destination to output. The vulnerable action happens before the response is escaped.

1. The form supplies the destination

src/index.php · form excerpt, lines 17–28
<form action="fetch.php" method="GET" class="fetch-form">
    <label for="url">Enter a URL to fetch:</label>
    <input type="text" id="url" name="url" required>
    <button type="submit">Fetch</button>
</form>

The input is type="text". The browser's required attribute checks ordinary form submission for an empty value; it does not authorize a network destination. A direct request to fetch.php does not need to use the form at all.

2. PHP reads the query string

src/fetch.php · line 30
$url = isset($_GET['url']) ? $_GET['url'] : '';

The handler later checks empty($url), but does not parse or validate a nonempty destination. There is no check between the attacker-controlled value and the resource reader.

3. The sink opens the resource as the server

src/fetch.php · line 70
$content = @file_get_contents($url);

For an HTTP URL, PHP makes a new HTTP request. It does not tell the user's browser to navigate there. In this Docker deployment, 127.0.0.1 in the supplied URL refers to the container's network namespace.

The @ suppresses warnings from the call. It is not a security control and does not change which destinations can be reached. The function still returns false for many failures.

No custom stream context is supplied. The application does not set an explicit fetch timeout, disable the HTTP wrapper's default redirect following, or cap the number of response bytes read. PHP's configured defaults still apply; this is not a claim that all requests wait forever.

4. The trusted source is enough for the internal route

A request to http://127.0.0.1/internal/ connects to Apache on container port 80. Its source address is loopback, which the directory ACL permits. The internal page has no additional login or per-user authorization in its PHP source.

Conceptual data flow · not an observed trace
untrusted GET parameter
    → PHP HTTP stream
    → container loopback:80
    → Apache's /internal/ source-IP check passes
    → internal HTML body
    → public fetch result

5. HTML escaping does not remove the disclosure

src/fetch.php · result rendering, lines 72–83
if ($content === false) {
    echo '<div class="error-box">';
    echo '<strong>Error:</strong> Could not fetch the specified URL.';
    echo ' The resource may be unreachable or the URL may be invalid.';
    echo '</div>';
} else {
    echo '<pre class="fetched-content">';
    echo htmlspecialchars($content);
    echo '</pre>';
}

The internal page's tags are shown as text rather than rendered as a live admin interface. Its embedded CSS and links are not activated by this output. The flag and simulated backup values remain readable because they are still part of the returned text.

XSS prevention and SSRF prevention answer different questions

htmlspecialchars controls how fetched bytes are interpreted in HTML. Destination validation controls which resource the server may retrieve. A page can correctly escape its output and still disclose an internal service through SSRF.

6. PHP streams also expose a file-reading surface

file_get_contents is not an HTTP-only client. The local file:// wrapper—and ordinary filesystem paths—can read files available to the PHP process. Such a read does not pass through Apache's directory authorization, because it is a filesystem operation rather than a request to Apache.

The Dockerfile turns allow_url_fopen on for remote URL wrappers. Disabling that setting would restrict supported remote streams, but does not disable local filesystem reads. File existence, permissions, open_basedir, and the available wrappers still matter.

The supplied guides call this “LFI via SSRF.” More precisely, this sink performs local file disclosure: it reads bytes and escapes them. It does not use include or execute the contents as PHP.

7. Keep demonstrated capabilities separate from possibilities

The intended route is response-visible HTTP SSRF to one known internal page. Other schemes, IPv6, alternative address formats, non-HTTP services, and cloud metadata require their own environment and protocol checks. Their appearance in a payload list is not evidence that they worked.

This handler uses the default HTTP GET behavior and does not expose custom outbound headers or a request body through the form. It is therefore not automatically capable of arbitrary Redis/MySQL commands or an AWS IMDSv2 token exchange.

Architecture & access

Docker + Apache configuration

There is one container and one Apache service. “Internal” is a directory authorization rule, not a second hidden server.

The deployment contract

The Dockerfile starts from php:8.2-apache, copies src/ into /var/www/html/, installs the internal-directory configuration, and explicitly enables remote stream fetching. Compose publishes host port 8080 to container port 80.

docker-compose.yml · complete service definition
services:
  ssrf-lab:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: ssrf-lab
    ports:
      - "8080:80"
    restart: unless-stopped

The public application address for the supplied mapping is http://localhost:8080/. The README's earlier http://localhost address omits the required host port. Conversely, the inner loopback payload normally omits :8080 because Apache listens on 80 inside the container.

ContextAddressMeaning
Browser → published applicationlocalhost:8080The student's Docker host, forwarded to the container.
PHP → its own Apache service127.0.0.1:80The container's loopback interface.
PHP → 127.0.0.1:8080Wrong port for this serviceNothing in the supplied deployment declares an Apache listener here.
PHP → [::1]:80IPv6 loopbackAllowed by the ACL if IPv6 networking and the listener support the connection.

The actual Apache rule

apache/internal.conf · directives, lines 17–25
<Directory /var/www/html/internal>
    # Deny all access by default
    Require all denied

    # Only allow requests originating from localhost (the server itself)
    # This simulates an internal-only service bound to loopback
    Require ip 127.0.0.1
    Require ip ::1
</Directory>

Apache 2.4 combines multiple ungrouped Require directives in the same section as an implicit <RequireAny>. The effective logic is:

Equivalent authorization logic · not a configuration change
denied_for_everyone OR source_is_127.0.0.1 OR source_is_::1

Loopback matches at least one granting provider.
Other source addresses match none.

Require all denied is not an unconditional veto when combined this way. Rewriting these three rules into a <RequireAll> would deny everyone, including loopback. The comment says the service is “bound to loopback,” but this directive changes authorization, not Apache's listening address.

Direct access versus the inner request

Expected network perspectives · configuration-derived
Direct:
  browser → Docker host:8080 → Apache:80 /internal/
  Apache sees the external/NAT-side peer, normally not loopback.
  Expected: 403 Forbidden.

Through the fetcher:
  browser → Docker host:8080 → Apache:80 /fetch.php
  PHP → 127.0.0.1:80 /internal/
  Apache sees source 127.0.0.1.
  Expected: internal page returned to PHP, then escaped to the browser.

The exact peer IP on the direct path depends on Docker's platform, network mode, NAT/proxy behavior, and any additional proxy. Do not invent a fixed 192.168.x.x address from the documentation. The intended distinction is a non-loopback peer versus a loopback peer.

Changing an HTTP header such as X-Forwarded-For is not needed for this solve. The payload causes an actual loopback connection. No trusted-proxy address rewriting is configured in the supplied lab files.

Where the internal route is disclosed

src/robots.txt lists Disallow: /internal/. The public page's HTML comment names the diagnostics panel and explains the localhost restriction. The result page's TODO comment also mentions it.

src/robots.txt · complete snapshot
User-agent: *
Disallow: /internal/

# Internal resources - restricted to localhost only
# Contact: security@cyberparadigm.in
# Last updated: 2026-01-15

robots.txt is a crawler instruction, not access control. It is useful reconnaissance evidence here, but obscuring the path would not fix the unrestricted fetch sink.

What the internal page actually contains

The page reports hostname, server IP, remote IP, server software, PHP version, and timestamp using runtime PHP expressions. It also contains fixed training values labelled as an admin credentials backup and the literal challenge flag.

The listed database hostname and API-key-shaped value are simulated data. Compose defines no database, cloud instance, Redis server, or separate admin service. Those labels do not establish that corresponding infrastructure exists or that the values authenticate anywhere.

The supplied host mapping is not loopback-only

"8080:80" does not specify a host bind address. Docker normally publishes it on all host interfaces, subject to daemon settings and firewall rules. For any later practice deployment, prefer an isolated environment and an explicit loopback host binding such as "127.0.0.1:8080:80". This is advice only; the supplied configuration was not changed or started.

Solve walkthrough

Read-only solve plan

Find the fetcher, identify the trusted destination, and explain the request-origin change. One well-understood payload is enough.

The commands below are inert reference text for a future, explicitly authorized local lab session. They were not run. This guide contains no fetch form, live test button, scanner, or embedded lab.

  1. Establish the real application address

    Read Compose's 8080:80 mapping and the Dockerfile's Apache image. Record http://localhost:8080/ as the outer address, and port 80 as the container-local listener.

    Static evidence: docker-compose.yml lines 14–17; Dockerfile lines 8, 24, 31–32, 50, and 55. No startup command is necessary to understand the mapping.
  2. Find the input and resource reader

    The main form sends GET to fetch.php with parameter url. Follow that parameter to line 70. Neither an empty-input check nor output escaping validates a destination.

    The supplied walkthrough first uses a normal external page as a baseline. In a future test, the useful observation is that the server returns the external page's source—not that your browser independently loads that destination.

  3. Identify the internal route and restriction

    Read the public HTML comments and robots.txt: both expose /internal/. Read the corresponding Apache directory rule to establish that loopback requests are allowed.

    For a future runtime baseline, a direct request should be denied when Apache sees a non-loopback source:

    Optional direct-access baseline · local lab only, not run
    curl -i --max-time 10 "http://localhost:8080/internal/"

    403 Forbidden is the author-reported and configuration-expected result, not a response captured during this review.

  4. Change the inner destination to container loopback

    The intended form value is http://127.0.0.1/internal/. Omitting a port selects HTTP port 80, so PHP calls its own Apache service without going through the host's published port.

    Optional one-request reproduction · inert command
    curl -i --get --max-time 10 \
      --data-urlencode "url=http://127.0.0.1/internal/" \
      "http://localhost:8080/fetch.php"

    --get keeps the outer request as GET; --data-urlencode safely places the entire inner URL into one parameter. This avoids treating an inner & as an additional outer query parameter.

    The timeout limits the example command's wait. It does not configure PHP's fetch timeout or cancel all work on the server if the client stops waiting.

  5. Interpret the returned body, not just the status

    Look inside the fetched-content <pre> for the escaped Internal Admin Panel HTML, the flag, and the Remote IP field. For the IPv4 loopback payload, the internal page's REMOTE_ADDR should reflect 127.0.0.1 in the intended deployment.

    The main result page already contains words such as “internal” in comments. A keyword hit anywhere in the outer page is weak evidence. Use the fetched-content region and the actual internal response as the discriminator.

    Future runtime evidence: direct denial, the exact submitted inner URL, returned internal content, and the internal peer-address field. Current evidence: source and configuration only.
  6. Keep file disclosure separate from the primary solve

    The supplied guide also proposes a benign local hostname read. It is not required to obtain the intended internal page.

    Optional wrapper demonstration · authorized local lab only, not run
    curl --get --max-time 10 \
      --data-urlencode "url=file:///etc/hostname" \
      "http://localhost:8080/fetch.php"

    If permitted by the environment, this reads the container's file as the PHP process. It does not make an HTTP request and does not exercise Apache's loopback ACL. No file contents from a running container were obtained here.

  7. Write a claim that matches the evidence

    The root cause is attacker-controlled resource retrieval without destination authorization. The intended impact is disclosure of a source-IP-restricted internal HTTP page. Additional file access is a separate source-supported surface whose actual readable targets depend on runtime controls.

    Do not claim database compromise, real credential theft, cloud compromise, remote code execution, or a completed port scan from this static review. The supplied ssrf_exploit.py was inspected only; it was not needed or run.

Reveal the source-defined answer and expected response shape
Flag · literal in src/internal/index.php line 101
FLAG{ssrf_internal_service_access}

Conceptually, the outer page contains an escaped version of the internal page:

Illustrative excerpt · not a captured response
<pre class="fetched-content">
  &lt;!DOCTYPE html&gt;
  …
  &lt;title&gt;Internal Admin Panel&lt;/title&gt;
  …
  FLAG{ssrf_internal_service_access}
  …
</pre>

The browser would display the decoded angle brackets as plain text. Hostname, timestamp, and version values cannot be filled in without a runtime request.

Expected outcomes—not recorded results

CaseExpected behaviorEvidence caveat
Direct /internal/Apache denies a non-loopback peer with 403.The actual peer depends on the deployment path.
Inner http://127.0.0.1/internal/Loopback ACL grants; internal HTML is escaped into the result page.Source supports the route; it was not tested live.
Missing or empty url“No URL provided” message; no resource fetch.The handler does not explicitly set an error HTTP status.
Inner resource cannot be readfile_get_contents may return false; a generic error is displayed.The outer response can still be 200.
Inner HTTP errorThe default HTTP wrapper normally treats 4xx/5xx as a read failure.The inner status is not deliberately forwarded to the outer response.
Local hostname readFile bytes displayed if readable by the PHP process.Permissions and runtime restrictions still apply.

If a future test looks wrong

  • Outer connection fails: check the authorized deployment and host port. This review intentionally did not start anything.
  • Loopback payload fails: distinguish container port 80 from host port 8080, and inspect the actual listener and loaded ACL.
  • Direct access is unexpectedly allowed: inspect the real peer IP, enabled Apache configuration, network mode, and any overriding authorization section.
  • The panel appears as markup: that is expected. The handler escapes the fetched HTML.
  • All tested ports look “open”: the tester may be checking the outer page's 200, not the inner connection.
  • IPv4 works but IPv6 does not: ACL permission is not proof of IPv6 listener or network availability.
  • A file read fails: check the container-local path and PHP process permissions; do not assume root access.
  • Burp and the lab both want port 8080: use a different proxy listener port during any later authorized testing.

Things to learn

Takeaways + defensive design

Authorize the destination before connecting. Treat internal services as security boundaries of their own—not as automatically safe neighbors.

The server can become an unintended intermediary

SSRF is about user-controlled requests crossing a trust boundary through a server. It is not inherently limited to a server's loopback IP: an outbound connection uses whatever source address routing selects. Loopback is the decisive origin only for this lab's chosen destination.

The server is not universally more powerful than a browser. A browser can also access its own local network, while a server may be tightly isolated. The question is the difference between their reachable and trusted destinations, not an absolute claim that browsers only reach public resources.

Ingress restrictions do not authorize egress

The Apache ACL governs who may enter /internal/. The PHP fetcher's missing policy governs where a public request may cause the application to connect. These are different controls. Keeping the internal ACL is useful, but it cannot replace authentication or a destination policy.

Choose the observable result before automating

A scanner needs a signal that actually represents the claim. Here, a 200 means the public handler responded normally—not that an inner HTTP request succeeded or a non-HTTP port is open. A generic timeout is also not a reliable closed-port verdict.

Inspect returned content and inner-fetch diagnostics in an owned test environment. The lab's response-visible SSRF should not be indiscriminately labelled “blind SSRF.” Blind SSRF is used when the inner response is not directly returned, requiring other observations.

Prefer fixed destinations over free-form URLs

If the feature only needs a few integrations, accept a resource identifier and construct the destination from a server-owned mapping. Restrict scheme, port, path, and operation to business requirements. This is easier to reason about than letting every user supply an arbitrary URL.

If arbitrary public URLs are genuinely required, use a dedicated, isolated fetch service with a reviewed URL parser and connection-time destination enforcement. A syntactically valid URL is not necessarily an authorized destination.

A defense-in-depth checklist

ControlWhat to requireWhy a shortcut fails
Destination policyExact permitted hosts/resources where feasible; fail closed on malformed or ambiguous input.A hostname suffix or substring check can authorize the wrong host.
Scheme and port policyOnly the protocols and ports the feature needs; reject local paths and unwanted wrappers.Blocking just file:// leaves ordinary local paths and other unwanted schemes.
Address classificationValidate all relevant A/AAAA answers and IP literals against permitted networks.A public-looking name can resolve to loopback, private, link-local, or another forbidden address.
Connection bindingConnect only to validated addresses; preserve the original hostname for Host, TLS SNI, and certificate verification.A second unchecked DNS lookup creates a validation-to-connection race.
Redirect policyDisable automatic redirects, or apply the same checks to every hop and reconnection.An allowed initial URL can redirect into an internal destination.
Network isolationRestrict fetch-worker egress and its access to host/internal services; apply appropriate local and network controls.A container with unrestricted outbound access is not an SSRF sandbox.
Internal authorizationAuthenticate callers and authorize operations independently of IP location.“From localhost” identifies a connection origin, not the user behind it.
Resource limitsConnect/read deadlines, byte limits while streaming, bounded concurrency, and safe handling of decompression.A CSS preview height limit does not limit server memory or network work.
Output and loggingKeep context-appropriate escaping; log safe destination and outcome metadata without exposing secrets.Escaping only addresses HTML interpretation, and unbounded logs can leak fetched secrets.

Guzzle's proxy “no” option is not a network denylist

The supplied explanation presents proxy => ['no' => [...]] as an SSRF restriction. Guzzle documents that list as hosts which should not use a proxy. It does not mean “do not connect to these hosts.” Choosing Guzzle or cURL alone does not authorize destinations.

Cloud metadata is a related risk, not part of this deployment

The guides mention cloud metadata and credential exposure. Compose does not define a metadata service, and none was contacted. Reachability and authorization requirements depend on the cloud and instance configuration.

For AWS, requiring IMDSv2 and disabling IMDSv1 adds defense in depth. IMDSv2 uses a token-creation PUT and token-bearing metadata requests; the lab's URL-only GET fetcher does not directly provide those request controls. Metadata hardening does not fix general SSRF, and least-privilege instance roles remain important.

Write the report around proved impact

Source-review finding · editable reporting model, not runtime evidence
Finding: Unrestricted server-side resource retrieval
Component: /fetch.php
Input: GET parameter "url"
Classification: CWE-918

Root cause:
  User input reaches file_get_contents without destination policy.

Source-supported path:
  A request to http://127.0.0.1/internal/ originates on container
  loopback, which the supplied Apache directory ACL permits.
  The public handler returns the internal HTML as escaped text.

Expected impact:
  Disclosure of the simulated internal admin page and flag.
  A separate local-file-reading surface exists, subject to permissions.

Evidence level:
  Static source and configuration review. No live reproduction.

Remediation:
  Restrict destinations and schemes; enforce validated connection
  targets and redirects; isolate egress; authenticate internal services.

Severity:
  Assess against the real deployment and accessible data.
  Do not assign a numeric CVSS score without its vector and rationale.

The supplied report's 8.6 CVSS 3.1 score has no vector and is not independently justified here. Likewise, “API key” labels in the training panel do not prove working credentials. Record confidentiality impact separately from speculative integrity or availability impact.

The guide's A10:2021 classification is a historical OWASP Top 10 label. The current MITRE CWE entry also maps SSRF to A01:2025 — Broken Access Control. State the edition whenever citing an OWASP category; keep CWE-918 as the weakness identifier.

Self-check

  • Can I draw the outer and inner requests without mixing their source IPs?
  • Can I explain why the inner payload uses port 80 while the browser uses 8080?
  • Can I explain Apache's implicit RequireAny behavior?
  • Can I distinguish a directory ACL from a loopback-only listener?
  • Can I explain why output escaping does not fix SSRF?
  • Can I distinguish file reading from PHP inclusion or code execution?
  • Can I explain why the outer 200 status is an unreliable scanner signal?
  • Can I describe how DNS changes and redirects affect destination validation?
  • Can I separate source-defined behavior from an observed exploit?

Useful follow-up topics

URL parser agreement, IPv4/IPv6 address normalization, DNS rebinding, redirect revalidation, Docker namespaces, network egress enforcement, authenticated service-to-service calls, and evidence-based vulnerability scoring.

Files & source notes

Provenance + corrections

The PHP and configuration are the evidence for this guide. The supplied walkthrough's success statements are not new observations made during this review.

Reviewed file inventory

Supplied fileRoleReview
SSRF/src/index.php63-line public form and internal-path hint.Read in full; GET input and comments checked.
SSRF/src/fetch.php112-line resource-fetch handler.Read in full; input, sink, error path, escaping, and absent status forwarding checked.
SSRF/src/internal/index.php105-line simulated internal panel.Read in full; runtime expressions distinguished from fixed training values.
SSRF/src/robots.txtSix-line crawler hint exposing /internal/.Read in full; complete text embedded above.
SSRF/src/style.css185-line application stylesheet.Read in full; preview styling is not a security boundary.
SSRF/apache/internal.conf25-line source-IP restriction.Read in full; implicit OR behavior checked against Apache documentation.
SSRF/Dockerfile60-line image and server configuration.Read in full; never built or executed.
SSRF/docker-compose.yml18-line deployment definition.Read in full; no container lifecycle command issued.
SSRF/ssrf_exploit.py165-line, eight-payload automated tester.Read in full; success criteria reviewed, not run.
SSRF/README.mdScenario, setup, learning outcomes, and expected verification.Read in full; conflicting host-port instructions noted.
SSRF/LAB_EXPLANATION.mdTechnical overview and defensive examples.Read in full; general claims qualified against implementation and official docs.
SSRF/EXPLOITATION_GUIDE.mdWalkthrough, payloads, automation, and reporting template.Read in full; expected outputs treated as author-reported.

Related PDFs present, but not used as evidence

The collection also contains Arshlaan_s Write-ups/SSRF - Internal Service Access.pdf and Arshlaan_s Write-ups/ssrf-detailed-technical-explanation.pdf, plus copies in the field guide. The reader could not supply model-readable PDF content in this session. No PDF extraction program was run, and no claims here depend on having read those PDFs.

Correction register

  • Host address: the active Compose mapping is 8080:80; use localhost:8080 externally and container loopback port 80 internally.
  • “Internal service bound to localhost”: the supplied file applies directory authorization. It does not configure a separate listener or container.
  • “Deny all” plus loopback exceptions: ungrouped Apache Require rules are OR-combined, not a sequential deny-then-override procedure.
  • “Admin panel is displayed”: the fetched HTML is escaped inside <pre>; it is readable source, not an active rendered panel.
  • “200 = successful fetch/open port”: the outer page can return 200 while displaying a fetch error. Both the guide's shell scan and the Python tester use this unreliable signal.
  • “LFI”: the local wrapper performs file disclosure. There is no PHP inclusion or execution sink here.
  • “All wrappers/IPv6 variants work”: behavior depends on wrapper support, configuration, permissions, resolver behavior, and listeners. No variants were tested.
  • “Disable allow_url_fopen to fix it”: this restricts remote wrappers, not the local file wrapper or ordinary paths.
  • “Guzzle proxy no blocks internal IPs”: it selects hosts which bypass a proxy; it does not forbid their destinations.
  • “Port 3306 means MySQL access”: an HTTP GET to a port is not a valid database protocol exchange, and Compose defines no database.
  • “Cloud exploitation”: no metadata service is part of this lab. Token and header requirements cannot be ignored.
  • CVSS and exam objective numbers: the supplied score lacks a vector; certification objective numbering also needs an exam version. Neither is asserted as independently verified here.
  • Burp listener: suggesting proxy port 8080 conflicts with the lab's published port when both bind the same local address.
  • Host exposure: the unqualified published-port mapping is normally all-interface, not a guaranteed localhost-only practice setup.

What the supplied tester actually counts

ssrf_exploit.py · selected logic, lines 47 and 66–75
response = requests.get(BASE_URL, params={"url": payload}, timeout=TIMEOUT)

# … metadata, flag matching and keyword matching …

if response.status_code == 200:
    # … prints the outer status and any matched text …
    return True, response.text, metadata

The summary's “Successful” count includes every test where the public fetch endpoint returned 200, even when its body contains “Could not fetch the specified URL.” The script separately looks for a flag, but its general success count is not a reliable per-payload exploit result.

Its len(response.text) measures decoded-text characters, although the printed label says bytes. Keyword matching scans the entire outer HTML, including comments. These are useful reasons to inspect a helper before trusting its output.

Where to look in the implementation

  • index.php lines 17–28: GET form, parameter name, and text input.
  • index.php lines 50–60: public developer comment naming the internal route.
  • fetch.php lines 30, 50, and 70: input, empty-value branch, and unrestricted resource read.
  • fetch.php lines 72–83: generic failure versus escaped response; no explicit status propagation.
  • internal/index.php lines 80–85: environment-derived diagnostics, including remote IP.
  • internal/index.php lines 90–101: fixed simulated backup values and literal flag.
  • apache/internal.conf lines 17–25: directory scope and loopback authorization.
  • Dockerfile lines 24, 31–32, and 50: source copy, ACL installation, and remote-wrapper setting.
  • ssrf_exploit.py lines 66–75 and 135–138: outer-status success test and summary count.
Read the original fetch.php · complete inert source snapshot

Preserved as text, including the author's comments. Their broader impact claims are qualified in this guide. Reading or copying this block does not invoke PHP or make a request.

SSRF/src/fetch.php · original source
<?php
// ============================================================
// fetch.php — Server-Side Resource Fetcher
// ============================================================
//
// VULNERABILITY: Server-Side Request Forgery (SSRF)
//
// This script takes a user-supplied URL, fetches its content
// using the server's network context, and displays it back
// to the user. There is NO validation whatsoever on the URL.
//
// WHY THIS IS VULNERABLE:
// 1. No allowlist — any URL scheme/host/port is accepted.
// 2. No denylist — localhost, 127.0.0.1, internal IPs are
//    not blocked.
// 3. The request originates FROM the server, so it can reach
//    internal services that are not exposed to the internet.
// 4. file_get_contents() will happily follow http://, https://,
//    file://, ftp://, and other PHP-supported stream wrappers.
//
// REAL-WORLD IMPACT:
// An attacker can use this to:
//   - Access internal admin panels (e.g., http://127.0.0.1/internal/)
//   - Read local files (e.g., file:///etc/passwd)
//   - Scan internal network ports
//   - Interact with cloud metadata services (e.g., 169.254.169.254)
// ============================================================

// Retrieve the user-supplied URL from the query string
$url = isset($_GET['url']) ? $_GET['url'] : '';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WebFetch Pro – Result</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <header>
            <h1>&#127760; WebFetch Pro</h1>
            <p class="tagline">Resource Fetch Result</p>
        </header>

        <main>
            <a href="/" class="back-link">&larr; Back to search</a>

            <?php if (empty($url)): ?>
                <!-- No URL was provided -->
                <div class="error-box">
                    <strong>Error:</strong> No URL provided. Please go back and enter a URL.
                </div>
            <?php else: ?>
                <div class="result-meta">
                    <strong>Fetched URL:</strong>
                    <code><?php echo htmlspecialchars($url); ?></code>
                </div>

                <div class="result-box">
                    <?php
                    // --------------------------------------------------------
                    // VULNERABLE CODE: No URL validation is performed.
                    // The server fetches whatever URL the user provides.
                    // This allows SSRF attacks against internal services.
                    // --------------------------------------------------------

                    // Suppress warnings to provide a cleaner error message
                    $content = @file_get_contents($url);

                    if ($content === false) {
                        echo '<div class="error-box">';
                        echo '<strong>Error:</strong> Could not fetch the specified URL.';
                        echo ' The resource may be unreachable or the URL may be invalid.';
                        echo '</div>';
                    } else {
                        // Display the fetched content as-is
                        // Using htmlspecialchars to prevent XSS from fetched content
                        echo '<pre class="fetched-content">';
                        echo htmlspecialchars($content);
                        echo '</pre>';
                    }
                    ?>
                </div>
            <?php endif; ?>
        </main>

        <footer>
            <p>&copy; 2026 WebFetch Pro &mdash; Internal Tool v3.1.2</p>
            <p style="font-size: 0.7em; color: #3a4a5a; margin-top: 5px;">
                Developed by <a href="https://cyberparadigm.in" target="_blank" style="color: #4a9eff;">CyberParadigm</a>
            </p>
        </footer>
    </div>

    <!-- 
        ============================================================
        TODO: Implement URL validation before production deployment
        
        Security review findings (2026-01-15):
        - Need to restrict access to internal resources
        - Block localhost/127.0.0.1 in fetch requests
        - /internal/ endpoint should never be reachable externally
        
        Priority: HIGH
        Assigned to: security@cyberparadigm.in
        Ticket: SEC-2847
        ============================================================
    -->
</body>
</html>

Official references consulted

The guide itself requires no network connection. These documentation links are optional and only navigate when selected.

Review boundaries

  • Checked by reading: all twelve supplied lab files, vulnerable data flow, Apache authorization, declared port mapping, response escaping, source flag, and tester logic.
  • Author-reported only: direct 403, successful inner fetch, wrapper/IPv6 successes, and sample execution outputs.
  • Not performed: Docker builds or startup, PHP/Python execution, port scans, lab HTTP requests, browser rendering, HTML/JavaScript execution, or executable-based validation.
  • Not embedded: a runnable lab, a working scanner, live external content, PDFs, or a fetched internal response.
  • Original files: left unchanged. Only this standalone reference was added.
One HTML file, no external assets or automatic network requests. Its only executable code is local page navigation, theme, clipboard, and printing behavior for when you choose to open it. All PHP, Python, configuration, and command examples are escaped reference text.