NewsCrawler.org

Securing Claude Code in the Auto mode era: 10 verified security kits

Auto mode時代のClaude Codeを守る。検証済み10キットで始めるセキュリティ対策【全員・チーム・組織別】
READMEの隠れた指示を、Claudeがプロンプトインジェクションと見抜いて拒否した画面
キットの hook が、Python で .env を開くコマンドを止めた画面
.envの中身を外部に送る操作を、モデルのsafeguardsがセッションを止めた画面
Image: zenn.dev

What happened next

  1. GitHub security in the Claude Code era: 10 verified kits by team and organization type

The whole story · 2 →

The author, a frontend engineer at Sonicmoov, follows up on a previous article about protecting GitHub repositories from AI-era threats with a guide to protecting Claude Code itself, the agent running on a developer's local machine. Claude Code reads files, executes commands and communicates with external services, so damage can occur both when it loads a hidden malicious instruction (prompt injection[1]) and when it simply interprets a request too broadly: secrets can be read or sent out, files destroyed, and its own protective settings removed. The countermeasures are organized into four 'don't let it' principles: don't let it read secrets such as .env files, SSH keys and cloud credentials; don't let it send data out through curl and WebFetch; don't let it destroy files and history with rm -rf, git push --force and git reset --hard; and don't let it strip its own defenses by rewriting .claude/settings.json and hooks[2].

Auto mode is now the default permission mode, so the author's verification targeted behavior without a confirmation screen: in October 2026, on macOS with Claude Code 2.1.29x and dummy secrets, 12 operations were tried in each permission mode. In auto mode, rm -rf outside the working folder, git push --force, and rewriting .claude/settings.json or hook scripts all ran with no confirmation; the auto mode classifier[3], whose decisions appeared on screen as 'Allowed by auto mode classifier', blocks operations it recognizes as irreversible, destructive or sending data externally, but let the force push and the settings writes through. Reading .env was stopped in every mode by Claude's own judgment, which also refused to follow hidden instructions planted in a README, and attempts to send secrets outward were halted by the model's built-in safeguards, which flagged a curl of .env contents as cyber-attack-related. Safeguards are not a hard wall — switching models lets a session continue, and they even blocked a harmless curl to example.com as a false positive — while Anthropic's own figures put user approval of confirmation screens at 97%, humans catching dangerous commands at 14%, and the auto mode classifier at 89%.

Because no single layer stops every bypass — a deny rule blocked cat .env but not a Python script opening the same file — the guide combines permission rules (deny, ask, allow), hooks that inspect commands before execution, an OS-level sandbox[4] restricting file access and network destinations (macOS, Linux and WSL2), and simply keeping real secrets out of the working folder. With the kits installed, hooks stopped the destructive and settings-rewriting operations even in auto mode and bypass mode, and a hook layered over the sandbox also prevented auto mode's dynamic loosening, in which Claude added example.com to the sandbox allowlist and retried a blocked request without confirmation. For organizations, Managed settings take precedence over every other configuration and cannot be overridden by users or Claude, with options such as disableBypassPermissionsMode and allowManagedPermissionRulesOnly.

Read the original zenn.dev

Sources

  • Zenn JA

    Auto mode時代のClaude Codeを守る。検証済み10キットで始めるセキュリティ対策【全員・チーム・組織別】

    22 likes6 bookmarks1 comment

Published: First seen: Читать по-русски

Open as a page