New chat sessions without an explicitly selected project can default the working directory to the entire user home folder (unscoped, expensive tool reads)
Summary / 概要
EN: When starting a new chat/session without explicitly picking a project folder, the underlying claude.exe CLI process can be launched with its working directory (cwd) resolved to the OS user's home directory (e.g. C:\Users\<username>) instead of a specific project subfolder. Because ordinary tool calls (Bash, Glob, Read, Grep) operate directly with the OS user's filesystem permissions and are not gated by any directory-consent mechanism (that gate — a folder-picker/approval flow — only applies when a session explicitly requests access outside its current cwd, not to what the cwd itself resolves to), any broad or recursive command issued in such a session can silently traverse the entire home directory tree. Given that a typical home directory contains many unrelated projects, caches, and large trees (AppData, Documents, plugin caches, etc.), this is a realistic and costly failure mode: large numbers of files/tokens can be read into the model's context without the user intending or noticing it, driving up token consumption unexpectedly.
JA: プロジェクトフォルダを明示的に選ばずに新規チャット/セッションを開始すると、その裏で起動されるclaude.exe CLIプロセスの作業ディレクトリ(cwd)が、特定のプロジェクトサブフォルダではなく、OSユーザーのホームディレクトリ(例: C:\Users\<username>)になることがあります。通常のツール呼び出し(Bash、Glob、Read、Grep)はOSユーザーの権限でそのままファイルシステムを操作し、ディレクトリアクセスの同意ゲート(フォルダピッカー/承認フロー)は現在のcwdの「外」に明示的にアクセスする場合にのみ働き、cwd自体がどこに解決されるかには関与しません。そのため、そのようなセッションで広域・再帰的なコマンドが実行されると、ホームディレクトリ全体を静かに走査してしまう可能性があります。一般的なホームディレクトリには無関係な多数のプロジェクトやキャッシュ、大きなツリー(AppData、Documents、プラグインキャッシュ等)が含まれるため、これは現実的かつコストの高い失敗モードです。ユーザーが意図せず、また気づかないまま、大量のファイル/トークンがモデルのコンテキストに読み込まれ、想定外のトークン消費につながります。
---
Evidence / 根拠
EN:
- A locally-installed third-party plugin that logs session start events (keyed by resolved project directory) showed 526 distinct sessions over a 5-day window whose resolved project directory was the bare home directory (
C:\Users\<username>) rather than any project subfolder — roughly 100+ per day. - Comparing currently-running
claude.exeprocesses: sessions where a project folder had been explicitly chosen showed an--add-dir <specific-project-path>argument in their launch command line; a session with no project chosen did not have this argument at all. - This is consistent with: cwd resolution silently falling back to the OS home directory whenever no project is explicitly selected at session start, with no safeguard preventing tool calls from then operating unscoped across that entire tree.
- We could not fully reproduce the exact UI trigger step from outside the desktop app (no access to its source), but the historical volume (526 occurrences) and the process-argument comparison make the mechanism very likely.
JA:
- ローカルにインストールされているサードパーティプラグイン(セッション開始イベントを解決済みプロジェクトディレクトリ単位で記録するもの)を確認したところ、過去5日間で526件の別セッションが、特定のプロジェクトサブフォルダではなく、ホームディレクトリそのもの(
C:\Users\<username>)を解決済みプロジェクトディレクトリとして記録していました(1日あたり100件超)。 - 現在動作中の
claude.exeプロセスを比較すると、プロジェクトフォルダを明示的に選んだセッションは起動コマンドラインに--add-dir <具体的なプロジェクトパス>という引数が付いていましたが、プロジェクトを選ばなかったセッションにはこの引数が一切ありませんでした。 - これは、セッション開始時にプロジェクトが明示選択されなかった場合、cwdの解決がOSのホームディレクトリへ静かにフォールバックし、その後のツール呼び出しがそのツリー全体に対して無制限に動作してしまう、という挙動と整合します。
- デスクトップアプリのソースにアクセスできないため、外部から正確なUIトリガー手順を完全に再現することはできませんでしたが、過去の発生件数(526件)とプロセス引数の比較から、この機構である可能性は高いと考えられます。
---
Expected behavior / 期待される挙動
EN: Starting a new chat without an explicitly selected project should never silently resolve the working directory to the entire home directory. Safer defaults would include: (a) refusing to start / prompting for a folder before any tool use is allowed, or (b) defaulting to the most-recently-used project directory, or (c) at minimum, surfacing a clear, persistent indicator in the UI when a session's scope is unset/global, before any broad tool call is permitted.
JA: プロジェクトを明示的に選ばずに新規チャットを開始した場合、作業ディレクトリが黙ってホームディレクトリ全体に解決されるべきではありません。より安全なデフォルトとしては、(a) フォルダが選択されるまで開始を拒否する/ツール使用前に選択を促す、(b) 直近使用したプロジェクトディレクトリをデフォルトにする、(c) 少なくとも、スコープが未設定/グローバルなセッションであることを、広域なツール呼び出しが許可される前にUI上ではっきり・持続的に表示する、などが考えられます。
---
Impact / 影響
EN: Unexpected, potentially large token consumption (and, on paid usage plans, real cost) from unscoped filesystem reads the user never intended. This is especially concerning for users relying on a fixed-price plan with a token/usage ceiling, where an accidental broad scan can consume a disproportionate share of their budget without any warning.
JA: ユーザーが意図しないスコープ無しのファイルシステム読み取りにより、予期しない、場合によっては大量のトークン消費(および従量課金プランでは実費用)が発生します。特に、定額プランで使用量上限がある利用者にとっては、警告なく偶発的な広域スキャンが発生し、予算の不釣り合いに大きな割合を消費してしまう恐れがあり、深刻な懸念事項です。
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗