jdx/mise · error

refusing to send credentials over an HTTPS-to-HTTP URL…

Error message

refusing to send credentials over an HTTPS-to-HTTP URL replacement

What it means

This is a security guard in src/http.rs (around line 2030): when a URL is replaced or rewritten (e.g. a mirror/proxy redirect), mise refuses to carry credentials from an original HTTPS URL into a replacement that uses plain HTTP. Sending a username/password or token over an unencrypted http:// connection would expose the credentials to anyone on the path, so the downgrade is blocked.

Solutions

  1. Change the replacement/mirror URL to https:// so the scheme is not downgraded.
  2. If the mirror really is HTTP-only, remove the credentials from the URL and rely on a network-isolated mirror without auth.
  3. Review the URL rewrite configuration (mirror/replacement entries) for accidental scheme changes (https→http).
  4. Move credentials out of URLs entirely (e.g. use host-scoped auth headers/env config) so no credential can leak into a replacement.

Example fix

# before (mirror config)
https://registry.example.com = http://mirror.internal/registry
# after
https://registry.example.com = https://mirror.internal/registry
Defensive patterns

Strategy: validation

Validate before calling

fn is_safe_replacement(original: &str, replacement: &str) -> bool {
  !(original.starts_with("https://") && replacement.starts_with("http://")
    && (replacement.contains('@') || replacement.contains("://") && replacement.split("//").nth(1).map_or(false, |h| h.contains('@'))))
}

Try / catch

match result {
  Err(e) if e.to_string().contains("HTTPS-to-HTTP") => {
    eprintln!("mirror URL must be https:// when credentials are present");
  }
  other => other?,
}

Prevention

When it happens

Trigger: A URL-replacement rule (URL rewrite/mirror configuration) maps an https:// endpoint to an http:// endpoint while the target URL (after replacement) contains credentials — either carried over from the original or embedded in the replacement (non-empty username or a password).

Common situations: Configuring a corporate mirror for a registry using http:// instead of https:// while the original URL had an embedded token; a self-hosted proxy served over HTTP; a typo'd mirror entry that downgrades the scheme; URL templates that insert auth tokens into http:// URLs.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/992be2326d25dad0. Report an issue: GitHub.

Appendix: source

Thrown at src/http.rs:2030

pub(crate) fn ensure_secure_replacement_credentials(
    original_url: &Url,
    url: &Url,
    headers: &HeaderMap,
) -> Result<()> {
    let has_credentials = headers
        .iter()
        .any(|(name, value)| is_credential_header(name, value));
    ensure_secure_url_replacement(original_url, url, has_credentials)
}

pub(crate) fn ensure_secure_url_replacement(
    original_url: &Url,
    url: &Url,
    has_credentials: bool,
) -> Result<()> {
    let downgraded = original_url.scheme() == "https" && url.scheme() == "http";
    let has_credentials = has_credentials || !url.username().is_empty() || url.password().is_some();
    ensure!(
        !downgraded || !has_credentials,
        "refusing to send credentials over an HTTPS-to-HTTP URL replacement"
    );
    Ok(())
}

/// Get HTTP Basic authentication headers from netrc file for the given URL
pub(crate) fn netrc_headers(url: &Url) -> HeaderMap {
    let mut headers = HeaderMap::new();
    if let Some(host) = url.host_str()
        && let Some((login, password)) = netrc::get_credentials(host)
    {
        let credentials = BASE64_STANDARD.encode(format!("{login}:{password}"));
        if let Ok(value) = HeaderValue::from_str(&format!("Basic {credentials}")) {
            headers.insert(reqwest::header::AUTHORIZATION, value);
        }
    }
    headers

View on GitHub (pinned to 533346cc37)