Repository navigation
fix(fetch): GHSA-g7v6-hfx3-8rv6 - robots.txt check misses backslash and path-parameter spellings (incomplete fix for GHSA-3rxj-6jhw-qfv7) - #5678
Conversation
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>
|
|
| Tools | Prompts | Resources | Resource templates | |
|---|---|---|---|---|
| Base | 1 | 1 | 0 | 0 |
| Head | 1 | 1 | 0 | 0 |
Updated by this run for e6131710e7d4d7cc3944035e57fcb6b57e4023d2.
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:gatepassed 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-fetchmatched a path as spelled and as an nginx/Apache-style origin resolves it (%2F/%2Edecoded, 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\..\privatepassedDisallow: /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%5Cas/, 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_urlrefuses 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
mcp-server-fetch, Python)src/mcp_server_fetch/server.py(_BACKSLASH,_resolved_path_url's two new keywords, thecan_fetchcheck incheck_may_autonomously_fetch_url);tests/test_protocol.py(new cases in the resolved-path, redirect and allowed-path parametrisations, plustest_robots_disallow_still_matches_the_dot_resolved_spellingandtest_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/mainand 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-ipsagainst a local origin that servesrobots.txtUser-agent: * / Disallow: /private, and answers each other path withCANARY-PRIVATEwhen it resolves to/privateunder IIS-style (backslash) or servlet-style (;params) semantics. The call wastools/call fetch url=http://127.0.0.1:18765<path> raw=true:v2/main(before)/public%5C..%5CprivateisError=false, bodyCANARY-PRIVATEisError=true, "The sites robots.txt … specifies that autonomous fetching of this page is not allowed"/public%5C..%5CprivateisError=falseisError=true, same refusal/public/..;/privateisError=false, bodyCANARY-PRIVATEisError=true, same refusal/public/..;/privateisError=falseisError=true, same refusal/public/page(control)isError=falseisError=false(still fetched)Gate:
npm run local:gateexited 0 on this head. Per-file coverage forserver.pyis 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/privateunder 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
Checklist
npm run changeset) if this changes what a TypeScript server publishes (not applicable: Python server)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
%3Bfor;, 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%uescapes 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