Skip to content

Active workspace state should validate root, db_path, and config-home inputs #3430

Description

@Widthdom

Found while dogfooding the current source with the locally built cdidx.

Active workspace state loading accepts or invents critical paths too leniently. A missing root falls back to the caller's current directory, db_path is accepted after GetFullPath without checking relationship to the root, missing db_path returns null without a diagnostic, and XDG_CONFIG_HOME is used directly when composing the active state path.

Evidence:

  • src/CodeIndex/ActiveWorkspace.cs Load uses ReadString(root, "root") ?? Environment.CurrentDirectory.
  • The same loader returns a state from Path.GetFullPath(workspaceRoot) and Path.GetFullPath(dbPath) without a containment check.
  • Missing db_path returns null.
  • StatePath trusts raw XDG_CONFIG_HOME before appending cdidx/active.json.

Suggested fix: require explicit valid state roots, validate db_path ownership/containment or document allowed external DBs, surface safe diagnostics for malformed state, and validate config-home inputs before composing paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsecurity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions