jdx/mise · error

invalid blob digest (expected 64 lowercase hex chars)

Error message

invalid blob digest (expected 64 lowercase hex chars): {digest}

What it means

mise validates blob digests must be `sha256:` followed by exactly 64 lowercase hex characters before using them as paths. When the prefix is present but the remainder is the wrong length or contains non-lowercase-hex characters (uppercase, non-hex, whitespace), this error is thrown. Like the prefix check, it prevents path traversal and blob-store corruption.

Solutions

  1. Regenerate the digest with `sha256sum <file>` and use the full 64-character lowercase output
  2. Normalize the digest to lowercase and trim whitespace before passing it
  3. Check the manifest/registry source for a malformed digest field

Example fix

// before
let digest = format!("sha256:{}", hex.to_uppercase());
// after
let digest = format!("sha256:{}", hex.to_lowercase());
Defensive patterns

Strategy: validation

Validate before calling

fn is_valid_sha256_hex(d: &str) -> bool {
    matches!(d.strip_prefix("sha256:"), Some(h) if h.len() == 64 && h.bytes().all(|b| b.is_ascii_hexdigit() && !b.is_ascii_uppercase()))
}

Type guard

fn is_wellformed_digest(d: &str) -> bool {
    let Some(hex) = d.strip_prefix("sha256:") else { return false };
    hex.len() == 64 && hex.chars().all(|c| c.is_ascii_digit() || ('a'..='f').contains(&c))
}

Try / catch

if let Err(e) = layout.read_blob(digest) {
    if e.to_string().contains("64 lowercase hex") {
        eprintln!("malformed digest {digest:?}; regenerate with sha256sum");
    }
}

Prevention

When it happens

Trigger: Calling `write_blob_with_digest` or `read_blob` with e.g. a 63/65-char hash, uppercase hex, a truncated or padded digest, or a digest containing injection characters.

Common situations: Manually copy-pasting a digest that got truncated; string transformations uppercasing hex; concatenating digests with stray characters; tooling emitting sha256 digests of different lengths.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at src/oci/layout.rs:147

        let bytes = serde_json::to_vec(manifest)?;
        self.write_blob(&bytes)
    }
}

/// Validate that `digest` is a well-formed `sha256:<64 lowercase hex>` string.
/// Guards against path traversal from a malicious registry returning something
/// like `sha256:../../etc/passwd` as a layer digest — without this check, that
/// would be used directly as a filesystem path component.
pub(crate) fn validate_sha256_digest(digest: &str) -> Result<()> {
    let Some(hex) = digest.strip_prefix("sha256:") else {
        eyre::bail!("invalid blob digest (expected sha256: prefix): {digest}");
    };
    if hex.len() != 64
        || !hex
            .chars()
            .all(|c| c.is_ascii_digit() || ('a'..='f').contains(&c))
    {
        eyre::bail!("invalid blob digest (expected 64 lowercase hex chars): {digest}");
    }
    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn rejects_path_traversal() {
        assert!(validate_sha256_digest("sha256:../../etc/passwd").is_err());
        assert!(validate_sha256_digest("sha256:../foo").is_err());
        assert!(validate_sha256_digest("../bad").is_err());
        assert!(validate_sha256_digest("sha256:DEADBEEF").is_err());
    }

    #[test]
    fn accepts_valid_digest() {

View on GitHub (pinned to 533346cc37)