Skip to content

Conversation

@fnebenfuehr
Copy link
Owner

Add security validation layer for hook commands to prevent dangerous operations:

  • Block dangerous patterns:

    • curl | bash, wget | bash (remote code execution)
    • sudo (privilege escalation)
    • eval (arbitrary code execution)
    • rm -rf on unsafe paths
  • Allow safe operations without warning:

    • Package managers (npm, yarn, pnpm, bun install)
    • Docker compose commands
    • Basic file operations (mkdir, cp, mv, touch, echo, cat)
    • Git operations (fetch, pull, checkout)
    • Build tools (make, cargo, go)
  • Safe rm -rf paths: node_modules, dist, .cache, build, coverage, etc.

  • Show warning + require user confirmation for risky/unknown commands in interactive mode. Skip unrecognized commands in non-interactive mode.

  • Add --trust-hooks flag to bypass validation (not recommended)

  • Add comprehensive tests for pattern detection (50+ test cases)

claude and others added 5 commits November 21, 2025 23:21
Add security validation layer for hook commands to prevent dangerous operations:

- Block dangerous patterns:
  - `curl | bash`, `wget | bash` (remote code execution)
  - `sudo` (privilege escalation)
  - `eval` (arbitrary code execution)
  - `rm -rf` on unsafe paths

- Allow safe operations without warning:
  - Package managers (npm, yarn, pnpm, bun install)
  - Docker compose commands
  - Basic file operations (mkdir, cp, mv, touch, echo, cat)
  - Git operations (fetch, pull, checkout)
  - Build tools (make, cargo, go)

- Safe rm -rf paths: node_modules, dist, .cache, build, coverage, etc.

- Show warning + require user confirmation for risky/unknown commands
  in interactive mode. Skip unrecognized commands in non-interactive mode.

- Add `--trust-hooks` flag to bypass validation (not recommended)

- Add comprehensive tests for pattern detection (50+ test cases)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@fnebenfuehr fnebenfuehr marked this pull request as ready for review November 22, 2025 13:42
@fnebenfuehr fnebenfuehr merged commit ad3c6d8 into main Nov 22, 2025
3 checks passed
@fnebenfuehr fnebenfuehr deleted the claude/add-hook-security-validation-01G4uFsZngs9bejDTExD2bfV branch November 22, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants