{"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":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote.rs","lineNumber":1886,"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":1868,"sourceCodeEnd":1904,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote.rs#L1868-L1904","documentation":"`elf_interpreter` reads EI_DATA (byte 5) of the ELF header to determine byte order; it accepts only 1 (little-endian) or 2 (big-endian). Any other value means the file's ELF header is malformed, so the parser cannot safely read multi-byte fields like program header offsets and bails out. This protects against parsing garbage or a deliberately mangled file.","triggerScenarios":"Calling the remote bootstrap path with a file that has ELF magic at bytes 0-3 but a corrupt/invalid EI_DATA byte at offset 5 — typically a corrupted download, a truncated or bit-flipped binary, or fuzzed/test data.","commonSituations":"Partial or interrupted downloads of the mise binary (curl interrupted, disk full); tools that wrote junk after the magic bytes; manually edited or patch-modified binaries.","solutions":["Re-download/reinstall the mise binary and retry — a valid build always has a valid EI_DATA byte","Verify integrity against the published checksum before use (`sha256sum` vs release manifest)","Check disk space and the download tool's exit status to rule out truncation/corruption"],"exampleFix":"// before\n# binary corrupted mid-download\ncurl -fLo mise https://github.com/jdx/mise/releases/latest/download/mise-linux-x64\n// after\n# re-download with checksum verification\ncurl -fLo mise <url> && echo '<expected-sha256>  mise' | sha256sum -c -","handlingStrategy":"validation","validationCode":"fn valid_elf_endianness(bytes: &[u8]) -> bool {\n    matches!(bytes.get(5), Some(1) | Some(2))\n}","typeGuard":"fn is_supported_elf_header(bytes: &[u8]) -> bool {\n    bytes.starts_with(b\"\\\\x7fELF\") && matches!(bytes.get(4), Some(1) | Some(2))\n        && matches!(bytes.get(5), Some(1) | Some(2))\n}","tryCatchPattern":"if !valid_elf_endianness(&bytes) {\n    // re-fetch the binary from the official source before retrying\n    redownload_mise_binary()?;\n}","preventionTips":["Verify checksums/signatures of downloaded binaries","Avoid writing to the mise binary in place; atomically replace installs","Watch for download tools exiting early (curl -f, pipefail)"],"tags":["remote","elf","corrupt-binary"],"backgroundTag":"checksum-mismatch","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"}