{"record":{"id":"c8ff27bc54aa7f19","repo":"jdx/mise","slug":"brew-cask-refusing-installer-executable-outside-t","errorCode":null,"errorMessage":"brew-cask: refusing installer executable outside trusted installer roots: {}","messagePattern":"brew-cask: refusing installer executable outside trusted installer roots: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask.rs","lineNumber":2443,"sourceCode":"    let relative = appdir.strip_prefix(Path::new(\"/\")).map_err(|_| {\n        eyre!(\n            \"brew-cask: app directory '{}' must be an absolute path\",\n            appdir.display()\n        )\n    })?;\n    // `allow_current_user` is true because a per-user appdir such as\n    // `~/Applications` is legitimately owned by the invoking user.\n    open_trusted_directory(Path::new(\"/\"), relative, true, true)\n}\n\nfn run_installer_artifact(\n    stage: &Path,\n    installer: &InstallerArtifact,\n    copied_files: &BTreeSet<PathBuf>,\n) -> Result<()> {\n    let executable = stage.join(&installer.executable);\n    if staged_relative_path(stage, &executable).is_none() {\n        bail!(\n            \"brew-cask: refusing installer executable outside trusted installer roots: {}\",\n            executable.display()\n        );\n    }\n    if !executable.is_file() {\n        bail!(\n            \"brew-cask: installer executable '{}' was not found\",\n            installer.executable\n        );\n    }\n    let executable = file::desymlink_path(&executable);\n    if !executable.starts_with(file::desymlink_path(stage)) && !copied_files.contains(&executable) {\n        bail!(\n            \"brew-cask: refusing installer executable outside trusted installer roots: {}\",\n            executable.display()\n        );\n    }\n    file::make_executable(&executable)?;","sourceCodeStart":2425,"sourceCodeEnd":2461,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/packages/brew/cask.rs#L2425-L2461","documentation":"run_installer_artifact executes a cask installer stanza. The executable is stage.join(installer.executable) and must still resolve inside the staging directory (staged_relative_path returns Some). This first bail rejects executables that escape the stage — absolute paths or paths containing '..' — because installers must run from files mise downloaded and verified, not from arbitrary filesystem locations.","triggerScenarios":"installer executable: \"/usr/bin/osascript\", \"/sbin/installer\", or \"../../System/anything\" — any string that, joined onto the stage root, canonicalizes outside it.","commonSituations":"Casks authored for Homebrew that legitimately reference system installers (unsupported here); relative executable strings with ../ from bad templating; stanza copy-paste errors.","solutions":["Point installer executable at a binary shipped inside the cask archive, relative to the stage root (e.g. \"Installer.app/Contents/MacOS/Installer\")","For system-path installers, move the logic into the cask's preflight/postflight steps instead of an installer artifact","Check the stanza for a leading '/' or '..' — that exact shape trips this check"],"exampleFix":"# before (cask stanza)\ninstaller executable: \"/usr/bin/osascript\", args: [\"-e\", \"...\"]\n\n# after\ninstaller executable: \"install.sh\", args: [\"--mode\", \"unattended\"]","handlingStrategy":"validation","validationCode":"// Verify the installer executable stays inside the stage before installing.\nfn installer_inside_stage(stage: &Path, executable: &str) -> bool {\n    let joined = stage.join(executable);\n    std::fs::canonicalize(&joined)\n        .map(|c| c.starts_with(std::fs::canonicalize(stage).unwrap_or_else(|_| stage.to_path_buf())))\n        .unwrap_or(false)\n}","typeGuard":"fn is_staged_relative(executable: &str) -> bool {\n    !executable.starts_with('/') && !executable.split('/').any(|seg| seg == \"..\")\n}","tryCatchPattern":null,"preventionTips":["Always give installer executables as archive-relative paths","Never reference /usr/bin, /sbin, or other absolute binaries in installer stanzas","Put system-installer logic in preflight/postflight steps instead"],"tags":["brew-cask","installer","path-escape","security"],"backgroundTag":"path-escape-blocked","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}