settings.json

sandbox.filesystem.denyRead

型string[]記述場所どの設定ファイルでも可

サブプロセスに対して読み取りアクセスを明示的に拒否するパスを指定します。

記述例

{
  "sandbox": {
    "filesystem": {
      "denyRead": ["~/.aws/credentials"]
    }
  }
}

使い方・用途

  • ~/.aws/credentials などの機密情報が含まれるファイルやディレクトリへのアクセスをサブプロセスから遮断し、情報の流出を防止したい場合に使用します。
  • 読み取り拒否された広範な領域(ホームディレクトリ等)の中から、特定のディレクトリだけを allowRead で再許可する柔軟な設定も可能です。
英語原文(公式ドキュメントより)

Paths where subprocesses are explicitly denied read access. See https://code.claude.com/docs/en/sandboxing#filesystem-isolation

関連する変更履歴

v2.1.304(1件)

Fixed
sandbox.filesystem.denyRead の glob に [user-id] のようなルートフォルダなど、文字クラスではない角括弧が含まれていると Linux でサンドボックス化されたコマンドの起動に失敗する問題を修正した。
英語原文を表示
Fixed sandboxed commands failing to start on Linux when a sandbox.filesystem.denyRead glob contains brackets that are not a character class, such as a [user-id] route folder

v2.1.299(1件)

Fixed
フォルダ名に波括弧・丸括弧・バックスラッシュを含むサンドボックスの denyRead および allowRead グロブが、Claude Code の設定チェックとサンドボックスで異なる解釈をする問題を修正した
英語原文を表示
Fixed sandbox denyRead and allowRead globs with braces, parentheses or backslashes in a folder's name being read differently by Claude Code's settings checks than by the sandbox

v2.1.224(1件)

Fixed
末尾にスラッシュを付けたパス指定(例:denyRead: "~/.aws/")で書かれたサンドボックスのファイルアクセス拒否ルールが、LinuxおよびmacOSにおいてサイレントにバイパスされてしまう問題を修正しました。
英語原文を表示
Fixed sandbox filesystem deny entries written with a trailing slash (e.g. denyRead: "~/.aws/") being silently bypassable on Linux and macOS

変更後

セキュリティ設定ファイルのパスの書き方による偶発的な制限の漏れがなくなり、機密ファイルが含まれるディレクトリを確実に保護できます。

v2.1.179(1件)

Fixed
Linux環境にて大規模なディレクトリ構造に対してサンドボックスのdenyRead/allowReadを適用すると、Bashツールの説明が肥大化しセッションが動作しなくなる問題を修正
英語原文を表示
Fixed a sandbox denyRead/allowRead glob over a large directory tree making the Bash tool description enormous and the session unusable on Linux

変更後

セキュリティのために厳格なファイルアクセス制限を適用しても、CLIの動作が重くなったりクラッシュしたりすることなく、安全に開発を継続できます。

関連ドキュメント

v2.1.77(1件)

Added
サンドボックスのファイルシステム設定に、denyRead 領域内での読み取りを再許可する allowRead を追加しました
英語原文を表示
Added allowRead sandbox filesystem setting to re-allow read access within denyRead regions

変更後

サンドボックスのセキュリティ制限を維持しつつ、必要なファイルへのアクセスだけをピンポイントで許可できるため、柔軟な環境構築が可能です。

関連ドキュメント