{"record":{"id":"f5a611ae96208be0","repo":"jdx/mise","slug":"invalid-blob-digest-expected-64-lowercase-hex-cha","errorCode":null,"errorMessage":"invalid blob digest (expected 64 lowercase hex chars): {digest}","messagePattern":"invalid blob digest \\(expected 64 lowercase hex chars\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/oci/layout.rs","lineNumber":147,"sourceCode":"        let bytes = serde_json::to_vec(manifest)?;\n        self.write_blob(&bytes)\n    }\n}\n\n/// Validate that `digest` is a well-formed `sha256:<64 lowercase hex>` string.\n/// Guards against path traversal from a malicious registry returning something\n/// like `sha256:../../etc/passwd` as a layer digest — without this check, that\n/// would be used directly as a filesystem path component.\npub(crate) fn validate_sha256_digest(digest: &str) -> Result<()> {\n    let Some(hex) = digest.strip_prefix(\"sha256:\") else {\n        eyre::bail!(\"invalid blob digest (expected sha256: prefix): {digest}\");\n    };\n    if hex.len() != 64\n        || !hex\n            .chars()\n            .all(|c| c.is_ascii_digit() || ('a'..='f').contains(&c))\n    {\n        eyre::bail!(\"invalid blob digest (expected 64 lowercase hex chars): {digest}\");\n    }\n    Ok(())\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn rejects_path_traversal() {\n        assert!(validate_sha256_digest(\"sha256:../../etc/passwd\").is_err());\n        assert!(validate_sha256_digest(\"sha256:../foo\").is_err());\n        assert!(validate_sha256_digest(\"../bad\").is_err());\n        assert!(validate_sha256_digest(\"sha256:DEADBEEF\").is_err());\n    }\n\n    #[test]\n    fn accepts_valid_digest() {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/oci/layout.rs#L129-L165","documentation":"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.","triggerScenarios":"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.","commonSituations":"Manually copy-pasting a digest that got truncated; string transformations uppercasing hex; concatenating digests with stray characters; tooling emitting sha256 digests of different lengths.","solutions":["Regenerate the digest with `sha256sum <file>` and use the full 64-character lowercase output","Normalize the digest to lowercase and trim whitespace before passing it","Check the manifest/registry source for a malformed digest field"],"exampleFix":"// before\nlet digest = format!(\"sha256:{}\", hex.to_uppercase());\n// after\nlet digest = format!(\"sha256:{}\", hex.to_lowercase());","handlingStrategy":"validation","validationCode":"fn is_valid_sha256_hex(d: &str) -> bool {\n    matches!(d.strip_prefix(\"sha256:\"), Some(h) if h.len() == 64 && h.bytes().all(|b| b.is_ascii_hexdigit() && !b.is_ascii_uppercase()))\n}","typeGuard":"fn is_wellformed_digest(d: &str) -> bool {\n    let Some(hex) = d.strip_prefix(\"sha256:\") else { return false };\n    hex.len() == 64 && hex.chars().all(|c| c.is_ascii_digit() || ('a'..='f').contains(&c))\n}","tryCatchPattern":"if let Err(e) = layout.read_blob(digest) {\n    if e.to_string().contains(\"64 lowercase hex\") {\n        eprintln!(\"malformed digest {digest:?}; regenerate with sha256sum\");\n    }\n}","preventionTips":["Copy digests verbatim from manifest JSON rather than retyping","Avoid case-transforming or trimming beyond whitespace on digests","Validate digest length at ingestion boundaries","Store digests in typed wrappers (newtype Digest) validated at construction"],"tags":["oci","digest","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}