'Is Your Claude Code Setup Safe? Check in 5 Seconds'

Published: (March 8, 2026 at 05:16 AM EDT)
3 min read
Source: Dev.to

Source: Dev.to

Recent CVE disclosures

Recent CVE disclosures (CVE‑2025‑59536, CVE‑2026‑21852) showed that malicious .claude/settings.json files in cloned repositories can execute arbitrary shell commands and exfiltrate API keys. Anthropic patched these specific vulnerabilities, but the broader question remains: what is Claude Code allowed to do on your machine right now?

Safety‑check script

The script requires no installation and only depends on bash and python3. It runs in about 2 seconds.

curl -fsSL https://raw.githubusercontent.com/Bande-a-Bonnot/Boucle-framework/main/tools/safety-check/check.sh | bash

The script inspects your ~/.claude/settings.json and scores 9 items across 5 categories:

CategoryChecks
Destructive Command Protectionbash-guard (blocks rm -rf /, sudo, `curl
File Protectionfile-guard (prevents reads/writes to .env, private keys, credential files)
branch-guard (blocks direct commits to main/master/production)
Observabilitysession-log (logs every tool call with timestamps to ~/.claude/session-logs/)
Efficiencyread-once (prevents redundant file re‑reads, saving ~2000 tokens per blocked read)
Built‑in SettingsPermission allow/deny rules in settings.json

Example output

Claude Code Safety Check
━━━━━━━━━━━━━━━━━━━━━━━━

Setup
  ✓ Claude Code installed (+5)
  ✓ Settings file exists (+5)

Destructive Command Protection
  ✗ bash-guard (blocks rm -rf /, sudo, curl|bash) (0/20)
  ✓ git-safe (blocks force push, hard reset) (+15)

File Protection
  ✗ file-guard (protects .env, secrets, keys) (0/15)
  ✗ branch-guard (prevents commits to main) (0/10)

Observability
  ✗ session-log (audit trail of all actions) (0/15)

Efficiency
  ✓ read-once (prevents redundant file reads) (+10)

Built-in Settings
  ✗ Permission rules configured (0/5)

━━━━━━━━━━━━━━━━━━━━━━━━

Safety Score: 35/100 (35%) — Grade D
Poor. Claude has too much unguarded access.
4/9 checks passed

If you score below C, the output tells you exactly which commands to run to install the missing hooks.

Why each check matters

WeightCheckReason
20bash-guardHighest blast radius – unrestricted bash is the biggest risk
15git-safeHistory destruction is hard to recover from
15file-guardCredential exposure is irreversible
15session-logWithout logs you can’t audit what happened
10branch-guardProtects deployment branches
10read-onceToken savings, not safety (lower weight)
5settings.jsonBasic config existence
5Claude installedPrerequisite check
5PermissionsBuilt‑in allow/deny rules

How the hooks work

Hooks are deterministic safety layers that run before Claude Code executes a tool call. They are simple Bash scripts that can:

  • Block dangerous commands (rm -rf /, sudo, curl|bash, etc.).
  • Prevent destructive Git operations (force‑push, hard reset).
  • Stop reads of sensitive files (.env, private keys).
  • Enforce branch protection policies.
  • Log every action for later audit.

Because they run regardless of the model’s decisions, they provide a reliable safety net even when the model is prompted to perform risky actions.

Running the check again

curl -fsSL https://raw.githubusercontent.com/Bande-a-Bonnot/Boucle-framework/main/tools/safety-check/check.sh | bash

Source code

The safety‑check script is open‑source and includes 30 tests to verify its behavior. You can review the code and tests in the repository linked above.

0 views
Back to Blog

Related posts

Read more »