In testing, Claude Code read .env secrets into context in all 24 runs when unconfigured
讨论:Qiita实测Claude Code,无配置时24次都把.env密钥读入
A Qiita author ran 48 headless-mode tests on macOS with Claude Code 2.1.300 and Sonnet 5.5, using a fake key CANARY to check whether .env contents would enter the model context. With no protection at all, it was read in all 24 runs, and the auto mode's permission classifier never once blocked reading the project's .env. With only permissions.deny added, 4 of 12 runs leaked, in cases using wildcard grep searches and when running app.py caused error messages to expose the connection string. With the sandbox added, there were zero leaks in 12 runs, but app.py also could not read .env due to Operation not permitted, making the practice of having AI run and debug the app ineffective. The author also found that the sandbox did not inherit Read(![