{"record":{"id":"d845cbda48c23bbf","repo":"gitbutlerapp/gitbutler","slug":"no-host-in-url","errorCode":null,"errorMessage":"No host in {} URL","messagePattern":"No host in (.+?) URL","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-installer/src/release.rs","lineNumber":112,"sourceCode":"/// Common URL validation logic for GitButler domains.\n///\n/// Validates HTTPS protocol, parses URL, and checks the host against a predicate.\nfn validate_gitbutler_url(\n    url: &str,\n    url_type: &str,\n    is_host_valid: impl Fn(&str) -> bool,\n) -> Result<()> {\n    // Only allow HTTPS URLs\n    if !url.starts_with(\"https://\") {\n        bail!(\"{url_type} must use HTTPS: {url}\");\n    }\n\n    // Extract host from URL\n    let url_parsed =\n        url::Url::parse(url).with_context(|| format!(\"Invalid {} URL\", url_type.to_lowercase()))?;\n    let host = url_parsed\n        .host_str()\n        .ok_or_else(|| anyhow!(\"No host in {} URL\", url_type.to_lowercase()))?;\n\n    // Validate host using the provided predicate\n    if !is_host_valid(host) {\n        bail!(\"{url_type} is not from a trusted GitButler domain: {url}\");\n    }\n\n    Ok(())\n}\n\n/// Validates that an API URL is from the trusted API domain.\n///\n/// API endpoints should only be served from app.gitbutler.com to prevent\n/// redirecting API requests to other subdomains.\npub(crate) fn validate_api_url(url: &str) -> Result<()> {\n    validate_gitbutler_url(url, \"API URL\", |host| host == \"app.gitbutler.com\")\n}\n\n/// Validates that a download URL is from a trusted GitButler domain.","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-installer/src/release.rs#L94-L130","documentation":"validate_gitbutler_url parses a URL and extracts its host to check it against a trusted-domain predicate. If the parsed URL has no host (e.g. a scheme like file:// or a malformed URL), it throws \"No host in {} URL\" where {} is the url_type (e.g. \"API URL\"). This is part of the SSRF/redirect protection for release and download URLs.","triggerScenarios":"validate_api_url or validate_download_url called with a URL string that parses but has no host component (e.g. \"file:///etc/passwd\", \"unix:/path\", or a relative string that happens to parse).","commonSituations":"A malicious or misconfigured redirect target, a corrupted release-metadata URL, or overriding the API/download URL with a non-HTTP scheme in a custom config.","solutions":["Ensure any custom release API or download URL is a fully qualified http(s) URL with a host","Remove custom URL overrides so the defaults (api.gitbutler.com / GitHub releases) are used","If triggered by a redirect, the installer rejected it by design — do not bypass; report the redirect source"],"exampleFix":"// before\nlet api_url = \"file:///mirror/release-api\";\n// after\nlet api_url = \"https://api.example-mirror.dev/releases\";","handlingStrategy":"validation","validationCode":"// validate URL shape before use\nlet parsed = url::Url::parse(candidate)?;\nif parsed.host_str().is_none() {\n    return Err(format!(\"URL must be absolute http(s) with a host: {candidate}\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only configure absolute https:// URLs for custom release/download endpoints","Never point the installer at file:// or other non-network schemes","Treat this error on redirects as a security signal and investigate the source"],"tags":["security","url-validation","ssrf-protection"],"backgroundTag":"invalid-url-format","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}