{"record":{"id":"e8758a9bddf2af13","repo":"jdx/mise","slug":"unsupported-elf-class","errorCode":null,"errorMessage":"unsupported ELF class","messagePattern":"unsupported ELF class","errorType":"exception","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/system/remote.rs","lineNumber":1381,"sourceCode":"        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    };\n    let program_offset = usize::try_from(program_offset)?;\n    let entry_size = usize::try_from(entry_size)?;\n    let entry_count = usize::try_from(entry_count)?;\n    for index in 0..entry_count {\n        let start = program_offset\n            .checked_add(\n                index\n                    .checked_mul(entry_size)\n                    .ok_or_else(|| eyre!(\"invalid ELF program headers\"))?,\n            )\n            .ok_or_else(|| eyre!(\"invalid ELF program headers\"))?;\n        if read_elf_int(bytes, start, 4, little_endian)? != PT_INTERP {\n            continue;\n        }\n        let offset = usize::try_from(read_elf_int(\n            bytes,\n            start + offset_field,","sourceCodeStart":1363,"sourceCodeEnd":1399,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/remote.rs#L1363-L1399","documentation":"Thrown by elf_interpreter when the ELF EI_CLASS byte (byte 4) is neither 1 (ELF32) nor 2 (ELF64). The parser only understands 32- and 64-bit ELF program headers; any other class value means the header is corrupt or the file is not a conventional Linux executable, and parsing cannot continue safely.","triggerScenarios":"A truncated or corrupted mise_bin whose class byte is garbage; a crafted/fuzzed binary fed into Linux-to-Linux upload validation.","commonSituations":"Damaged artifacts from partial copies; test/fuzz corpora accidentally pointed at by mise_bin; files with prepended data (some packers) that shift the header.","solutions":["Re-obtain the binary from a trusted source and validate the header (readelf -h mise should show Class: ELF64)","Strip anything prepended to the file or re-extract the archive properly","Use remote_mise/bootstrap_command to sidestep local-binary validation"],"exampleFix":"# before: binary with damaged header\nreadelf -h ./mise  # Class: <invalid>\n\n# after: reinstall\n./install-mise.sh   # or: cargo build --release\nreadelf -h ./target/release/mise  # Class: ELF64","handlingStrategy":"validation","validationCode":"// Same magic/class guard as 895 covers this arm\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)   // ELF32/ELF64 only\n        && matches!(magic[5], 1 | 2)\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 class\") => {\n        eyre::bail!(\"mise binary at {} is not a valid ELF32/ELF64 image; rebuild it\", path.display());\n    }\n    other => other?,\n}","preventionTips":["Do not feed packed/prepended binaries into mise_bin; extract the raw ELF first","Add readelf/file checks to artifact pipelines so corrupt builds never ship","Fuzz-corpus or test binaries should not be reused as deploy artifacts"],"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"}