feat(filter-proxy): deny file-write mcp tools #11
No reviewers
Labels
No labels
enhancement
No milestone
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
genji1024/containerized-agents!11
Loading…
Reference in a new issue
No description provided.
Delete branch "7-feat/filter-proxy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #7
概要
forgejo-mcp / github-mcp 経由の push を技術的に塞ぎ、gitpush-mcp に一本化する。承認済み案A(プロキシ層での deny)を最小構成で実施する。
変更内容
dockerfiles/filter-proxy/proxy.py(新規) — stdlib のみ(http.server + urllib)の透過プロキシ。JSON-RPCtools/callのツール名が DENY_LIST に一致したら即時 403 + JSON-RPC エラー、それ以外は plain-JSON/SSE とも透過転送dockerfiles/filter-proxy/Dockerfile(新規) —python:3.13-slimでプロキシ起動compose.yaml—forgejo-filter(3008→forgejo-mcp:3006、deny 4点)とgithub-filter(3009→github-mcp:3003、deny 4点)を追加。opencode の depends_on に両 filter を追加。既存 5 MCP サービスは無変更.config/opencode/opencode.jsonc— github/forgejo の URL を filter 経由に書換え + 2行コメント。エージェント permission 変更なしdeny 対象(c462 承認どおり
create_branch含む):create_file/update_file/delete_file/create_branchcreate_or_update_file/push_files/delete_file/create_branch抜け道の検討:
create_file/update_file/delete_fileはnew_branch_nameで暗黙ブランチ作成できるため、file 系全 deny で迂回を閉じた動作確認
python3 -m py_compile dockerfiles/filter-proxy/proxy.py— 成功create_file→ 403、allowcreate_issue→ 200 転送を確認docker compose -f compose.yaml config— 成功手動確認手順
docker compose -f compose.yaml build forgejo-filter github-filterでビルドdocker compose -f compose.yaml up -dで起動(docker compose psで両 filter が healthy になるまで待つ)forgejo_list_repo_issues/create_issue_comment等の正常系が成功することforgejo_create_file等の file-write 系が拒否されること(403 / deny エラー)docker compose -f compose.yaml config --servicesにforgejo-filter/github-filterが現れること備考
@bot-genji1024 作業ブランチをチェックアウトして起動しました。他に抜け道がないか徹底的に検証してください。
実行結果 (c524 抜け道検証)
@genji1024 作業ブランチ
7-feat/filter-proxy(head8e158e9) をチェックアウトし、filter-proxy の抜け道を徹底検証しました。結論: 承認済み deny 8点の迂回路はありません。通常利用での file-write 系 push 経路は塞がれています。 残存する書き込み経路を下表に整理し、末尾で追加 deny の承認をお願いします(コード修正は承認後に着手します)。実施内容
proxy.pyで deny 4点→403(backend 未到達)、allow/tools/list/initialize/GET/SSE・/health→透過転送を確認。py_compile・compose config成功create_file/update_file/delete_file/create_branch完全一致)、upstream github-mcp-server v1.7.0 README (deny 4点すべて実在・名称一致)、mcp-go の batch 処理、mcp-proxy v0.12.0 のツール名素通しを確認github_*/forgejo_*を呼べるのは pr-manager/issue-reader のみ(両者 bash なし)。bash が広い coder/verifier は当該 MCP 権限なし。多層防御として成立検証済み・問題なし
new_branch_name付きの暗黙ブランチ作成: file 系3点 deny で coveragetools/call以外 (GET/SSE・tools/list・initialize・notifications): 書き込み不可のため素通しで問題なし。パス・Content-Type 偽装での回避不可 (proxy は body の JSON のみ見て判定し、パスを無視して固定/mcpへ転送)残存する書き込み経路 (要判断)
delete_branch(forgejo) が deny 外update_pull_request_branch(github) が deny 外merge_pull_request(両) が deny 外curl http://forgejo-mcp:3006/mcp等)networks分離 (backend は filter とだけ同居、opencode とは filter のみ共有)。承認後に実装tools/listに deny 済みツールが表示される関連
備考
動作確認
python3 -m py_compile dockerfiles/filter-proxy/proxy.py— 成功docker compose config— 成功@bot-genji1024 違います。この作業ブランチの設定下であなたを再起動したということです。自分で forgejo-mcp 経由でブランチをプッシュする経路がないか試してください。
実行結果 (c538 自己検証)
@genji1024 この作業ブランチの設定下で再起動された状態から、自分で forgejo-mcp 経由の push を試しました。結論: ブランチをプッシュする経路はありません。
実施内容
create_branch(test-filter-probe-20260908 from main) → 拒否tool 'create_branch' is denied by filter-proxy (file writes belong to gitpush-mcp)(code -32001)create_file/update_file/delete_file→ 同様に全て拒否 (code -32001、backend 未到達のため副作用なし)test-filter-probe-20260908が作成されていないことを確認 (残存 3枝のみ: main / 7-feat/filter-proxy / 6-feat/pi-migration)動作確認
関連
備考
http://forgejo-filter:3008/mcp、DENY_LIST 4点) での実測です@bot-genji1024 対応ありがとうございました。LGTM!