Skip to content

fix(fetch): GHSA-g7v6-hfx3-8rv6 - robots.txt check misses backslash and path-parameter spellings (incomplete fix for GHSA-3rxj-6jhw-qfv7) - #5678

Merged
cliffhall merged 2 commits into
v2/mainfrom
v2/fix/ghsa-g7v6-hfx3-8rv6
Nov 27, 2026
Merged

cliffhall merged 2 commits into
v2/mainfrom
v2/fix/ghsa-g7v6-hfx3-8rv6

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #5670

Fix for GHSA-g7v6-hfx3-8rv6. It was written and reviewed in the advisory's private fork, where a subagent reviewer stood in for Copilot (which cannot review a private fork) until a clean round. Per the advisory flow this PR gets no Copilot review. The private fork has no Actions, so this PR's CI is the first CI run on the change; the full npm run local:gate passed on this exact head and on a rollup of all eight advisory fixes.

Fix for GHSA-g7v6-hfx3-8rv6 (private fork; no public issue is linked until the card converts).

Description

The robots.txt check in mcp-server-fetch matched a path as spelled and as an nginx/Apache-style origin resolves it (%2F/%2E decoded, repeated slashes merged, dot segments removed). It did not take into account origins that read a backslash (literal or %5C) as a separator (IIS, Windows-backed servers) or that drop ; path parameters from each segment before resolving (Java servlet containers). So /public%5C..%5Cprivate, /public/..;/private, and a redirect to /public\..\private passed Disallow: /private, while such an origin serves /private. This follows on from GHSA-3rxj-6jhw-qfv7, whose fix left these spellings out.

The fix adds two more spellings to the check instead of widening the existing one: _resolved_path_url(url, backslash_separator=True) also reads \ and %5C as /, and _resolved_path_url(url, drop_parameters=True) strips ;… from each segment, each before the slashes are merged and the dot segments removed. They are separate because an origin may do only one of the two (review round 1). check_may_autonomously_fetch_url refuses when any of the four spellings is disallowed, so the change only ever adds refusals. A rule that names a parameter (Disallow: /a;b) still matches through the existing dot-resolved spelling (pinned by a test).

Server Details

  • Server: fetch (mcp-server-fetch, Python)
  • Changed: src/mcp_server_fetch/server.py (_BACKSLASH, _resolved_path_url's two new keywords, the can_fetch check in check_may_autonomously_fetch_url); tests/test_protocol.py (new cases in the resolved-path, redirect and allowed-path parametrisations, plus test_robots_disallow_still_matches_the_dot_resolved_spelling and test_robots_disallow_matches_each_resolution_on_its_own); README.md ("Customization - robots.txt", the list of normalisations).

Motivation and Context

GHSA-g7v6-hfx3-8rv6 (severity low). SECURITY.md names robots.txt as an enforced boundary for the autonomous (tool) fetch.

How Has This Been Tested?

Regression tests (protocol level, in-memory MCP client): 8 new refusal cases fail on origin/v2/main and pass on this branch: tool-argument /public%5c..%5cprivate, /public%5C..%5Cprivate, /public/..;/private, /public;x/..;y/private, /;x/private; and redirects to /public\..\private, /public%5c..%5cprivate, /public/..;/private. New allowed cases (/public%5cprivate, /public;private) and the parameter-named rule case pass on both. A literal backslash in a tool argument is already turned into / by pydantic's URL parsing (WHATWG), so the redirect path is where the literal-backslash spelling reaches the check.

Inspector CLI (@modelcontextprotocol/inspector@2.12.0 --cli), both eras. The server ran with --allow-private-ips against a local origin that serves robots.txt User-agent: * / Disallow: /private, and answers each other path with CANARY-PRIVATE when it resolves to /private under IIS-style (backslash) or servlet-style (;params) semantics. The call was tools/call fetch url=http://127.0.0.1:18765<path> raw=true:

Path Era v2/main (before) this branch (after)
/public%5C..%5Cprivate legacy (2025-11-25) exit 0, isError=false, body CANARY-PRIVATE exit 5, isError=true, "The sites robots.txt … specifies that autonomous fetching of this page is not allowed"
/public%5C..%5Cprivate modern (2026-07-28) exit 0, isError=false exit 5, isError=true, same refusal
/public/..;/private legacy exit 0, isError=false, body CANARY-PRIVATE exit 5, isError=true, same refusal
/public/..;/private modern exit 0, isError=false exit 5, isError=true, same refusal
/public/page (control) both exit 0, isError=false exit 0, isError=false (still fetched)

Gate: npm run local:gate exited 0 on this head. Per-file coverage for server.py is 99.0% lines and 96.6% branches (head e613171). The Inspector runs above were made on the first head (b92a8df). The round-1 change only splits the combined spelling into two, and both table paths still resolve to /private under one of them.

LLM client: not run. From this session there is no LLM client that could be pointed at the private-IP lab origin with the branch build. The Inspector runs above drive the same tool in both eras.

Breaking Changes

None. No configuration changes. Fetches whose path resolves to a disallowed path under backslash or ;-parameter semantics are now refused. That is intended, and it applies only to the autonomous tool fetch with robots.txt checking on.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follow MCP security best practices
  • I have updated the server's README accordingly
  • I have added a changeset (npm run changeset) if this changes what a TypeScript server publishes (not applicable: Python server)
  • I have tested this with an LLM client (not done: see above; Inspector CLI evidence in both eras instead)
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling (not applicable beyond the existing refusal: no new error path)
  • I have documented all environment variables and configuration options (not applicable: none added)

Additional context

What this leaves open: origins with other path semantics are still not modelled. That covers full percent-decoding of other characters (for example %3B for ;, or overlong/double encodings), case-insensitive path matching on case-insensitive file systems (RFC 9309 says matching is case-sensitive, and this PR keeps it so), and IIS-specific spellings such as %u escapes or 8.3 short names. Each would be one more spelling in the same tuple if it is ever wanted. The user-invoked fetch prompt still skips robots.txt by design.

🤖 Generated with Claude Code

cliffhall and others added 2 commits November 27, 2026 00:26
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall cliffhall added the v2 label Nov 27, 2026
@changeset-bot

changeset-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e613171

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

fetch: MCP interface diff

Base: 90e6a48c8c90 (Merge pull request #5652 from modelcontextprotocol/v2/feat/5651-everything-events)
Head: the build in this checkout, at 83fa66800295 (Merge e613171 into 90e6a48)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 1 1 0 0
Head 1 1 0 0

Updated by this run for e6131710e7d4d7cc3944035e57fcb6b57e4023d2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GHSA-g7v6-hfx3-8rv6] - mcp-server-fetch: robots.txt check misses backslash and path-parameter spellings (incomplete fix for GHSA-3rxj-6jhw-qfv7)

1 participant