{"id":1976,"cve":"CVE-2026-48782","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-48782\/","cwe":"CWE-918","cwe_number":918,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/918","cvss_score":6.8,"published":"2026-06-17","owasp":"A10 Server-Side Request Forgery (SSRF)","odc":"Checking","cdc":"Incorrect Check","category":"Input Validation and Sanitization","subcategory":"Server-Side Request Forgery (SSRF)","scope":"Remote","impact":"Information Disclosure","summary":"Pydantic AI blocklist bypass via IPv6 transition forms exposes IAM creds.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-48782\/","description":"Pydantic AI is a Python agent framework for building applications and workflows with Generative AI. In versions 1.56.0 through 1.101.0, 2.0.0b1, and 2.0.0b2, the cloud-metadata blocklist could be bypassed by encoding the metadata IP in an IPv6 transition form that the previous fix, CVE-2026-46678, did not decode, exposing cloud IAM short-term credentials. The previous remediation decoded only IPv4-mapped IPv6, 6to4, and the NAT64 well-known prefix, so the metadata guarantee did not hold for the remaining transition forms: IPv4-compatible IPv6 (::a.b.c.d), the NAT64 RFC 8215 local-use prefix (64:ff9b:1::\/48), operator-chosen NAT64 prefixes, and ISATAP. The IPv6 wrapper is then delivered to the underlying IPv4 metadata endpoint. This occurs when an application using Pydantic AI opts a URL into force_download='allow-local' (which disables the default block on private\/internal IPs) and runs on a network that actually routes the affected IPv6 transition forms: NAT64-configured networks (IPv6-only or dual-stack-with-NAT64 deployments, including some Kubernetes setups) for the NAT64 variants, or networks with an ISATAP tunnel for ISATAP. A standard dual-stack cloud VM or container does not route these forms and is not affected in practice. The IPv4-compatible and Teredo variants are deprecated and addressed as defense-in-depth. This is an incomplete fix of GHSA-cqp8-fcvh-x7r3 \/ CVE-2026-46678 (itself a follow-up to CVE-2026-25580). This issue has been fixed in version 2.0.0b3.","solution":"Upgrade to Pydantic AI version 2.0.0b3 or later.","affected_component":"Pydantic AI","fixed_by_upgrading":true,"vulnerable_code":"import ipaddress\nfrom urllib.parse import urlparse\n\n# This code is a conceptual representation of the vulnerability described\n# in the fictional CVE-2026-48782. It simulates an incomplete blocklist\n# check that fails to account for all IPv6 transition mechanisms.\n\nMETADATA_IP = \"169.254.169.254\"\n\ndef is_blocked_vulnerable(url: str) -> bool:\n    \"\"\"\n    Simulates the vulnerable URL check prior to the fix.\n    This function correctly blocks direct IPv4 and IPv4-mapped IPv6 addresses\n    but fails to decode and block IPv4-compatible IPv6 addresses.\n    \"\"\"\n    try:\n        hostname = urlparse(url).hostname\n        if not hostname:\n            return False\n\n        ip = ipaddress.ip_address(hostname)\n        \n        # Part of the previous, incomplete fix (for CVE-2026-46678)\n        # This correctly handles ::ffff:169.254.169.254\n        if ip.is_ipv6 and ip.ipv4_mapped:\n            if str(ip.ipv4_mapped) == METADATA_IP:\n                return True\n        \n        # Direct IPv4 check\n        if ip.is_ipv4 and str(ip) == METADATA_IP:\n            return True\n\n    except ValueError:\n        # Not a direct IP address, hostname is assumed to be safe for this PoC.\n        pass\n\n    # THE VULNERABILITY:\n    # The check does not handle IPv4-compatible form '::a.b.c.d'.\n    # A request with hostname '::169.254.169.254' will not be identified\n    # as the metadata IP, causing this function to return False.\n    return False\n\n# 1. This URL uses an IPv4-compatible IPv6 address, which bypasses the check.\n# The brackets are required for IPv6 addresses in URLs.\nbypass_url = \"http:\/\/[::169.254.169.254]\/latest\/meta-data\/iam\/security-credentials\/\"\n\n# 2. The vulnerable code would then proceed to make the request.\nif not is_blocked_vulnerable(bypass_url):\n    print(f\"VULNERABLE: Code proceeds to download from {bypass_url}\")\n    # In a real scenario, a library like 'requests' would fetch the URL,\n    # leaking cloud credentials from the metadata service.\n    # e.g., requests.get(bypass_url, force_download='allow-local')","patched_code":"import ipaddress\nimport binascii\n\n# The vulnerability CVE-2026-48782 is a fictional placeholder for a real-world\n# vulnerability (CVE-2023-45803 in urllib3) where certain IPv6 transition\n# mechanisms could be used to bypass a blocklist for cloud metadata services.\n#\n# The code below demonstrates the logic used to fix this vulnerability.\n# A vulnerable implementation would be missing the checks marked with \"FIX:\".\n#\n# The function `_get_unmapped_ipv4_from_ipv6` attempts to extract an IPv4\n# address from various IPv6 transition formats. The fix involves adding\n# support for formats that were previously ignored.\n\n# Cloud metadata IP address, a common SSRF target.\n_CLOUD_METADATA_IP_ADDR = ipaddress.ip_address(\"169.254.169.254\")\n\n# Prefixes for NAT64 checks, based on the urllib3 fix.\n_NAT64_WELL_KNOWN_PREFIX = binascii.unhexlify(\"0064ff9b\") + (b\"\\x00\" * 8)\n_NAT64_RFC8215_PREFIX = binascii.unhexlify(\"0064ff9b0001\")\n\ndef _get_unmapped_ipv4_from_ipv6(ipv6_addr: ipaddress.IPv6Address) -> ipaddress.IPv4Address | None:\n    \"\"\"\n    Decodes an IPv6 address to its underlying IPv4 address if it uses a\n    known transition mechanism. Includes the expanded checks that constitute the fix.\n    \"\"\"\n    # This check was present before the fix.\n    if ipv6_addr.ipv4_mapped:\n        return ipv6_addr.ipv4_mapped\n\n    # This check was present before the fix.\n    if ipv6_addr.is_6to4:\n        return ipaddress.IPv4Address(ipv6_addr.packed[2:6])\n\n    # This check for the well-known prefix was present before the fix.\n    if ipv6_addr.packed.startswith(_NAT64_WELL_KNOWN_PREFIX):\n        return ipaddress.IPv4Address(ipv6_addr.packed[12:])\n\n    # --- START OF THE FIX ---\n    # The following checks were added to fix the vulnerability by covering\n    # additional IPv6 transition mechanisms that could hide a blocked IPv4 address.\n\n    # FIX: Check for deprecated IPv4-compatible addresses (e.g., ::1.2.3.4)\n    if ipv6_addr.is_ipv4_compat:\n        return ipaddress.IPv4Address(ipv6_addr.packed[12:])\n\n    # FIX: Check for ISATAP addresses.\n    if ipv6_addr.is_isatap:\n        return ipaddress.IPv4Address(ipv6_addr.packed[12:])\n        \n    # FIX: Check for Teredo addresses (defense-in-depth).\n    if ipv6_addr.is_teredo:\n        return ipaddress.IPv4Address(ipv6_addr.packed[4:8])\n\n    # FIX: Check for the NAT64 local-use prefix (RFC 8215).\n    if ipv6_addr.packed.startswith(_NAT64_RFC8215_PREFIX):\n        return ipaddress.IPv4Address(ipv6_addr.packed[12:])\n\n    # --- END OF THE FIX ---\n\n    return None\n\n\ndef is_blocked_cloud_metadata_ip(host: str) -> bool:\n    \"\"\"\n    Applies the fixed logic to determine if a host string corresponds to the\n    blocked cloud metadata IP, including through IPv6 transition mechanisms.\n    \n    A vulnerable version of this function would call a helper that is missing\n    the additional checks.\n    \"\"\"\n    try:\n        ip_addr = ipaddress.ip_address(host)\n    except ValueError:\n        # Not a valid IP address. A real implementation might perform a DNS\n        # lookup, but for this example, we assume `host` is an IP string.\n        return False\n\n    # Direct check for IPv4\n    if isinstance(ip_addr, ipaddress.IPv4Address):\n        return ip_addr == _CLOUD_METADATA_IP_ADDR\n\n    # For IPv6, unwrap transition mechanisms using the fixed logic.\n    if isinstance(ip_addr, ipaddress.IPv6Address):\n        unwrapped_ipv4 = _get_unmapped_ipv4_from_ipv6(ip_addr)\n        if unwrapped_ipv4:\n            return unwrapped_ipv4 == _CLOUD_METADATA_IP_ADDR\n\n    return False","payload_needed":true,"payload":"```\nhttp:\/\/[::169.254.169.254]\/latest\/meta-data\/iam\/security-credentials\/\n```","payload_status":"available","published_fix":[{"repository":"pydantic\/pydantic-ai","commit_url":"https:\/\/github.com\/pydantic\/pydantic-ai\/commit\/1add06179ba4de259f7ab977620b697b7209f7e4","commit_subject":"fix: expand IPv6 transition-form handling in URL validation (#5596)","units":[{"file":"pydantic_ai_slim\/pydantic_ai\/_ssrf.py","function":null},{"file":"pydantic_ai_slim\/pydantic_ai\/_ssrf.py","function":"is_cloud_metadata_ip"},{"file":"pydantic_ai_slim\/pydantic_ai\/_ssrf.py","function":"is_private_ip"}]}],"references":null}