Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

Mcp contextforge gateway: ContextForge: DNS TOCTOU race condition causes SSRF protection bypass (`/admin/gateways/test`) (CVE-2026-53708)

0
Medium
Published: 08/14/2026 (08/14/2026, 19:49:14 UTC)
Source: GCVE Database
Product: mcp-contextforge-gateway

Description

## Summary The `/admin/gateways/test` endpoint validates submitted URLs by resolving the hostname at validation time and blocking private address ranges. The HTTP client independently re-resolves DNS at connection time with no IP binding between the two operations, creating a TOCTOU window exploitable via DNS rebinding. The source code explicitly acknowledges this limitation in two separate locations. ## Details `validate_gateway_test_url()` in `mcpgateway/common/validators.py` (lines 1527–1710) calls `socket.getaddrinfo()` on the submitted hostname, checks whether the resolved IP falls in private, loopback, link-local, or cloud-metadata ranges (including `169.254.169.254`, `10.0.0.0/8`, `172.16.0.0/12`, and `192.168.0.0/16`), and accepts the URL if the result is clean. The validated URL is then passed to the HTTP client **as the original hostname string**, not as the validated IP address. The HTTP client (`httpx`, via `ResilientHttpClient`) performs its own independent DNS resolution at connection time. No mechanism bridges the two resolutions: - The validated IP address is never passed to the HTTP client. - Only the original hostname is forwarded, triggering a second independent lookup. - No TTL enforcement, mandatory DNS-cache reuse, or IP-level socket binding is implemented. The configuration options `ssrf_blocked_networks` (default: enabled, covers `169.254.169.254/32`, link-local ranges, etc.) and `ssrf_dns_fail_closed` (default: `True`) apply exclusively at **validation time**. They share the same TOCTOU gap because they operate on the validation-time resolution result, not on the connection-time resolution performed by the HTTP client. ### Two independent acknowledgements in the source code **Location 1** — `mcpgateway/common/validators.py`, lines 1537–1543 (function docstring of `validate_gateway_test_url`): > "DNS TOCTOU Limitation: This validation resolves DNS at validation time, but > the HTTP client will re-resolve DNS at connection time. An attacker controlling > DNS can return a public IP during validation and a private IP during connection > (DNS rebinding). True mitigation requires pinning the validated IP into the > connection (custom resolver/transport, or IP allowlist check at connect > callback). This is tracked as a known limitation for future improvement." **Location 2** — `mcpgateway/admin.py`, lines 14025–14029 (call site comment): > "TODO(ICACF-15): DNS rebinding risk — allowlist and SSRF checks resolve DNS, > but the actual ResilientHttpClient request resolves DNS a third time. An > attacker-controlled DNS server could return a public IP during validation and a > private IP during the actual request. Consider pinning the resolved IP for > outbound requests (custom transport) or caching DNS resolution across > validation and request phases." The existence of a named TODO ticket (ICACF-15) confirms the maintainers consider this an open, tracked defect. ### Prerequisites 1. `MCPGATEWAY_ADMIN_API_ENABLED=true` (not the default; must be explicitly enabled by an operator). 2. The attacker holds a credential with explicit `gateways.read` permission assigned via a database role. Regarding prerequisite 2: the endpoint is decorated with @require_permission("gateways.read", allow_admin_bypass=False). The allow_admin_bypass=False flag explicitly disables the platform-admin shortcut, meaning even a platform admin must hold an explicit database-backed role assignment that carries gateways.read. A credential produced solely via the platform-admin bootstrap bypass described in the companion advisory (GHSA-m8rv-5m6m-32ff) — a virtual identity with no database record — is rejected with HTTP 403 at this endpoint because no role lookup can succeed without a database row. An attacker who has forged a JWT via that bootstrap path does not automatically gain access to this endpoint; they still require a separately provisioned account with an appropriate role. ## Proof of Concept ### Setup ```bash cd /opt/mcp-cf-test MCPGATEWAY_ADMIN_API_ENABLED=true \ JWT_SECRET_KEY=my-test-key-but-now-longer-than-32-bytes \ uvicorn mcpgateway.main:app --host 0.0.0.0 --port 8000 & sleep 5 ``` ### Step 1 — Obtain a token for an account with database role assignment The exploit requires a credential for a user who exists in the database with a role carrying `gateways.read` (e.g., `platform_admin`, which holds the `*` wildcard). Register a user through the Admin UI or API and assign the `platform_admin` role, then generate a JWT: ```python import datetime, jwt, uuid SECRET = "my-test-key-but-now-longer-than-32-bytes" EMAIL = "[email protected]" # must have platform_admin role in DB now = datetime.datetime.now(datetime.timezone.utc) payload = { "sub": EMAIL, "aud": "mcpgateway-api", "iss": "mcpgateway", "jti": str(uuid.uuid4()), "iat": now, "exp": now + datetime.timedelta(hours=1), } print(jwt.encode(payload, SECRET, algorithm="HS256"), end="") ``` ```bash TOKEN=$

CVSS v3.1

Score 6.6medium

Attack Vector
Network
Attack Complexity
High
Privileges Required
High
User Interaction
None
Scope
Changed
Confidentiality
High
Integrity
Low
Availability
None
CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:L/A:N

Affected software

PyPIghsa
mcp-contextforge-gateway
Affected versions
<1.0.3

Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.

AI-Powered Analysis

Machine-generated threat intelligence

AILast updated: 08/15/2026, 05:42:32 UTC

Technical Analysis

The vulnerability arises because the /admin/gateways/test endpoint performs DNS resolution during URL validation to block private IP ranges, but the HTTP client (httpx via ResilientHttpClient) performs a separate DNS resolution at connection time without reusing or pinning the validated IP address. This TOCTOU gap enables DNS rebinding attacks where an attacker-controlled DNS server returns a public IP during validation and a private IP during the actual connection, bypassing SSRF protections. The source code explicitly documents this limitation and includes a TODO for mitigation via IP pinning or DNS caching. Exploitation requires the MCPGATEWAY_ADMIN_API_ENABLED flag to be true and an attacker to have a credential with the gateways.read permission assigned via a database role. The vulnerability is tracked as CVE-2026-53708 with a CVSS 3.1 score of 6.6 (medium severity).

Potential Impact

Successful exploitation allows an attacker with valid credentials and the gateways.read permission to bypass SSRF protections on the /admin/gateways/test endpoint by exploiting a DNS TOCTOU race condition. This could lead to unauthorized internal network access or data exposure via SSRF attacks. The vulnerability does not grant access by itself; the attacker must have appropriate permissions and the admin API must be enabled.

Mitigation Recommendations

A patch is available for this vulnerability; users should upgrade to version 1.0.3 or later. The maintainers acknowledge the issue and track it as an open defect (ICACF-15). Operators should ensure MCPGATEWAY_ADMIN_API_ENABLED is disabled if not needed to reduce exposure. Since the vulnerability requires explicit gateways.read permission, strict role assignment and credential management are recommended. Patch status is confirmed; apply the official fix to remediate.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

Technical Details

Gcve Source
db.gcve.eu
Osv Id
GHSA-9hgc-g3w5-67cm
Osv Schema Version
1.4.0
Aliases
["CVE-2026-53708"]
Ecosystems
["PyPI"]
Database Specific Severity
MODERATE
Cvss Version
3.1

Threat ID: 6a7ff5f6bf8831d53988006a

Added to database: 08/15/2026, 05:15:34 UTC

Last enriched: 08/15/2026, 05:42:32 UTC

Last updated: 08/16/2026, 00:53:54 UTC

Views: 6

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need more coverage?

Upgrade to Pro Console for AI refresh and higher limits.

For incident response and remediation, OffSeq services can help resolve threats faster.

Latest Threats

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses