{"record":{"id":"e8758a9bddf2af13","repo":"jdx/mise","slug":"unsupported-elf-class","errorCode":null,"errorMessage":"unsupported ELF class","messagePattern":"unsupported ELF class","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote.rs","lineNumber":1903,"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":1885,"sourceCodeEnd":1921,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote.rs#L1885-L1921","documentation":"`elf_interpreter` reads EI_CLASS (byte 4): 1 = ELF32, 2 = ELF64; anything else is an invalid ELF class and parsing stops. This prevents reading program header tables with the wrong field layout/offsets, which would produce nonsense or out-of-bounds reads.","triggerScenarios":"A file passing the magic check but whose byte 4 is not 1 or 2 — corrupted binary, fuzzed input, or a fabricated file that begins with \\\"\\\\u{7f}ELF\\\" but is not a real ELF image.","commonSituations":"Corrupted mise binary on disk (bad download, filesystem corruption); a file mislabeled as the mise executable; adversarial or test fixture inputs.","solutions":["Reinstall mise so the binary is a genuine ELF32/ELF64 executable (`file $(which mise)` should say 'ELF 32-bit' or 'ELF 64-bit')","Verify the binary's checksum against the release manifest","Ensure the mise on PATH is the actual compiled binary, not a stub or placeholder"],"exampleFix":"// before\n$ xxd -l 8 mise\n00000000: 7f45 4c46 09 01 ...   # class byte 0x09 -> invalid\n// after\n# restore a valid binary\nmise self-update   # or reinstall from release tarball\n$ xxd -l 8 mise\n00000000: 7f45 4c46 02 01 ...   # class 2 = ELF64","handlingStrategy":"validation","validationCode":"fn valid_elf_class(bytes: &[u8]) -> bool {\n    matches!(bytes.get(4), Some(1) | Some(2))\n}","typeGuard":"fn is_plausible_elf(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":"match elf_interpreter(&bytes) {\n    Err(e) if e.to_string().contains(\"unsupported ELF class\") => {\n        reinstall_mise()?; // binary on disk is corrupt\n    }\n    other => other?,\n}","preventionTips":["Reinstall mise rather than hand-editing binaries","Use official release tarballs and verify digests","Check filesystem health if binaries repeatedly corrupt"],"tags":["remote","elf","corrupt-binary"],"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"}