GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - themsquared/mcp-gateway-redirect-ssrf-demo

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
demo.sh
demo.sh
 
 
gateway.py
gateway.py
 
 
internal_service.py
internal_service.py
 
 
tool_pod.py
tool_pod.py
 
 

Repository files navigation

mcp-gateway-redirect-ssrf-demo

A minimal, runnable reproduction of the bug class Microsoft fixed in microsoft/mcp-gateway v1.0.1 (published 2026-11-16): an MCP tool gateway that follows HTTP redirects coming back from a tool call.

The problem

An MCP gateway dispatches a tool call to a tool pod and returns whatever that pod responds with as the tool result. If the gateway's HTTP client follows redirects by default — which is the default behavior of most HTTP clients, including Python's urllib for GET requests — then a tool pod doesn't have to return data directly. It can return an HTTP 302 with a Location header pointing anywhere the gateway can reach: a cloud metadata endpoint, an internal admin API, a sidecar that was never meant to be exposed through a tool call.

The gateway then requests that URL on the tool pod's behalf, and returns that response as the "tool result." The agent on the other end has no way to tell the difference between a legitimate tool result and a value smuggled out of the gateway's own network by a tool pod that is malicious, compromised, or just misconfigured.

This is a textbook SSRF / confused-deputy bug: the gateway has more network reach than the tool pod does, and following a redirect hands that reach to whatever the tool pod points at. It doesn't matter whether the tool pod meant it — the gateway's job is to not trust it either way.

Microsoft's fix in v1.0.1, from the release notes:

Tool calls no longer follow HTTP redirects returned by tool pods. Previously, the tool gateway and agent runs sent tool invocations with an HTTP client that followed redirects, so a tool pod could redirect the gateway to another host it can reach and have that host's response returned as the tool result. A redirect from a tool pod is now returned as a tool error, and the redirect target is never requested.

What this demo shows

Three tiny stdlib-only Python servers, no dependencies, no containers:

  • internal_service.py — stands in for the internal-only service: a secrets endpoint the gateway host can reach but nothing else should.
  • tool_pod.py — stands in for the tool: on /invoke it returns a 302 pointing at the internal service, instead of a real tool result.
  • gateway.py — the gateway itself, runnable in two modes:
    • vulnerable: the pre-1.0.1 shape of the bug — default redirect following, so the internal secret comes back as the tool result.
    • fixed: the v1.0.1 shape — redirects are detected and rejected as a tool error, and the target is never requested.

demo.sh starts all three, calls the vulnerable gateway and shows the leak, then calls the fixed gateway against the exact same tool pod and shows the error instead.

Quickstart

Requires only Python 3 (stdlib) and curl. No pip installs, no Docker, no Kubernetes — this bug lives in HTTP client defaults, not in cluster config, so the demo doesn't need a cluster either.

git clone https://github.com/themsquared/mcp-gateway-redirect-ssrf-demo.git
cd mcp-gateway-redirect-ssrf-demo
./demo.sh

Validated output, vulnerable mode:

{
  "mode": "vulnerable",
  "tool_result": "{\"secret\": \"admin-rotation-key-7f3a9c\", \"note\": \"internal-only: reachable from the gateway host, never from a tool call result\"}"
}

Validated output, fixed mode, same tool pod:

{
  "mode": "fixed",
  "tool_error": "tool response was a redirect; redirects are never followed",
  "status": 302,
  "location_seen_not_followed": "http://127.0.0.1:29001/secret"
}

If ports 29001–29004 collide with something already running on your machine, override them: INTERNAL_PORT=39001 TOOL_PORT=39002 GW1_PORT=39003 GW2_PORT=39004 ./demo.sh (see the top of demo.sh for the full list of override variables).

Why this matters beyond one project

This isn't a knock on microsoft/mcp-gateway specifically — they found it, fixed it fast, and published exactly how. The actual lesson is architectural: any MCP gateway that proxies tool calls with a general-purpose HTTP client needs to make an explicit decision about redirects, because "follow redirects" is usually the client library's default, not something anyone chose. The same question applies to agentgateway and to any other MCP/tool gateway: does the HTTP client used for outbound tool calls follow redirects, and if so, has anyone actually decided that's safe for a response that was never meant to be trusted in the first place?

Scope and what's unverified

  • This demo reproduces the class of bug described in the public release notes, using a minimal gateway built for this repo — it does not run Microsoft's actual mcp-gateway binary pre- and post-patch. Reproducing against the real binary would need its specific deployment shape (Azure template, container images); that's out of scope for a same-day demo.
  • Every command in this README was run against this repo's own code on 2026-11-18 and the output above is copied from that run.

License

Apache-2.0. See LICENSE.

GitHub topics: mcp, ssrf, ai-agents, security, agentgateway, kubernetes

About

No description or website provided.

Topics

agentgatewayai-agentskubernetesmcpsecurityssrf

Resources

Readme
Apache-2.0 license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.