{"record":{"id":"e93b4f0ffd5316e4","repo":"jdx/mise","slug":"unsafe-elf-interpreter-path-interpreter","errorCode":null,"errorMessage":"unsafe ELF interpreter path: {interpreter:?}","messagePattern":"unsafe ELF interpreter path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote.rs","lineNumber":1943,"sourceCode":"        let size = usize::try_from(read_elf_int(\n            bytes,\n            start + size_field,\n            if class == 1 { 4 } else { 8 },\n            little_endian,\n        )?)?;\n        let value = bytes\n            .get(\n                offset\n                    ..offset\n                        .checked_add(size)\n                        .ok_or_else(|| eyre!(\"invalid ELF interpreter\"))?,\n            )\n            .ok_or_else(|| eyre!(\"truncated ELF interpreter\"))?;\n        let value = value.strip_suffix(&[0]).unwrap_or(value);\n        let interpreter = String::from_utf8(value.to_vec())?;\n        if !interpreter.starts_with('/') || interpreter.contains('\\0') || interpreter.contains('\\n')\n        {\n            bail!(\"unsafe ELF interpreter path: {interpreter:?}\");\n        }\n        return Ok(Some(interpreter));\n    }\n    Ok(None)\n}\n\nfn read_elf_int(bytes: &[u8], offset: usize, size: usize, little_endian: bool) -> Result<u64> {\n    let value = bytes\n        .get(\n            offset\n                ..offset\n                    .checked_add(size)\n                    .ok_or_else(|| eyre!(\"invalid ELF field\"))?,\n        )\n        .ok_or_else(|| eyre!(\"truncated ELF field\"))?;\n    let mut padded = [0_u8; 8];\n    if little_endian {\n        padded[..size].copy_from_slice(value);","sourceCodeStart":1925,"sourceCodeEnd":1961,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote.rs#L1925-L1961","documentation":"After extracting the PT_INTERP program header string, `elf_interpreter` sanity-checks the interpreter path: it must be absolute, and must not contain NUL or newline characters. A path failing these checks could break shell quoting or be abused for path injection when re-executing the binary remotely, so mise refuses it.","triggerScenarios":"The ELF interpreter string in the local mise binary is not a normal absolute path: it lacks a leading '/', or embeds NUL/newline bytes — a tampered or hand-crafted binary, or corrupted program header contents.","commonSituations":"Running a patched/repacked mise binary; binary corruption after the header (bad sectors, partial write); security-tooling test fixtures.","solutions":["Run an unmodified official mise build — replace any locally patched binary","Verify the binary's checksum/signature against the release","Inspect the interpreter with `readelf -l $(which mise) | grep interpreter` to confirm it looks like `/lib64/ld-linux-...`"],"exampleFix":"// before\n# patched binary has interpreter \"ld-linux.so\" (relative)\nreadelf -l mise  # [Requesting program interpreter: ld-linux.so]\n// after\n# use official build with absolute interpreter\nreadelf -l mise  # [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]","handlingStrategy":"validation","validationCode":"fn safe_interpreter(interp: &str) -> bool {\n    interp.starts_with('/') && !interp.contains('\\\\0') && !interp.contains('\\\\n')\n}","typeGuard":"fn is_absolute_safe_path(p: &str) -> bool {\n    p.starts_with('/') && p.chars().all(|c| c != '\\\\0' && c != '\\\\n' && c != '\\\\r')\n}","tryCatchPattern":"if let Ok(Some(interp)) = elf_interpreter(&bytes) {\n    if !safe_interpreter(&interp) {\n        // reject tampered binary; use stock build\n        return Err(anyhow!(\"refusing tampered mise binary\"));\n    }\n}","preventionTips":["Only run stock, signed mise builds on remote-bootstrap paths","Verify binary signatures/checksums before install","Do not patch or repack the mise executable"],"tags":["remote","elf","security","path-validation"],"backgroundTag":"path-traversal-blocked","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"}