본문으로 건너뛰기
Skillpedia
보안29k · #9570

security-guidance

하는 일

파일 편집이 저장되기 전에 확인하는 훅으로, SQL 인젝션이나 안전하지 않은 코드 평가 같은 알려진 위험 패턴을 경고합니다. Claude Code를 쓰면서 추가 안전장치를 원하는 분들을 위한 스킬입니다.

사용하는 경우

  • ✓위험한 코드가 쓰이기 전에 경고하는 자동 점검을 설치할 때.
  • ✓에이전트가 쓰는 코드에서 명령 인젝션, 크로스 사이트 스크립팅(XSS), SQL 인젝션 위험을 줄이고 싶을 때.
  • ✓보안 알림을 끄거나 조정해야 할 때.

스킬 링크

https://github.com/alirezarezvani/claude-skills/blob/main/engineering/security-guidance/skills/security-guidance/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/alirezarezvani/claude-skills/blob/main/engineering/security-guidance/skills/security-guidance/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“위험한 코드가 쓰이기 전에 경고를 받을 수 있도록 보안 훅을 설정해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

훅은 각 편집 전에 실행되며, 파일 경로와 새 내용을 알려진 위험 패턴과 대조하고, 파일과 규칙마다 한 번씩 경고합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Security Guidance Hook

A PreToolUse hook that blocks 12 common security anti-patterns before Claude Code writes them.

This skill is a hook, not a slash command. Once installed, it runs automatically before every Edit, Write, or MultiEdit operation and warns + blocks if it detects a known dangerous pattern.

What It Catches

The hook scans both:

  • The file path being edited — flags GitHub Actions workflow files with risky ${{ }} patterns
  • The content being written — substring matches against 11 anti-patterns
Pattern Category Risk
GitHub Actions workflow expressions Path-based Workflow command injection via untrusted inputs
child_process.exec, exec(, execSync( Substring Node.js command injection
new Function Substring JS code injection
eval( Substring JS code injection
dangerouslySetInnerHTML Substring React XSS
document.write Substring DOM XSS
.innerHTML = Substring DOM XSS
pickle Substring Python deserialization RCE
os.system, from os import system Substring Python command injection
shell=True (subprocess) Substring Python command injection
f-string SQL or .format SQL Substring SQL injection
yaml.load(, yaml.unsafe_load Substring YAML deserialization RCE

How It Works

  1. Claude Code is about to run Edit, Write, or MultiEdit
  2. PreToolUse hook fires → invokes security_reminder_hook.py with the tool input as JSON on stdin
  3. The hook extracts file_path + content + checks against the pattern table
  4. If a pattern matches AND this warning hasn't been shown for this file+rule in this session:
    • Print the warning to stderr (Claude sees it)
    • Exit code 2 → blocks the tool call
    • Save the warning key to ~/.claude/security_warnings_state_<session>.json
  5. If a pattern matches BUT the warning was already shown this session:
    • Allow the tool call (exit code 0) — Claude already saw the warning once
  6. If no pattern matches:
    • Allow the tool call (exit code 0)

Installation

This plugin ships as a Claude Code plugin with hooks.json wiring:

# In Claude Code:
/plugin marketplace add alirezarezvani/claude-skills
/plugin install security-guidance@claude-code-skills

Once installed, no further configuration needed — the hook runs automatically.

Configuration

Disable per-session via environment variable:

ENABLE_SECURITY_REMINDER=0 claude
# Hook is bypassed for this session

Use sparingly — the hook is most useful exactly when you're tempted to disable it (because you're under deadline pressure to ship something you know is sketchy).

Per-File Override Pattern

If a specific file legitimately needs eval() or pickle (e.g., a sandboxed REPL, a deliberately unsafe parser for a fuzzer), document it in the file with a comment:

# SAFETY: pickle is the required serialization format for this internal tool.
# This file does NOT accept untrusted input. See SECURITY.md for boundary analysis.
import pickle

The hook will still warn on first edit per session. After acknowledging, subsequent edits in the same session are allowed (session-state caching).

Why The Patterns Are Substring-Based (Not AST-Based)

Trade-off: AST-based detection would be more precise (no false positives on string literals containing "eval("). Substring-based is:

  • Faster — runs in ms, doesn't parse the file
  • Cross-language — same hook works for JS/TS/Python/YAML/etc.
  • Conservative — false positives are easy to dismiss (one keystroke); false negatives are dangerous

For 90%+ of cases, substring detection is sufficient. If you need stricter detection, layer in a proper SAST tool (semgrep, CodeQL) as a CI step.

State Files

The hook caches "warning shown" state in ~/.claude/security_warnings_state_<session_id>.json. These files:

  • Are auto-cleaned after 30 days (10% chance per hook invocation)
  • Are session-scoped (each Claude session gets its own)
  • Contain a JSON list of <file_path>-<rule_name> keys

You can safely delete ~/.claude/security_warnings_state_*.json files at any time — the hook regenerates them on next run.

Debug Log

The hook writes to ~/.claude/security-warnings-log.txt for debugging hook misfires:

tail -f ~/.claude/security-warnings-log.txt
# Shows JSON decode errors, state-file save failures, etc.

(Upstream version wrote to `/tmp/security-warnings

자주 묻는 질문

끄려면 어떻게 하나요?

환경 변수 ENABLE_SECURITY_REMINDER를 0으로 설정합니다.

어떤 문제를 잡아내나요?

명령 인젝션, 크로스 사이트 스크립팅, SQL 인젝션, 안전하지 않은 역직렬화, eval, GitHub Actions 인젝션을 잡아냅니다.

매번 경고하나요?

아니요. 파일과 규칙마다 한 번만 경고하므로 같은 알림을 반복하지 않습니다.

상세 정보

작성자의 원본 설명

Use when installing or tuning the PreToolUse security hook that warns before Claude writes command injection, XSS, SQL injection, unsafe deserialization, eval or GitHub Actions injection. Warns once per file and rule; ENABLE_SECURITY_REMINDER=0 turns it off.

repo: alirezarezvani/claude-skills

인기도

GitHub 스타
29k
순위
#9570
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬