Executive brief
The `/admin/gateways/test` endpoint in ContextForge validates gateway URLs by checking the hostname's IP address against a block list (including cloud metadata services). However, the validation and the actual HTTP connection use independent DNS resolutions with no synchronization, allowing an attacker to use DNS rebinding to redirect validated connections to blocked internal addresses. This requires the Admin API to be explicitly enabled and the attacker to hold an authenticated credential with `gateways.read` permission.
Technical details
The vulnerability is a time-of-check-time-of-use (TOCTOU) race condition in DNS resolution. The `validate_gateway_test_url()` function in `mcpgateway/common/validators.py` (lines 1527–1710) resolves a hostname and validates the resulting IP against a block list covering private addresses (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), link-local ranges, and cloud metadata addresses (169.254.169.254). However, only the original hostname string is passed to the HTTP client (`httpx` via `ResilientHttpClient`), which performs an independent DNS resolution at connection time. No mechanism pins the validated IP to the connection. An attacker controlling DNS can exploit this by returning a public IP during validation (which passes the check) and then changing the DNS record to a blocked private IP before the HTTP client connects, achieving DNS rebinding. The vulnerability requires `MCPGATEWAY_ADMIN_API_ENABLED=true` and a valid authentication token with explicit `gateways.read` database-role assignment. The maintainers have documented this limitation in two source-code locations and track it under TODO ICACF-15.
Affected products
- IBM mcp-contextforge-gateway < 1.0.3
Timeline
- 2026-06-15: disclosed
- 2026-08-14: advisory