Hmbown/CodeWhale · error
reviewed plugin MCP path escaped its staged root
Error message
reviewed plugin MCP path escaped its staged root
What it means
This error is thrown when a reviewed plugin's MCP server working directory, after canonicalization, no longer sits under the plugin's staged root directory. The library validates that the resolved path starts with the staged plugin path to prevent a reviewed plugin from executing its MCP server from outside the approved staging location (e.g. via a symlink). It is a security guard against path escape during plugin review.
Solutions
- Copy the MCP server files physically into the staged plugin directory instead of symlinking them
- Make sure the staged `plugin_path` is itself canonicalized before the comparison, so prefix matching is consistent
- If using temp dirs on macOS, stage plugins under the canonical path (e.g. /private/var/...) or canonicalize the root before staging
- Re-package the plugin so its cwd genuinely lives inside the reviewed staging root
Example fix
// before
let plugin_path = std::env::temp_dir().join("plugins").join("reviewed"); // non-canonical, symlinked root
// after
let plugin_path = std::env::temp_dir().join("plugins").join("reviewed").canonicalize()?; // canonical root so starts_with holds Defensive patterns
Strategy: validation
Validate before calling
fn plugin_cwd_within_root(cwd: &Path, plugin_path: &Path) -> bool {
let resolved = cwd.canonicalize().unwrap_or_else(|_| cwd.to_path_buf());
resolved.starts_with(plugin_path)
}
assert!(plugin_cwd_within_root(&staged_cwd, &plugin_root), "staged cwd escaped plugin root"); Type guard
fn is_within(child: &Path, parent: &Path) -> bool {
child.canonicalize().map(|c| c.starts_with(parent)).unwrap_or(false)
} Prevention
- Copy (don't symlink) plugin files into the staged root
- Canonicalize both sides of prefix checks before comparing
- Avoid staging plugins under macOS /var symlinked temp dirs
When it happens
Trigger: Calling the plugin MCP path resolution function (around crates/tui/src/mcp.rs:5596) when the canonicalized `cwd` of the plugin's staged MCP server resolves outside `plugin_path` — typically because the staged path contains a symlink pointing elsewhere, or a `..` component escapes the root.
Common situations: A plugin developer symlinks their MCP server binary or directory into the staging area instead of copying it; CI copies plugins with symlinks preserved; a user hand-edits the staged plugin layout; macOS temp-dir symlinks (/var -> /private/var) making canonicalization diverge from the staged prefix.
Understand the failure class
Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.
Related errors
- Project MCP server cwd must stay within workspace
- Refusing to MCP server ' ' from plugin bundle ` `: .
- reviewed plugin stage changed before stdio launch
- reviewed plugin stage could not be opened for launch
- reviewed plugin stdio cwd escaped its staged root
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/ffd69900cefe47a6.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/mcp.rs:5596
anyhow::bail!("reviewed plugin MCP argument path escaped its staged root");
}
*argument = frozen.display().to_string();
}
}
Ok(())
}
fn resolve_plugin_mcp_cwd(plugin_path: &Path, cwd: Option<&Path>) -> Result<PathBuf> {
let cwd = match cwd {
Some(cwd) if cwd.is_relative() => normalize_path_components(&plugin_path.join(cwd)),
Some(cwd) => normalize_path_components(cwd),
None => plugin_path.to_path_buf(),
};
let resolved = cwd
.canonicalize()
.unwrap_or_else(|_| normalize_path_components(&cwd));
if !resolved.starts_with(plugin_path) {
anyhow::bail!("reviewed plugin MCP path escaped its staged root");
}
Ok(resolved)
}
fn workspace_allows_project_mcp_config(workspace: &Path) -> bool {
crate::config::is_workspace_trusted(workspace)
}
fn checked_workspace_mcp_config_path(workspace: &Path) -> Result<PathBuf> {
Ok(checked_workspace_path(workspace)?
.join(".codewhale")
.join("mcp.json"))
}
fn checked_workspace_path(workspace: &Path) -> Result<PathBuf> {
if workspace.as_os_str().is_empty() {
anyhow::bail!("workspace path cannot be empty");
}View on GitHub (pinned to 73e0f67d83)