GHSA-fjj5-v948-whjj: Mise Vulnerable to Arbitrary Code Execution via Tera Templates in .tool-versions Files (Trust Bypass)
SummaryMise processes `.tool-versions` files through the Tera template engine during parsing, with the `exec()` function registered, enabling arbitrary command execution. Unlike `.mise.toml` files, `.tool-versions` files are **not subject to trust verification** in non-paranoid mode. This means an attacker can place a malicious `.tool-versions` file in a git repository, and when a victim with mise activated `cd`s into the directory, arbitrary commands execute without any trust prompt.Vulnerability DetailsVulnerable Code**File:** `src/config/config_file/tool_versions.rs`, lines 60-63**File:** `src/tera.rs`, lines 385-391**File:** `src/tera.rs`, lines 394-452 -- `tera_exec` passes the `command` argument to a shell for execution with no restrictions.**File:** `src/config/config_file/mod.rs`, lines 272-287Attack VectorAn attacker creates a `.tool-versions` file in a git repository containing Tera template syntax with the `exec()` function.The victim clones the repository and has mise activated in their shell (via `eval "$(mise activate zsh)"` or equivalent).When the victim `cd`s into the repository directory, mise's shell hook (`hook-env`) fires automatically.`hook-env` loads and parses config files, including `.tool-versions`.During parsing, `ToolVersions::parse_str` processes the file content through `get_tera(dir).render_str()`.The Tera engine evaluates `{{ exec(command="...") }}`, executing arbitrary commands as the victim's user.No trust prompt is displayed because `trust_check` is not called for `.tool-versions` files in non-paranoid mode.Execution ContextCommands execute as the current user with full access to their environment.The pristine environment (`env::PRISTINE_ENV`) is passed to the executed command, which includes all of the user's environment variables (potentially including tokens, credentials, SSH agents, etc.).Execution happens silently during the prompt hook -- the user sees no indication that code was run.Contrast with .mise.toml`.mise.toml` files are protected: `MiseToml::from_str()` calls `trust_check(path)` before any parsing occurs (line 213 of `mise_toml.rs`). During `hook-env`, untrusted `.mise.toml` files fail to parse with an `UntrustedConfig` error, preventing any code execution. `.tool-versions` files lack this protection entirely.Steps to ReproducePrerequisitesmise installed (`brew install mise` or equivalent)Shell activation enabled: `eval "$(mise activate zsh)"` (or bash/fish)Default settings (paranoid mode NOT enabled — this is the default)PoC: Silent RCE on `cd`**Step 1:** Create a directory simulating a cloned repository with a malicious `.tool-versions`:Note: The `exec()` output is concatenated with `node` so the resulting line parses as a valid tool-versions entry. The payload redirects all output to a file, producing no stdout — the `exec()` returns an empty string, making the line evaluate to `node 20.0.0`.**Step 2:** In a new shell with mise activated, enter the directory:**Step 3:** Verify arbitrary code execution:**Expected output:**No trust prompt, no warning, no error output. The `id` command executed silently as the current user.Validated Test ResultsTested on 2026-03-16 with:mise 2026.3.9 macos-arm64macOS Darwin 24.5.0 arm64zsh 5.9Paranoid mode: `false` (default)**Test 1 — `.tool-versions` (no trust check):**Command executed silently. No trust prompt. No errors.**Test 2 — `.mise.toml` with same payload (trust check blocks execution):**`.mise.toml` correctly blocked by trust verification. `.tool-versions` bypasses it entirely.Alternative PoC (data exfiltration)Impact**Arbitrary code execution** on any machine where a user with mise activated enters a directory containing a malicious `.tool-versions` file.**Supply chain attack vector**: `.tool-versions` is a widely-used convention from asdf-vm and is commonly committed to repositories. Developers expect it to contain only tool names and versions, not executable content.**Silent execution**: No trust prompt, warning, or user interaction required.**Full user privilege escalation**: Commands run with the full privileges and environment of the current user.**Credential theft**: The user's full environment (including tokens, API keys, SSH agent) is available to the executed command.**Widespread potential impact**: Any open-source project with a `.tool-versions` file could be targeted. A malicious PR adding tera syntax to an existing `.tool-versions` file could execute code on all reviewers' machines.Suggested FixOption 1: Add trust_check to .tool-versions parsing (recommended)Option 2: Remove exec() from .tool-versions tera contextCreate a separate `get_tera_safe()` that does not register the `exec` function, and use it for `.tool-versions` parsing.Option 3: Remove tera processing from .tool-versions entirely`.tool-versions` is an asdf-compatible format that historically does not support templates. Removing tera from its parsing would be the safest approach and most consistent with user expectations.
CVSS v3.1: 9.6