lfnovo/open-notebook · critical · ValueError

Hostname '{hostname}' resolves to the AWS IMDSv6 metadata ad

Error message

Hostname '{hostname}' resolves to the AWS IMDSv6 metadata address (fd00:ec2::254), which is not allowed for security reasons.

What it means

A hostname in the config resolved to fd00:ec2::254, AWS's IPv6 IMDS endpoint. This is a Unique Local Address (not link-local), so it needs an explicit check; discovering it via DNS triggers this hostname-specific message. It exists to close the SSRF path where an attacker routes a friendly name to the IPv6 metadata service.

Source

Thrown at open_notebook/utils/url_validation.py:245

                f"Hostname '{hostname}' resolves to a link-local address (169.254.x.x) "
                "which is not allowed for security reasons. These addresses are used "
                "for cloud metadata endpoints."
            )
        raise ValueError(
            "Link-local addresses (169.254.x.x) are not allowed for security reasons. "
            "These addresses are used for cloud metadata endpoints."
        )

    # Block AWS's IMDSv6 metadata address - a Unique Local Address, not
    # link-local, so it needs its own explicit check. Compare without scope
    # ID so scoped forms (fd00:ec2::254%eth0) cannot bypass the sentinel.
    is_aws_imds_v6 = (
        isinstance(ip, ipaddress.IPv6Address)
        and int(ip) == int(_AWS_IMDS_V6_ADDRESS)
    )
    if is_aws_imds_v6:
        if resolved:
            raise ValueError(
                f"Hostname '{hostname}' resolves to the AWS IMDSv6 metadata address "
                "(fd00:ec2::254), which is not allowed for security reasons."
            )
        raise ValueError(
            "The AWS IMDSv6 metadata address (fd00:ec2::254) is not allowed for "
            "security reasons."
        )

View on GitHub (pinned to a7de90d38a)

Solutions

  1. Remove the offending hostname from the config; requests to the AWS IPv6 metadata endpoint are blocked by design
  2. Audit how that DNS record got created if it wasn't intentional
  3. For legitimate AWS API access use the public service hostnames
Defensive patterns

Strategy: validation

Validate before calling

import ipaddress, socket
from urllib.parse import urlparse

AWS_IMDS_V6 = ipaddress.IPv6Address("fd00:ec2::254")

def resolves_to_imds_v6(url: str) -> bool:
    host = urlparse(url).hostname or ""
    try:
        if ipaddress.ip_address(host) == AWS_IMDS_V6:
            return True
    except ValueError:
        pass
    try:
        return any(ipaddress.ip_address(ai[4][0]) == AWS_IMDS_V6 for ai in socket.getaddrinfo(host, None))
    except socket.gaierror:
        return False

Try / catch

try:
    target = await prepare_pinned_http_target(url, provider)
except ValueError as e:
    if "IMDSv6" in str(e):
        log_security_event(url)
    raise

Prevention

When it happens

Trigger: Provider base_url set to a hostname whose AAAA record is fd00:ec2::254, then running discover_with_config or any connection-test helper that pins the outbound target.

Common situations: DNS rebinding / SSRF test payloads pointing at AWS IMDSv6; attacker-controlled endpoint in a multi-tenant setup; accidental wildcard DNS record.

Related errors


AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27). Data as JSON: /api/errors/9503240f268f4f77. Report an issue: GitHub.