tinyhumansai/openhuman · error

URL port is out of range

Error message

URL port is out of range

What it means

While parsing the URL authority, extract_port rejects port components containing non-ASCII-digit characters (e.g. ':8080x' or a trailing colon) or values that fail u16 parsing — a malformed-URL guard inside the SSRF validator, hit before any DNS check or request.

Source

Thrown at src/openhuman/tools/impl/network/url_guard.rs:280

        .or_else(|| url.strip_prefix("https://"))
        .ok_or_else(|| anyhow::anyhow!("Only http:// and https:// URLs are allowed"))?;

    let authority = rest
        .split(['/', '?', '#'])
        .next()
        .ok_or_else(|| anyhow::anyhow!("Invalid URL"))?;

    if authority.starts_with('[') {
        anyhow::bail!("IPv6 hosts are not supported in http_request");
    }

    if let Some((_, port)) = authority.rsplit_once(':') {
        if port.is_empty() || !port.chars().all(|ch| ch.is_ascii_digit()) {
            anyhow::bail!("URL port must be numeric");
        }
        return port
            .parse::<u16>()
            .map_err(|_| anyhow::anyhow!("URL port is out of range"));
    }

    Ok(if is_http { 80 } else { 443 })
}

pub(super) fn host_matches_allowlist(host: &str, allowed_domains: &[String]) -> bool {
    allowed_domains.iter().any(|domain| {
        // `"*"` is the explicit allow-all wildcard (the "Allow all sites"
        // toggle), mirroring the browser tool. Local/private hosts are still
        // rejected upstream by `is_private_or_local_host`, so a wildcard only
        // opens *public* hosts, never the loopback/RFC1918 SSRF surface.
        domain == "*"
            || host == domain
            || host
                .strip_suffix(domain)
                .is_some_and(|prefix| prefix.ends_with('.'))
    })
}

View on GitHub (pinned to 7491200858)

Solutions

  1. Remove or fix the port so it is a bare numeric value in 0-65535
  2. Omit the port to use the scheme default
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/openhuman/tools/impl/network/url_guard.rs:280 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/4b97d43ad901582f. Report an issue: GitHub.