cc-safe-setup 1.9.4 → 1.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/examples/README.md +1 -0
- package/examples/network-guard.sh +53 -0
- package/index.mjs +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -151,11 +151,12 @@ Or browse all available examples in [`examples/`](examples/):
|
|
|
151
151
|
- **scope-guard.sh** — Block file operations outside project directory — absolute paths, home, parent escapes ([#36233](https://github.com/anthropics/claude-code/issues/36233))
|
|
152
152
|
- **auto-checkpoint.sh** — Auto-commit after every edit for rollback protection ([#34674](https://github.com/anthropics/claude-code/issues/34674))
|
|
153
153
|
- **git-config-guard.sh** — Block `git config --global` modifications without consent ([#37201](https://github.com/anthropics/claude-code/issues/37201))
|
|
154
|
+
- **deploy-guard.sh** — Block deploy commands when uncommitted changes exist ([#37314](https://github.com/anthropics/claude-code/issues/37314))
|
|
154
155
|
|
|
155
156
|
## Learn More
|
|
156
157
|
|
|
157
158
|
- [Official Hooks Reference](https://code.claude.com/docs/en/hooks) — Claude Code hooks documentation
|
|
158
|
-
- [Hooks Cookbook](https://github.com/yurukusa/claude-code-hooks/blob/main/COOKBOOK.md) —
|
|
159
|
+
- [Hooks Cookbook](https://github.com/yurukusa/claude-code-hooks/blob/main/COOKBOOK.md) — 16 ready-to-use recipes from real GitHub Issues
|
|
159
160
|
- [Japanese guide (Qiita)](https://qiita.com/yurukusa/items/a9714b33f5d974e8f1e8) — この記事の日本語解説
|
|
160
161
|
- [The incident that inspired this tool](https://github.com/anthropics/claude-code/issues/36339) — NTFS junction rm -rf
|
|
161
162
|
|
package/examples/README.md
CHANGED
|
@@ -17,6 +17,7 @@ Custom hooks beyond the 8 built-in ones. Copy any file to `~/.claude/hooks/` and
|
|
|
17
17
|
| **edit-guard.sh** | Block Edit/Write to protected files | [#37210](https://github.com/anthropics/claude-code/issues/37210) |
|
|
18
18
|
| **enforce-tests.sh** | Warn when source changes without test changes | |
|
|
19
19
|
| **git-config-guard.sh** | Block git config --global modifications | [#37201](https://github.com/anthropics/claude-code/issues/37201) |
|
|
20
|
+
| **network-guard.sh** | Warn on suspicious network commands (data exfiltration) | [#37420](https://github.com/anthropics/claude-code/issues/37420) |
|
|
20
21
|
| **notify-waiting.sh** | Desktop notification when Claude waits for input | |
|
|
21
22
|
| **protect-dotfiles.sh** | Block modifications to ~/.bashrc, ~/.aws/, ~/.ssh/ | [#37478](https://github.com/anthropics/claude-code/issues/37478) |
|
|
22
23
|
| **scope-guard.sh** | Block file operations outside project directory | [#36233](https://github.com/anthropics/claude-code/issues/36233) |
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# network-guard.sh — Warn on network commands that send file contents
|
|
3
|
+
#
|
|
4
|
+
# Solves: Prompt injection causing data exfiltration via curl/wget (#37420)
|
|
5
|
+
# This is a warning hook (exit 0), not a blocker (exit 2),
|
|
6
|
+
# because legitimate commands like gh pr create also match.
|
|
7
|
+
#
|
|
8
|
+
# Usage: Add to settings.json as a PreToolUse hook
|
|
9
|
+
#
|
|
10
|
+
# {
|
|
11
|
+
# "hooks": {
|
|
12
|
+
# "PreToolUse": [{
|
|
13
|
+
# "matcher": "Bash",
|
|
14
|
+
# "hooks": [{ "type": "command", "command": "~/.claude/hooks/network-guard.sh" }]
|
|
15
|
+
# }]
|
|
16
|
+
# }
|
|
17
|
+
# }
|
|
18
|
+
|
|
19
|
+
INPUT=$(cat)
|
|
20
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
|
|
21
|
+
|
|
22
|
+
[[ -z "$COMMAND" ]] && exit 0
|
|
23
|
+
|
|
24
|
+
# Skip safe network commands
|
|
25
|
+
if echo "$COMMAND" | grep -qE '^\s*(gh\s|git\s|npm\s|pip\s|curl\s+-s\s+https://api\.|wget\s+-q)'; then
|
|
26
|
+
exit 0
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
# Warn on commands that POST file contents to external URLs
|
|
30
|
+
if echo "$COMMAND" | grep -qE 'curl\s.*(-d\s+@|-F\s+file=|--data-binary\s+@|--upload-file)'; then
|
|
31
|
+
echo "" >&2
|
|
32
|
+
echo "⚠ SECURITY: curl sending file contents to external URL" >&2
|
|
33
|
+
echo "Command: $COMMAND" >&2
|
|
34
|
+
echo "$(date -Iseconds) NETWORK-WARN: $COMMAND" >> "${HOME}/.claude/security-audit.log" 2>/dev/null
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
# Warn on wget/curl POST to non-standard domains
|
|
38
|
+
if echo "$COMMAND" | grep -qE 'curl\s.*-X\s*POST' && ! echo "$COMMAND" | grep -qE '(github\.com|api\.anthropic|localhost|127\.0\.0\.1)'; then
|
|
39
|
+
echo "" >&2
|
|
40
|
+
echo "⚠ SECURITY: POST request to external domain" >&2
|
|
41
|
+
echo "Command: $COMMAND" >&2
|
|
42
|
+
echo "$(date -Iseconds) NETWORK-WARN: $COMMAND" >> "${HOME}/.claude/security-audit.log" 2>/dev/null
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# Warn on piping sensitive files to network commands
|
|
46
|
+
if echo "$COMMAND" | grep -qE '(cat|base64)\s+.*(\.env|credentials|\.pem|\.key|id_rsa).*\|.*(curl|wget|nc|ncat)'; then
|
|
47
|
+
echo "" >&2
|
|
48
|
+
echo "⚠ SECURITY: Sensitive file piped to network command" >&2
|
|
49
|
+
echo "Command: $COMMAND" >&2
|
|
50
|
+
echo "$(date -Iseconds) NETWORK-WARN: $COMMAND" >> "${HOME}/.claude/security-audit.log" 2>/dev/null
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
exit 0
|
package/index.mjs
CHANGED
|
@@ -292,6 +292,7 @@ function examples() {
|
|
|
292
292
|
'auto-checkpoint.sh': 'Auto-commit after edits for rollback protection',
|
|
293
293
|
'git-config-guard.sh': 'Block git config --global modifications',
|
|
294
294
|
'deploy-guard.sh': 'Block deploy when uncommitted changes exist',
|
|
295
|
+
'network-guard.sh': 'Warn on suspicious network commands (data exfiltration)',
|
|
295
296
|
};
|
|
296
297
|
|
|
297
298
|
console.log();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-safe-setup",
|
|
3
|
-
"version": "1.9.
|
|
4
|
-
"description": "One command to make Claude Code safe for autonomous operation. 8 built-in hooks +
|
|
3
|
+
"version": "1.9.5",
|
|
4
|
+
"description": "One command to make Claude Code safe for autonomous operation. 8 built-in hooks + 17 installable examples. Destructive blocker, branch guard, database wipe protection, dotfile guard, and more.",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cc-safe-setup": "index.mjs"
|