---
title: "Flyto2 Core SSRF Guard TOCTOU and DNS Rebinding Bypasses"
slug: "flyto2-core-ssrf-guard-toc-tou-dns-rebinding-cve-2026-77316-cve-2026-7"
description: "Defensive teardown of Flyto2 Core SSRF guard TOCTOU and DNS rebinding bypasses in versions <= 2.26.7, with IP pinning controls and verification steps."
author: "Hamdi Soudani"
category: "ai-security-jailbreaks"
archetype: "advisory-teardown"
published_at: "2026-11-23T06:04:38.63+00:00"
updated_at: "2026-11-23T06:04:39.254679+00:00"
canonical_url: "https://pyvren.com/blog/flyto2-core-ssrf-guard-toc-tou-dns-rebinding-cve-2026-77316-cve-2026-7"
reading_time_minutes: 6
word_count: 1119
quality_score: 88
tags: ["flyto2-core","ssrf","dns-rebinding","toctou","ai-security"]
keywords: ["flyto2 core ssrf guard","dns rebinding toctou","flyto-core cve-2026-77316","ssrf ip pinning python","aiohttp dns rebinding defense"]
sources: ["https://github.com/advisories/GHSA-6pm8-6f34-9v3g","https://github.com/advisories/GHSA-pfg2-w999-497v","https://github.com/flytohub/flyto-core/releases/tag/v2.26.8"]
---

# Flyto2 Core SSRF Guard TOCTOU and DNS Rebinding Bypasses

> **TL;DR:** Flyto2 Core versions <= 2.26.7 resolve URLs then discard the IP, letting aiohttp re-resolve at connect time and bypass SSRF guards via DNS rebinding; upgrade to 2.26.8 or pin resolved addresses.

## Key Facts

- **Affected versions:** flyto-core <= 2.26.7 ([source](https://github.com/advisories/GHSA-6pm8-6f34-9v3g))
- **Patched version:** flyto-core 2.26.8 ([source](https://github.com/advisories/GHSA-6pm8-6f34-9v3g))
- **CVE-2026-77316 CVSS:** 6.8 Medium, AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:L/A:N ([source](https://github.com/advisories/GHSA-6pm8-6f34-9v3g))
- **CVE-2026-77313 CVSS:** 7.1 High ([source](https://github.com/advisories/GHSA-pfg2-w999-497v))
- **Vulnerable component:** src/core/utils.py::validate_url_ssrf ([source](https://github.com/advisories/GHSA-6pm8-6f34-9v3g))
- **Root cause class:** CWE-918 SSRF / CWE-367 TOCTOU ([source](https://github.com/advisories/GHSA-6pm8-6f34-9v3g))

Flyto2 Core versions 2.26.7 and earlier contain two related SSRF guard bypasses, tracked as CVE-2026-77316 and CVE-2026-77313. Both defects live in `src/core/utils.py::validate_url_ssrf` and share the same root cause: the guard resolves a hostname, validates the resolved IP against private ranges, then discards the IP and returns the hostname URL string. The caller hands that hostname to aiohttp, which performs an independent second DNS resolution at connect time. An attacker who controls DNS for a hostname with a zero or low TTL can return a public address during the guard's lookup and a private, loopback, or cloud metadata address during the connection's lookup. This is a classic check-then-use time-of-check-to-time-of-use (TOCTOU) condition.

## Threat Model & Attack Surface Matrix

| Attack surface | Blast radius | Concrete control |
|---|---|---|
| `guarded_aiohttp_request()` | Internal network fetch, cloud metadata credential theft at 169.254.169.254 | Upgrade to flyto-core 2.26.8; pin resolved IP for connection |
| `enforce_outbound_url()` / `validate_url_with_env_config()` | Reads internal services reachable from the application host | Shared resolver; egress proxy allowlist |
| `http.get/request/batch` | Exfiltration of internal HTTP bodies | Block private and link-local IP ranges at egress |
| `graphql.query/mutation` | Internal GraphQL introspection and data reads | Destination allowlist per module |
| `monitor.http_check`, `notification.{slack,discord,teams}` | Internal service discovery and notification abuse | Network segmentation and DNS pinning |
| `ai.vision_analyze`, `verify.visual_diff`, `browser.proxy_rotate` | Internal asset enumeration and screenshot capture | Outbound TLS inspection and allowlist |

The CVSS v3.1 vector for CVE-2026-77316 is `AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:L/A:N`, scored 6.8 Medium. The high attack complexity reflects the requirement for attacker-controlled DNS with a low TTL and a successful flip between the guard's resolution and the connection's resolution. The scope change flag indicates the vulnerability reaches internal or metadata services outside the application's intended trust boundary. CVE-2026-77313 is scored 7.1 High and describes the same check-then-use defect with the additional observation that `SECURITY_SSRF.md` line 63 claims DNS rebinding is prevented when it is not.

## Why Naive Prompt Filters Fail

This advisory concerns an SSRF guard in an application library, not an LLM prompt filter, but the failure pattern is directly relevant to AI red teams shipping tool-calling agents. A prompt filter that inspects user-supplied URLs before passing them to `execute_module` or `http.get` sees only the hostname string. It cannot observe the independent DNS resolution performed by aiohttp at connect time. If the agent tool accepts attacker-controlled URLs or hostnames, the filter's allow decision is based on stale resolution data. Multi-turn guardrail drift does not fix this because the vulnerability is in the network client, not the conversation state. Any agent that forwards URLs to Flyto2 Core HTTP modules inherits this SSRF path unless the resolved address is pinned or outbound egress is independently controlled.

Prior hardening in the SSRF-guard family, referenced as GHSA-pgwh-4jj4-qm8v, GHSA-c9hr-64h3-gxpc, and GHSA-794r-5rp2-fpg8, added per-module coverage, redirect revalidation, and IPv6 transition range checks. None of those fixes pinned the resolved address, so the resolve-then-connect gap defeats all of them. Redirect revalidation specifically does not help because the initial hop already rebinds before any redirect occurs.

## Defense-in-Depth & Sandbox Isolation Architecture

The patch in flyto-core 2.26.8 resolves the hostname once and pins the resulting address for the connection, eliminating the independent second lookup. Until you can upgrade, apply the following controls in order.

First, upgrade the dependency. Run `pip install flyto-core==2.26.8` and verify the installed version with `pip show flyto-core`. This is the only complete fix because it changes the guard to retain and use the validated IP.

Second, if you must run an unpatched version, wrap outbound HTTP calls in a validation layer that resolves the hostname once, checks the IP against private, loopback, link-local, and cloud metadata ranges, then opens a TCP connection directly to that pinned IP address. Do not pass the hostname back to aiohttp for resolution.

Third, enforce egress controls at the network edge. Block outbound traffic to 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8, 169.254.0.0/16, and IPv6 unique local and link-local ranges. Allow only required public destinations. This limits blast radius even if the application-layer guard is bypassed.

Fourth, isolate the agent execution environment. Run Flyto2 Core modules in a sandbox with no route to internal services or instance metadata. Use separate egress namespaces for untrusted URL inputs. Do not rely on the application guard as the sole boundary.

## Runnable Guardrail Policy / Verification Code

The following Python snippet demonstrates the defensive pattern: resolve once, validate every returned address against a comprehensive deny list, and refuse to connect if resolution is non-deterministic. This is a detection and hardening reference, not an exploit.

```python
import socket
import ipaddress
from typing import List, Tuple

PRIVATE_RANGES = [
    ipaddress.ip_network("0.0.0.0/8"),
    ipaddress.ip_network("10.0.0.0/8"),
    ipaddress.ip_network("100.64.0.0/10"),
    ipaddress.ip_network("127.0.0.0/8"),
    ipaddress.ip_network("169.254.0.0/16"),
    ipaddress.ip_network("172.16.0.0/12"),
    ipaddress.ip_network("192.0.0.0/24"),
    ipaddress.ip_network("192.0.2.0/24"),
    ipaddress.ip_network("192.168.0.0/16"),
    ipaddress.ip_network("198.18.0.0/15"),
    ipaddress.ip_network("224.0.0.0/4"),
    ipaddress.ip_network("240.0.0.0/4"),
    ipaddress.ip_network("255.255.255.255/32"),
    ipaddress.ip_network("::/128"),
    ipaddress.ip_network("::1/128"),
    ipaddress.ip_network("fc00::/7"),
    ipaddress.ip_network("fe80::/10"),
]

def is_private_ip(addr: ipaddress.IPv4Address | ipaddress.IPv6Address) -> bool:
    return any(addr in net for net in PRIVATE_RANGES)

def resolve_and_validate(hostname: str) -> List[ipaddress.IPv4Address | ipaddress.IPv6Address]:
    infos = socket.getaddrinfo(hostname, None)
    addrs: List[ipaddress.IPv4Address | ipaddress.IPv6Address] = []
    for family, _, _, _, sockaddr in infos:
        ip = ipaddress.ip_address(sockaddr[0])
        if ip.version == 6 and ip.ipv4_mapped:
            ip = ip.ipv4_mapped
        addrs.append(ip)
    return addrs

def validate_url_ssrf_defensive(hostname: str) -> Tuple[bool, str]:
    first = resolve_and_validate(hostname)
    second = resolve_and_validate(hostname)
    if first != second:
        return False, "non-deterministic DNS resolution detected; possible rebinding"
    for ip in first:
        if is_private_ip(ip):
            return False, f"resolved IP {ip} is private or link-local"
    return True, f"validated {len(first)} address(es)"
```

Run this check against every outbound URL before the application module uses it. If the two resolutions differ, reject the URL immediately. A difference indicates a TTL-zero or rapidly flipping DNS record, which is the rebinding condition described in CVE-2026-77316.

Verify the patch with the following commands:

```bash
pip show flyto-core | grep Version
pip install flyto-core==2.26.8
pip show flyto-core | grep Version
grep -n "validate_url_ssrf" src/core/utils.py
```

Confirm that the patched function returns or consumes a pinned IP address rather than the raw hostname string. A grep for `TCPConnector`, `AsyncResolver`, or custom resolver configuration in `http/` should confirm whether your deployment pins connections or relies on aiohttp's independent resolver.

## Operational Tradeoffs & False-Positive Budget

Pinning resolved IPs introduces operational complexity. If a hostname legitimately resolves to multiple addresses for load balancing or failover, pinning the first address may reduce availability. Use the full address list and rotate through validated addresses rather than selecting a single address arbitrarily. Non-deterministic DNS detection can produce false positives behind CDNs or global server load balancing that return different addresses for legitimate reasons. Tune the rejection threshold so that only rapid flips between public and private space trigger a block.

Egress allowlists reduce false positives in the application layer but increase operational overhead when adding new third-party APIs. Start with a monitor-only mode that logs private-space resolution attempts without blocking, then move to block mode after a baseline period. The false-positive budget should be near zero for private and link-local ranges because legitimate outbound traffic to those addresses from a Flyto2 Core module is rare.

Latency overhead from the defensive resolver wrapper is one additional `getaddrinfo` call per URL. Treat this as an illustrative target rather than a measured benchmark; actual overhead depends on resolver cache state, network region, and sample size. Cache the validation result by hostname and TTL to avoid placing this check in high-frequency inner loops.

When not to use this approach: do not rely on DNS rebinding detection alone if the application must resolve hostnames that change addresses frequently for legitimate reasons. In those cases, network segmentation and egress proxy controls are more reliable than application-layer IP pinning.

This advisory is based on the GitHub Advisory Database entries for GHSA-6pm8-6f34-9v3g and GHSA-pfg2-w999-497v, the Flyto2 Core release notes for v2.26.8, and the CWE definitions for CWE-918 and CWE-367. No weaponized payloads or bypass recipes are included.

[Flyto2 Core SSRF guard bypass via DNS rebinding GHSA-6pm8-6f34-9v3g](https://github.com/advisories/GHSA-6pm8-6f34-9v3g)

[Flyto2 Core SSRF guard validates resolved IP but connects by hostname GHSA-pfg2-w999-497v](https://github.com/advisories/GHSA-pfg2-w999-497v)

[Flyto2 Core v2.26.8 release](https://github.com/flytohub/flyto-core/releases/tag/v2.26.8)

## Frequently Asked Questions

### What is the root cause of CVE-2026-77316 and CVE-2026-77313?

validate_url_ssrf resolves the hostname with socket.getaddrinfo, checks the IP against private ranges, then returns the hostname URL string while discarding the resolved IP. aiohttp performs an independent second DNS resolution at connect time, allowing an attacker-controlled DNS to return a public address during validation and a private or metadata address during connection.

### Which Flyto2 Core versions are affected?

All versions of flyto-core up to and including 2.26.7 are affected. Version 2.26.8 contains the patch.

### Does redirect revalidation fix this bypass?

No. Redirect revalidation added in prior SSRF-guard hardening does not help because the initial hop already rebinds before any redirect occurs. The guard's resolved IP is never pinned for the connection.

### What is the recommended defensive control?

Upgrade to flyto-core 2.26.8. If immediate upgrade is impossible, pin the validated IP address for the connection, enforce a shared resolver across validation and connect, block private and link-local ranges at the egress proxy, and allowlist outbound destinations.

## Primary Sources

- https://github.com/advisories/GHSA-6pm8-6f34-9v3g
- https://github.com/advisories/GHSA-pfg2-w999-497v
- https://github.com/flytohub/flyto-core/releases/tag/v2.26.8
