{"record":{"id":"b051b6f876d373f7","repo":"jdx/mise","slug":"unsupported-elf-byte-order","errorCode":null,"errorMessage":"unsupported ELF byte order","messagePattern":"unsupported ELF byte order","errorType":"exception","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/system/remote.rs","lineNumber":1364,"sourceCode":"        if bytes.get(offset) != Some(&b'.') {\n            break;\n        }\n        offset += 1;\n    }\n    (!components.is_empty()).then_some(AbiVersion(components))\n}\n\nfn elf_interpreter(bytes: &[u8]) -> Result<Option<String>> {\n    const ELF_MAGIC: &[u8] = b\"\\x7fELF\";\n    const PT_INTERP: u64 = 3;\n    if !bytes.starts_with(ELF_MAGIC) {\n        bail!(\"local mise is not an ELF executable\");\n    }\n    let class = *bytes.get(4).ok_or_else(|| eyre!(\"truncated ELF header\"))?;\n    let little_endian = match bytes.get(5) {\n        Some(1) => true,\n        Some(2) => false,\n        _ => bail!(\"unsupported ELF byte order\"),\n    };\n    let (program_offset, entry_size, entry_count, offset_field, size_field) = match class {\n        1 => (\n            read_elf_int(bytes, 28, 4, little_endian)?,\n            read_elf_int(bytes, 42, 2, little_endian)?,\n            read_elf_int(bytes, 44, 2, little_endian)?,\n            4,\n            16,\n        ),\n        2 => (\n            read_elf_int(bytes, 32, 8, little_endian)?,\n            read_elf_int(bytes, 54, 2, little_endian)?,\n            read_elf_int(bytes, 56, 2, little_endian)?,\n            8,\n            32,\n        ),\n        _ => bail!(\"unsupported ELF class\"),\n    };","sourceCodeStart":1346,"sourceCodeEnd":1382,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/remote.rs#L1346-L1382","documentation":"Thrown by elf_interpreter when the ELF EI_DATA byte (byte 5) is neither 1 (little-endian) nor 2 (big-endian). Real Linux executables are always one of these, so a different value indicates a corrupted, truncated, or deliberately malformed ELF header rather than any platform mismatch.","triggerScenarios":"The mise_bin file's header is damaged (bit rot, interrupted copy, tool that rewrote the header) while validating Linux-to-Linux upload compatibility.","commonSituations":"Interrupted downloads; files mangled by transfer modes (e.g. ASCII-mode FTP); fuzzed or hand-crafted binaries reaching the validation path.","solutions":["Restore the binary from a trusted source and re-run (verify with: file mise && readelf -h mise | grep -i 'data encoding')","If it is a build artifact, rebuild it and check the toolchain output","Fall back to bootstrap_command/remote_mise so the local binary is not parsed at all"],"exampleFix":"# verify and replace a corrupted binary\nfile ./mise           # before: data encoding: corrupt/unexpected\n\ncurl -fsSL https://mise.run | sh  # reinstall official binary\nfile ~/.local/bin/mise # after: ELF 64-bit LSB executable","handlingStrategy":"validation","validationCode":"// Reject corrupt ELF headers before upload validation\nfn elf_header_sane(path: &Path) -> bool {\n    let mut magic = [0u8; 6];\n    let Ok(mut f) = std::fs::File::open(path) else { return false };\n    std::io::Read::read_exact(&mut f, &mut magic).is_ok()\n        && &magic[..4] == b\"\\x7fELF\"\n        && matches!(magic[4], 1 | 2)   // class\n        && matches!(magic[5], 1 | 2)   // data encoding\n}","typeGuard":"fn elf_header_sane(path: &Path) -> bool {\n    let mut magic = [0u8; 6];\n    let Ok(mut f) = std::fs::File::open(path) else { return false };\n    std::io::Read::read_exact(&mut f, &mut magic).is_ok()\n        && &magic[..4] == b\"\\x7fELF\"\n        && matches!(magic[4], 1 | 2)\n        && matches!(magic[5], 1 | 2)\n}","tryCatchPattern":"match elf_interpreter(&bytes) {\n    Err(e) if e.to_string().contains(\"unsupported ELF byte order\") => {\n        // header corruption: restore from trusted source instead of parsing further\n        eyre::bail!(\"mise binary at {} has a corrupt ELF header; re-download or rebuild\", path.display());\n    }\n    other => other?,\n}","preventionTips":["Transfer binaries in binary mode; verify sha256 after copy","Run 'readelf -h <binary>' as a smoke test in deploy scripts","Treat any header-level parse failure as corruption, not as a compatibility signal"],"tags":["mise","elf","corruption","binary-format","validation"],"backgroundTag":"invalid-executable-format","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}