Skip to content

uninstall --help performs a real uninstall — unknown flags silently ignored, no confirmation before destructive removal #1038

Open

Description

@metehanulusoy

Summary

codebase-memory-mcp uninstall --help does not print help — it performs a real, destructive uninstall: it removes agent configurations (Claude Code, Codex, Gemini, VS Code, Cursor, …), skills, hooks, and deletes the installed binary, then exits 0.

This happened to me on a real machine: I ran uninstall --help to look up the flag for selective removal, and it wiped the tool from all five detected agents and deleted the binary.

Environment

  • codebase-memory-mcp 0.9.0 (release binary, UI variant)
  • macOS (darwin/arm64)

Reproduction (safe, uses a throwaway HOME)

FAKEHOME=$(mktemp -d)
mkdir -p "$FAKEHOME/.local/bin" "$FAKEHOME/.claude"
echo fake-binary > "$FAKEHOME/.local/bin/codebase-memory-mcp"
echo '{"mcpServers":{"codebase-memory-mcp":{"command":"x"}}}' > "$FAKEHOME/.claude/.mcp.json"

HOME="$FAKEHOME" codebase-memory-mcp uninstall --help

Output:

codebase-memory-mcp uninstall

Claude Code: removed 0 skill(s)
  removed MCP config entry
  removed PreToolUse + SessionStart + SubagentStart hooks
Removed .../.local/bin/codebase-memory-mcp

Uninstall complete.

Exit code 0. The fake binary is gone and .claude/.mcp.json is emptied — help was never printed.

Root cause

Three compounding issues:

  1. Subcommand dispatch matches before global --help — handle_subcommand in src/main.c scans argv positionally, so in uninstall --help the subcommand matches at i=1 and dispatches before the --help check ever sees i=2.
  2. cbm_cmd_uninstall silently ignores unknown flags — src/cli/cli.c#L4087-L4094 only looks for -y/-n (via parse_auto_answer) and --dry-run; anything else — --help, -h, or a typo like --dryrun — falls through to a full uninstall. Note the typo case is arguably worse: uninstall --dryrun performs a real uninstall when the user explicitly asked for a dry run.
  3. No confirmation gate on the destructive path — the agent-config removal and binary deletion at src/cli/cli.c#L4104-L4137 run unconditionally. The only prompt_yn is for index deletion. prompt_yn itself fails closed on non-TTY stdin (good), but nothing destructive is behind it — so even uninstall -n ("answer no to everything") removes all configs and the binary.

The same unknown-flag blindness affects the other mutating subcommands: install --help silently rewrites agent configs, and update --help downloads and replaces the binary.

Expected behavior

  • uninstall --help / install --help / update --help print usage and exit 0 without touching anything.
  • uninstall <unknown-flag> errors out with usage instead of running.
  • uninstall asks for confirmation (or requires -y when non-interactive) before removing configs and the binary; -n aborts.

Proposed fix

I have a patch ready and will open a PR referencing this issue shortly:

  • a --help/-h check at the top of cbm_cmd_install, cbm_cmd_uninstall, and cbm_cmd_update that prints per-command usage and exits 0;
  • strict flag validation in cbm_cmd_uninstall (unknown flag → error + usage, exit 1);
  • a prompt_yn confirmation gate in front of the destructive uninstall path (skipped for --dry-run; -y auto-confirms as before, matching the existing scripts/smoke-test.sh phase 6b invocation uninstall --dry-run -y);
  • regression tests in tests/test_cli.c.

Activity

  1. added this to the 0.9.1-rc milestone on Jul 14, 2026
  2. added
    securitySecurity vulnerabilities, hardening
    priority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.
    on Jul 14, 2026
  3. DeusData commented on Jul 14, 2026

    @DeusData
    Owner

    Thanks for the safe throwaway-HOME reproduction. This is a high-priority 0.9.1-rc safety bug and is also labeled security because help or unknown flags must never trigger destructive configuration or binary removal. PR #1040 is the current fix candidate, but its platform smoke checks are still failing and must be resolved before review can complete.

  4. vpzed commented on Jul 23, 2026

    @vpzed

    Hit this same bug today on Linux. In addition the uninstall left the cbm-code-discovery-gate, cbm-session-reminder, and cbm-subagent-reminder hook files in ~/.claude/hooks so the uninstall didn't completely remove things.

  5. DeusData commented on Jul 24, 2026

    @DeusData
    Owner

    Thanks for confirming the same behavior on Linux. The leftover cbm-code-discovery-gate, cbm-session-reminder, and cbm-subagent-reminder files extend the acceptance criteria: help and unknown flags must never mutate state, and a confirmed uninstall must remove every hook file owned by this installation without touching unrelated hooks. This remains in the 0.9.1-rc safety queue.

  6. DeusData commented on Aug 14, 2026

    @DeusData
    Owner

    @metehanulusoy — you did the whole job here: a safe throwaway-HOME reproduction, the three compounding causes with line references, and the observation that a typo'd --dryrun is arguably worse than --help, because it performs a real uninstall while the user believes they explicitly asked for the opposite.

    I am sorry this hit you on a real machine and removed cbm from all five detected agents. A flag whose entire purpose is to be safe should never be destructive, and the security label on this is deserved.

    A fix is up as PR #1641: the guard now runs before anything destructive happens, so --help prints help and unknown flags error out instead of falling through to a real uninstall. @vpzed — thank you for the Linux confirmation and for catching that the cbm-code-discovery-gate, cbm-session-reminder and cbm-subagent-reminder files survived the uninstall; removing every hook we own, and only those, is part of the acceptance criteria. This is in scope for tonight's v0.10.5.

  7. DeusData commented on Sep 26, 2026

    @DeusData
    Owner

    Thank you, @metehanulusoy, for the safe reproduction and the three-cause breakdown, and @vpzed for the Linux confirmation!

    What changed:

    • uninstall --help now prints usage and exits without touching anything (v0.10.5, a530c8a).
    • Unknown flags such as --dryrun are rejected with an error instead of falling through to a real uninstall.
    • A confirmed uninstall now removes the cbm-code-discovery-gate, cbm-session-reminder and cbm-subagent-reminder scripts and leaves unrelated hooks alone.

    Could you confirm on v0.11.0?

  8. added
    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then close
    on Sep 26, 2026
  9. github-actions commented on Sep 26, 2026

    @github-actions

    Thanks for the report! To move this forward we need a bit more so we can reproduce it ourselves:

    • the codebase-memory-mcp --version you're on
    • the exact steps or command you ran
    • a public repo (or a small dummy snippet) that shows the problem — please don't paste proprietary code

    Once that's here we'll pick it straight back up. Heads-up: issues left awaiting-reporter are automatically closed after a few weeks of silence, but a comment reopens the door anytime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then closebugSomething isn't workingeditor/integrationEditor compatibility and CLI integrationpriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.securitySecurity vulnerabilities, hardeningux/behaviorDisplay bugs, docs, adoption UX

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions