{"record":{"id":"71bfd941be12ee6a","repo":"jdx/mise","slug":"relative-remote-mise-path-escapes-the-staged-proje","errorCode":null,"errorMessage":"relative remote mise path escapes the staged project: {command:?}","messagePattern":"relative remote mise path escapes the staged project: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote.rs","lineNumber":1254,"sourceCode":") -> Result<String> {\n    if command.starts_with('/') {\n        return Ok(command.to_string());\n    }\n    if let Some(suffix) = command.strip_prefix(\"~/\") {\n        if suffix.is_empty() {\n            bail!(\"remote mise path does not name an executable: {command:?}\");\n        }\n        let home = remote_home.ok_or_else(|| eyre!(\"remote login home was not resolved\"))?;\n        return Ok(format!(\"{}/{suffix}\", home.trim_end_matches('/')));\n    }\n\n    let mut components = Vec::new();\n    for component in command.split('/') {\n        match component {\n            \"\" | \".\" => {}\n            \"..\" => {\n                if components.pop().is_none() {\n                    bail!(\"relative remote mise path escapes the staged project: {command:?}\");\n                }\n            }\n            component => components.push(component),\n        }\n    }\n    if components.is_empty() {\n        bail!(\"relative remote mise path does not name an executable: {command:?}\");\n    }\n    Ok(format!(\"{project}/{}\", components.join(\"/\")))\n}\n\nfn remote_mise_find_script() -> &'static str {\n    r#\"mise_path=$(command -v mise 2>/dev/null || true)\ncase \"$mise_path\" in /*) ;; *) mise_path= ;; esac\nif [ -z \"$mise_path\" ]; then\n  for candidate in \"$HOME/.local/bin/mise\" \"$HOME/.local/share/mise/bin/mise\" \"$HOME/.cargo/bin/mise\" /usr/local/bin/mise /opt/homebrew/bin/mise; do\n    if [ -x \"$candidate\" ]; then\n      mise_path=$candidate","sourceCodeStart":1236,"sourceCodeEnd":1272,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote.rs#L1236-L1272","documentation":"Relative remote mise paths are resolved against the staged project directory, and `..` components that would pop past the project root are rejected. This error means the configured relative path contains enough `..` segments to escape the staging area, which mise refuses as a path-traversal safety measure.","triggerScenarios":"Normalizing a relative remote mise path during provision; the split-on-'/' loop pops an empty component stack on a `..` (e.g. `../bin/mise`, `a/../../mise`).","commonSituations":"User assumes the base is the home directory or /usr, not the staged project, and writes `../../usr/bin/mise`; config copied from a non-staged setup.","solutions":["Use an absolute path (e.g. `/usr/local/bin/mise`) for binaries outside the staged project","Use a `~/`-prefixed path for home-relative binaries","Rewrite the relative path to stay within the project directory (no leading `..` escapes)"],"exampleFix":"// before\nremote_mise = \"../../usr/local/bin/mise\"\n// after\nremote_mise = \"/usr/local/bin/mise\"","handlingStrategy":"validation","validationCode":"// reject relative paths that escape via '..'\nfn escapes_project(p: &str) -> bool {\n    let mut depth = 0i32;\n    for c in p.split('/') {\n        match c {\n            \"\" | \".\" => {}\n            \"..\" => { depth -= 1; if depth < 0 { return true; } }\n            _ => depth += 1,\n        }\n    }\n    false\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember relative remote mise paths resolve against the staged project directory","Use absolute or ~/ paths for binaries outside the project","Lint host configs for leading `..` segments"],"tags":["path-validation","path-traversal","config"],"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"}