-
Notifications
You must be signed in to change notification settings - Fork 3.1k
index_repository name override can silently clobber a different project's index #1578
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workingeditor/integrationEditor compatibility and CLI integrationEditor compatibility and CLI integrationpriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.Needs near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.stability/performanceServer crashes, OOM, hangs, high CPU/memoryServer crashes, OOM, hangs, high CPU/memoryux/behaviorDisplay bugs, docs, adoption UXDisplay bugs, docs, adoption UX
Description
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingeditor/integrationEditor compatibility and CLI integrationEditor compatibility and CLI integrationpriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.Needs near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.stability/performanceServer crashes, OOM, hangs, high CPU/memoryServer crashes, OOM, hangs, high CPU/memoryux/behaviorDisplay bugs, docs, adoption UXDisplay bugs, docs, adoption UX
Summary
index_repository'snameparameter overrides the derived project key, butnothing checks whether that name is already bound to a different repo
root. Calling
index_repository(repo_path: <some-repo>, name: "<existing-project>")silently deletes and recreates
<existing-project>'s index with data fromthe wrong repo — no error, no prompt.
Details
cbm_validate_project_name(src/foundation/str_util.c) only checks thename for path-traversal characters — it doesn't look up whether the name is
already registered to a different
repo_path.handle_index_repository(
src/mcp/mcp.c) callscbm_pipeline_set_project_name(p, name_override),and the resulting pipeline unlinks and recreates the
.dbfile at<CBM_CACHE_DIR>/<name>.db(src/pipeline/pipeline.c) regardless ofwhether that file already belongs to an unrelated project.
Any MCP client that shares one
CBM_CACHE_DIRacross multiple projects (areasonable, even encouraged, setup for a single cache directory) is exposed:
a
nametypo, or a client-side auto-fill that guesses the wrong projectname, replaces someone else's index with no confirmation.
Mitigating factor: an index is derived data, so the fix is "re-index the
correct repo" rather than data loss — but a full reindex runs
capture_existing_adrbefore unlinking, so at least the ADR document itselfsurvives the collision.
Suggested fix
index_repositoryshould refuse anameoverride that already resolves toan existing project whose recorded
repo_pathdiffers from the one suppliedin the call — return an error (e.g. "name '' is already bound to
; use --force to override" or similar) instead of silently
overwriting. This keeps the common case (first-time indexing, or re-indexing
the same repo under the same name) unprompted, while catching the
cross-project collision.
Found via
Downstream client integration (llmenv) — see llmenv issue
phaedrus1992/llmenv#1331 for the client-side
analysis that surfaced this.