Skip to content

fix: block private URLs in MCP tools#242

Open
RitwijParmar wants to merge 1 commit into
firecrawl:mainfrom
RitwijParmar:codex/firecrawl-mcp-url-guard
Open

fix: block private URLs in MCP tools#242
RitwijParmar wants to merge 1 commit into
firecrawl:mainfrom
RitwijParmar:codex/firecrawl-mcp-url-guard

Conversation

@RitwijParmar

Copy link
Copy Markdown

Summary

  • add a URL guard that rejects localhost, private IPv4 ranges, link-local metadata IPs, loopback/link-local/unique-local IPv6, and IPv4-mapped private IPv6 targets by default
  • apply the guard before forwarding scrape, map, crawl, and extract requests to Firecrawl
  • allow trusted self-hosted/private-network deployments to opt in with FIRECRAWL_ALLOW_PRIVATE_NETWORKS=true

Why

This addresses the SSRF/local-network risk raised in #210 and #194. Shape validation with z.string().url() still allows targets like localhost, 127.0.0.1, 169.254.169.254, and private LAN ranges, so an MCP client can accidentally or maliciously route a tool call toward local infrastructure.

Verification

  • npm run build
  • node --test tests/urlGuard.test.mjs
  • git diff --check

Note: I also tried the repo lint command, but a fresh install does not currently include the ESLint/@typescript-eslint dev dependencies required by .eslintrc.json, so lint could not be run locally without changing dependency metadata.

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.

1 participant