Skip to content

fix(fetch): block private network URL fetches#4226

Open
kgarg2468 wants to merge 1 commit into
modelcontextprotocol:mainfrom
kgarg2468:kgarg/harden-fetch-ssrf
Open

fix(fetch): block private network URL fetches#4226
kgarg2468 wants to merge 1 commit into
modelcontextprotocol:mainfrom
kgarg2468:kgarg/harden-fetch-ssrf

Conversation

@kgarg2468
Copy link
Copy Markdown
Contributor

Summary

  • validate fetch URLs use http/https and resolve only to public IP addresses
  • block localhost, private, loopback, link-local, and metadata-service targets
  • follow redirects manually so redirected targets are validated before each request

Fixes #4143.

Tests

  • cd src/fetch && uv run pytest tests/test_server.py -q
  • cd src/fetch && uv run ruff check src/mcp_server_fetch/server.py tests/test_server.py
  • git diff --check

desledishant10 added a commit to desledishant10/mcp-scan that referenced this pull request Jun 2, 2026
PR modelcontextprotocol/servers#4226 by @kgarg2468 opened 2026-05-22,
explicitly listing 'Fixes #4143' in the body. Commit summary:

- Validate fetch URLs use http/https
- Resolve only to public IP addresses
- Block localhost, private, loopback, link-local, and metadata-service
  targets
- Follow redirects manually so redirected targets are validated before
  each request

The per-redirect validation step is more rigorous than the original
disclosure asked for — closes a 302-bypass that the basic scheme/host
check would have missed.

16/16 CI checks pass on the PR. Awaiting maintainer approval.

Updated:
- disclosures/2026-05-12-mcp-fetch-http-request-ssrf.md (status field
  + new Updates entry dated 2026-05-22)
- findings/2026-05-11-MCP-D-003-fetch-direct-environment-dependent-ssrf.md
  (outcome line: 'demonstrated' → 'demonstrated + fix PR in review')
- README.md findings table (fix PR link added)
- CHANGELOG.md Unreleased section (disclosure-status entry)

The community half (mcp-server-http-request) still has no maintainer
response. Day +14 ping is due 2026-05-26 (4 days from now).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: mcp-server-fetch lacks SSRF protection; cloud-hosted agent hosts can leak IAM credentials

1 participant