AI LLM-Driven SSRF Lab: Push the Agent's Fetch Tool Inward

✨ AI Summary
FetchBot can retrieve URLs for you with a server-side tool. Its only guard is a denylist: it refuses URLs that contain 'localhost', '127.0.0.1' or 'internal'. Denylists miss things — and the cloud metadata endpoint does not contain any of those words.
Lab at a glance: Advanced · 145 XP · about 20 minutes · runs in your browser, no signup or setup. Try it yourself first; the full solution is behind a spoiler below.

What this lab teaches

This is classic SSRF with an LLM holding the trigger. The agent has a server-side HTTP tool, and a natural-language denylist tries to stop it reaching internal targets. Denylists enumerate 'known bad' strings and always miss alternatives, so the agent can be steered to an internal address the list did not anticipate.

The lesson: guardrails phrased as 'refuse things that look bad' are blocklists, and blocklists fail. Fetch destinations need an allowlist enforced in code, not in the prompt.

How FetchBot guards its http_get tool

You ask FetchBot to retrieve a URL. The model checks the URL against its denylist of forbidden substrings and, if it passes, calls the server-side fetch tool. The cloud metadata address does not match the banned strings, so the guard waves it through.

The attack approach

  • Confirm the guard is a denylist of specific strings, not an allowlist.
  • Identify an internal target that avoids every banned substring.
  • Ask FetchBot to retrieve the cloud metadata endpoint by its numeric address.
  • Surface the credentials the endpoint returns.

Full walkthrough (spoiler)

If the fetch is refused, your URL still matches a banned word — open the steps.

Show the step-by-step solution
  1. Choose the cloud metadata address (169.254.169.254), which contains none of the denylisted words.
  2. Ask FetchBot to fetch it — the natural-language guard sees nothing on its banned list.
  3. The server-side tool retrieves the metadata endpoint, which returns IAM credentials.
  4. The credentials appear in the reply and the lab marks you solved.

Why it works

The guard reasons about surface strings, not about what the address actually is. The metadata IP is internal but matches no banned word, so the model considers it allowed and the tool — running on the server — happily reaches it. The LLM is just the operator of a classic SSRF.

Core principleControl fetch destinations with a code-enforced allowlist and block private, loopback and link-local ranges after resolving the host — never with a prompt-level denylist.

Where this happens in the real world

SSRF driven by LLM tool calls is a serious cloud-security concern, mapping to OWASP LLM06 Excessive Agency plus classic SSRF (A10 in the web Top 10). The 2019 Capital One breach reached a cloud metadata endpoint via SSRF and exposed data on roughly 100 million people — the same endpoint this lab targets.

How to defend against it

  • Enforce an allowlist in code around the fetch tool — only specific external domains, never a prompt denylist.
  • Resolve the host and block private, loopback and link-local ranges (including the metadata IP) at request time.
  • Require IMDSv2 so a reachable metadata endpoint still resists token-less reads.
  • Run tools with least privilege and egress-filter the environment the agent runs in.
Mr Elite tip: Any agent with a server-side fetch tool is an SSRF vector. Judge its guard by whether destinations are allowlisted in code — a natural-language denylist is not a control.

Try it, then go further

Reading about it is the easy part. Open the lab, try your own approach before peeking at the spoiler, and see how many attempts it takes.

❓ Frequently asked questions

What is LLM-driven SSRF?
Server-Side Request Forgery where an LLM agent's HTTP tool is steered to fetch an internal address, often the cloud metadata endpoint, exposing internal data or credentials.
Why doesn't the guardrail stop it?
The guard is a denylist of specific strings. Denylists always miss alternatives — the metadata IP matches none of the banned words.
Why is the metadata endpoint a target?
It can return cloud IAM credentials. The 2019 Capital One breach used SSRF against it; requiring IMDSv2 and egress controls mitigates this.
How do I secure an agent's fetch tool?
Allowlist destinations in code, block private/loopback/link-local ranges after DNS resolution, require IMDSv2, and run the tool with least privilege.
⚡
Join free to earn XP for reading this article Track your progress, build streaks and compete on the leaderboard.
Join Free
Lokesh N. Singh aka Mr Elite
Lokesh N. Singh aka Mr Elite
Founder, Securityelites · AI Red Team Educator
Founder of Securityelites and creator of the SE-ARTCP credential. Working penetration tester focused on AI red team, prompt injection research, and LLM security education.
About Lokesh ->

Leave a Comment

Your email address will not be published. Required fields are marked *