{"record":{"id":"575bf929403eae53","repo":"Hmbown/CodeWhale","slug":"plugin-path-escapes-plugins-directory","errorCode":null,"errorMessage":"plugin path {} escapes plugins directory {}","messagePattern":"plugin path (.+?) escapes plugins directory (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/plugins/install/place.rs","lineNumber":144,"sourceCode":"    Ok(user_plugins_dir.join(name))\n}\n\n/// The resolved bundle must be a direct child of the resolved plugins root,\n/// matching discovery's fail-closed containment rule.\npub(super) fn ensure_target_within_plugins_dir(\n    target: &Path,\n    user_plugins_dir: &Path,\n) -> Result<()> {\n    let root = fs::canonicalize(user_plugins_dir).with_context(|| {\n        format!(\n            \"failed to resolve plugins directory {}\",\n            user_plugins_dir.display()\n        )\n    })?;\n    let target = fs::canonicalize(target)\n        .with_context(|| format!(\"failed to resolve {}\", target.display()))?;\n    if target.parent() != Some(root.as_path()) {\n        bail!(\n            \"plugin path {} escapes plugins directory {}\",\n            target.display(),\n            root.display()\n        );\n    }\n    Ok(())\n}\n","sourceCodeStart":126,"sourceCodeEnd":152,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/plugins/install/place.rs#L126-L152","documentation":"`ensure_target_within_plugins_dir` canonicalizes the plugins root and the target, then requires the target's parent to be exactly the plugins root. If a symlink or `..` component makes the resolved target land outside the plugins directory, it bails — a defense against symlink escapes during uninstall/finalize.","triggerScenarios":"`uninstall`, `update`, or `finalize_install` resolving to a target whose canonical parent is not the plugins dir — e.g. the plugin name is a symlink pointing elsewhere, or the plugins dir itself is symlinked such that canonicalize rewrites the root.","commonSituations":"A user symlinked a plugin folder to another disk/location; the plugins directory is itself a symlink (canonicalized root no longer matches the target's parent); a malicious install tried to plant a link escaping the root.","solutions":["Remove symlinks so the plugin is a real directory directly inside the user plugins dir","Install the plugin with `/plugin install` rather than linking manually","If you intentionally keep plugins elsewhere, point the plugins dir setting at the real location and use real directories"],"exampleFix":"// before: escape via symlink\nln -s ~/elsewhere/myplugin ~/.codewhale/plugins/myplugin\n// after: real directory in place\ncp -r ~/elsewhere/myplugin ~/.codewhale/plugins/myplugin","handlingStrategy":"validation","validationCode":"let root = fs::canonicalize(user_plugins_dir)?;\nlet target = fs::canonicalize(root.join(name))?;\nif target.parent() != Some(root.as_path()) {\n    eprintln!(\"{} would escape the plugins dir\", name);\n    return;\n}","typeGuard":null,"tryCatchPattern":"match uninstall(name, dir) {\n    Err(e) if e.to_string().contains(\"escapes plugins directory\") => {\n        eprintln!(\"plugin target is a symlink or traversal; remove it manually\");\n    }\n    other => other?,\n}","preventionTips":["Do not symlink plugins into the plugins dir; copy them","Keep plugin names as plain [A-Za-z0-9._-] identifiers","Point the plugins-dir setting at the real directory, not a symlink"],"tags":["plugins","path-validation","security"],"backgroundTag":"path-traversal-blocked","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}