fetch: --allowed-hosts accepts wildcard IP entries (e.g. *.0.0.1) and matches any IPv4 ending with that suffix

オープン 初心者向け
#5,521 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend, security

調査の方向性

src/fetch/src/mcp_server_fetch/allowlist.pyから始め、issueが影響を受けるエントリーポイントとして挙げているnormalize_allowed_hostとhost_is_allowedを読んでください。許可されたホストの正規化と照合に関する既存のテストを確認し、ワイルドカード付きIPリテラル、数値サフィックス、IPアドレスのホストを対象とするテストを追加してください。これらの入力が拒否されるか、IPリテラルに決して一致せず、ホスト名のサブドメインに対するワイルドカードは引き続き機能すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Problem

mcp-server-fetch's --allowed-hosts allowlist (src/fetch/src/mcp_server_fetch/allowlist.py) documents two valid entry forms:

Two entry forms only, to keep the semantics obvious: an exact host (a name or an IP literal), and *.example.com, which matches any subdomain at any depth of example.com...

However, normalize_allowed_host only checks ipaddress.ip_address(...) when not wildcard (line 37). When a wildcard prefix *. is given before an IP literal or numeric IP suffix (such as *.10.0.0.1 or *.0.0.1), httpx.URL(f"http://{name}/") parses name without error and returns *.10.0.0.1 / *.0.0.1.

Then in host_is_allowed(host, allowed_hosts), host.endswith(entry[1:]) matches any IPv4 literal ending with .0.0.1 (for example, *.0.0.1 matches both 10.0.0.1 and 127.0.0.1).

from mcp_server_fetch.allowlist import host_is_allowed, normalize_allowed_hosts

entries = normalize_allowed_hosts(["*.0.0.1"])  # returns ('*.0.0.1',)
assert host_is_allowed("127.0.0.1", entries) is True
assert host_is_allowed("10.0.0.1", entries) is True

Expected

  • normalize_allowed_host rejects wildcard IP literals and numeric-TLD wildcard suffixes (*.10.0.0.1, *.0.0.1, *.[::1]) with ValueError.
  • host_is_allowed does not match *. subdomain wildcards against IP address literals.
主要言語
TypeScript
スター
91.9k
フォーク
11.9k
平均マージ
3時間 10分
マージ済み PR(30日)
178

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/servers のほかの issue

modelcontextprotocol/servers の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。