Skip to content

[BUG] [v0.0.7] cortex plugin remove <absolute-path> deletes directories outside ~/.cortex/plugins #49473

Description

@marvinayisi

Project

cortex

Description

cortex plugin remove <absolute-path> can delete arbitrary directories outside ~/.cortex/plugins.

With a fresh HOME and no installed plugins, passing an absolute path to plugin remove -y removes that source directory directly instead of rejecting it as not installed.

Error Message

$ HOME="$tmp" cortex plugin remove -y "$src"
Plugin "/tmp/.../srcplugin" removed successfully.

$ test -e "$src" && echo EXISTS || echo REMOVED
REMOVED

Debug Logs

$ mkdir -p "$src"
$ printf 'name = "demo"\n' > "$src/plugin.toml"
$ printf 'keep\n' > "$src/marker.txt"
$ HOME="$tmp" /Users/odeili/Projects/platform/cortex/target/release/cortex plugin remove -y "$src"
Plugin "/tmp/.../srcplugin" removed successfully.

$ test -e "$src" && echo EXISTS || echo REMOVED
REMOVED

System Information

cortex 0.0.7 (7954d02 2026-04-04)
macOS 26.1 (25B78)
arch: arm64

Screenshots

repro.mp4

Steps to Reproduce

  1. Create a temporary directory outside ~/.cortex/plugins with a marker file.
  2. Use a fresh temporary HOME so there are no installed plugins.
  3. Run cortex plugin remove -y <absolute-path-to-that-directory>.
  4. Check whether the original directory still exists.

Expected Behavior

plugin remove should only remove plugins installed under ~/.cortex/plugins and should reject arbitrary absolute paths.

Actual Behavior

The command resolves the absolute path directly and deletes that external directory.

Additional Context

Code path: src/cortex-cli/src/plugin_cmd.rs. run_remove() computes plugin_path = plugins_dir.join(&args.name). When args.name is absolute, PathBuf::join() returns the absolute path itself, and std::fs::remove_dir_all(&plugin_path) deletes that outside directory.

Duplicate check on April 7, 2026: searched plugin remove absolute path delete arbitrary directory, plugin remove outside plugins directory absolute path, and related variants in the live tracker. No matching live issue was found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginvalidThis doesn't seem right

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions