fix(co-gahusb): DNS-rebinding 보호 비활성화 (public Host 421 해결)

- FastMCP가 기본 host(127.0.0.1)에서 DNS rebinding 보호를 자동 활성화 →
  allowed_hosts=localhost만 허용 → nginx가 넘기는 Host gahusb.synology.me가 421.
- 실 보안은 nginx 앞단 Bearer 인증(MCP 도달 전 401)이므로 Host 검증 비활성화.
- 재현/회귀 테스트 추가 + config.CO_BUS_KEY import-순서 격리 버그 수정 (23 통과).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-12 10:20:04 +09:00
parent ea5cf49cea
commit 756d9fccf3
2 changed files with 36 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ import logging
import redis.asyncio as aioredis
from mcp.server.fastmcp import FastMCP
from mcp.server.transport_security import TransportSecuritySettings
from starlette.applications import Starlette
from starlette.middleware import Middleware
from starlette.middleware.base import BaseHTTPMiddleware
@@ -16,7 +17,12 @@ _auth_failed_logged = False
_redis = aioredis.from_url(config.REDIS_URL, decode_responses=True)
mcp = FastMCP("co-gahusb")
# DNS-rebinding 보호 비활성화: 실 보안은 nginx 앞단 Bearer 인증(MCP 도달 전 401)이다.
# 원격 HTTPS + 정적키 모델이라 Host 화이트리스트는 보안가치 ~0이고, 도메인 변경 시 또 깨진다.
mcp = FastMCP(
"co-gahusb",
transport_security=TransportSecuritySettings(enable_dns_rebinding_protection=False),
)
# ---- 메시지 ----