jpskill.com
🛠️ 開発・MCP コミュニティ

shared-security-auth-security

機密情報の管理、XSSやCSRF対策、脆弱性のある依存関係の検出、DOMPurifyによる無害化、CSPヘッダー設定、CODEOWNERS、HttpOnly Cookieなど、セキュリティ対策を総合的に支援するSkill。

📜 元の英語説明(参考)

Secrets management, XSS prevention, CSRF protection, dependency scanning, DOMPurify sanitization, CSP headers, CODEOWNERS, HttpOnly cookies

🇯🇵 日本人クリエイター向け解説

一言でいうと

機密情報の管理、XSSやCSRF対策、脆弱性のある依存関係の検出、DOMPurifyによる無害化、CSPヘッダー設定、CODEOWNERS、HttpOnly Cookieなど、セキュリティ対策を総合的に支援するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o shared-security-auth-security.zip https://jpskill.com/download/10265.zip && unzip -o shared-security-auth-security.zip && rm shared-security-auth-security.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10265.zip -OutFile "$d\shared-security-auth-security.zip"; Expand-Archive "$d\shared-security-auth-security.zip" -DestinationPath $d -Force; ri "$d\shared-security-auth-security.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して shared-security-auth-security.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → shared-security-auth-security フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

セキュリティパターン

クイックガイド: シークレットの管理は、.env.local (git 追跡対象外)、CI シークレットを使用し、侵害時またはチーム変更時にローテーションします。依存関係のセキュリティは、自動スキャン (Dependabot) を有効にし、重大な脆弱性を 24 時間以内に修正します。XSS の防止は、最新のフレームワークではデフォルトで出力を自動エスケープします。DOMPurify でサニタイズしない限り、生の HTML インジェクションでバイパスしないでください。CSP ヘッダーを設定します。CODEOWNERS は、auth/、.env.example、workflows のセキュリティチームのレビューを必須にします。

詳細なリソース:

  • コード例については、examples/core.md (必須パターン) を参照してください。
  • 意思決定フレームワークとアンチパターンについては、reference.md を参照してください。

追加の例:


<critical_requirements>

重要: この Skill を使用する前に

すべてのコードは、CLAUDE.md のプロジェクト規約に従う必要があります (kebab-case、名前付きエクスポート、インポート順序、import type、名前付き定数)

(シークレットをリポジトリにコミットしてはなりません - .env.local と CI シークレットのみを使用してください)

(生の HTML をレンダリングする前に、すべてのユーザー入力をサニタイズする必要があります - HTML インジェクションの前に DOMPurify を使用してください)

(重大/高の脆弱性を 24 時間以内に修正する必要があります - 自動スキャンには Dependabot を使用してください)

(認証トークンには HttpOnly クッキーを使用する必要があります - localStorage または sessionStorage は絶対に使用しないでください)

(セキュリティが重要なファイルには CODEOWNERS を構成する必要があります - セキュリティチームの承認を必須にしてください)

</critical_requirements>


自動検出: security, secrets management, XSS prevention, CSRF protection, Dependabot, vulnerability scanning, authentication, DOMPurify, CSP headers, CODEOWNERS, HttpOnly cookies

使用する場合:

  • シークレットを安全に管理する場合 (コミットせずに、.env.local と CI シークレットを使用)
  • 自動脆弱性スキャン用に Dependabot を設定する場合
  • XSS 攻撃を防止する場合 (フレームワークの自動エスケープ、DOMPurify、CSP ヘッダー)
  • セキュリティが重要なコード用に CODEOWNERS を構成する場合
  • 安全な認証とトークンストレージを実装する場合

使用しない場合:

  • 一般的なコード品質レビューの場合 (セキュリティ上の懸念事項ではない)
  • パフォーマンス最適化の場合 (異なるドメイン)
  • CI/CD パイプラインの設定の場合 (ここでのセキュリティパターンは、インフラストラクチャではなくコード用)
  • セキュリティレビューが重要なホットフィックスを遅らせる場合 (フォローアップのためにドキュメント化)

カバーする主要なパターン:

  • シークレットをコミットしない (.gitignore、CI シークレット、四半期ごとのローテーションポリシー)
  • Dependabot による自動依存関係スキャン (24 時間以内に対応)
  • XSS 防止 (フレームワークの自動エスケープ、HTML 用の DOMPurify、CSP ヘッダー)
  • トークンと SameSite クッキーによる CSRF 保護
  • セキュリティが重要な領域の CODEOWNERS (.env.example、認証コード、ワークフロー)
  • 安全なトークンストレージ (HttpOnly クッキー、インメモリアクセストークン)

<philosophy>

哲学

セキュリティは機能ではなく、基盤です。コードのすべての行は、セキュリティを念頭に置いて記述する必要があります。多層防御とは、複数の保護レイヤーを意味し、1 つが失敗した場合に、他のレイヤーが攻撃をキャッチします。

セキュリティパターンを使用する場合:

  • 常に - セキュリティはオプションではありません
  • ユーザー入力を処理する場合 (サニタイズと検証)
  • シークレットを管理する場合 (環境変数、ローテーション)
  • 認証トークンを保存する場合 (HttpOnly クッキー)
  • CI/CD を設定する場合 (脆弱性スキャン、CODEOWNERS)

妥協しない場合:

  • 本番環境で HTTPS をスキップしない
  • クライアント側の検証のみを信頼しない
  • シークレットをリポジトリにコミットしない
  • 機密トークンに localStorage を使用しない
  • 重要なコードのセキュリティレビューをバイパスしない

コア原則:

  • 最小特権: 最小限必要なアクセス権を付与する
  • 多層防御: 複数のセキュリティレイヤー
  • 安全に失敗: デフォルトは拒否であり、許可ではない
  • ユーザー入力を信頼しない: 常に検証とサニタイズを行う
  • 侵害を想定: 攻撃が発生する場合 (発生するかどうかではなく) に備えて計画する

</philosophy>


<patterns>

コアパターン

パターン 1: シークレット管理

シークレットをリポジトリにコミットしないでください。開発には .env.local (git 追跡対象外) の環境変数を使用し、本番環境には CI/CD シークレットマネージャーを使用します。シークレットは四半期ごと、またはチームメンバーの退職時にローテーションします。

シークレットとは

シークレットには、API キー、トークン、パスワード、データベース認証情報、秘密キー、証明書、OAuth クライアントシークレット、暗号化キー、JWT シークレットが含まれます。

シークレットの保存場所

開発:

  • .env.local (git 追跡対象外)
  • 開発者ごとのローカルオーバーライド
  • リポジトリにコミットしない

CI/CD:

  • GitHub Secrets
  • Vercel Environment Variables
  • GitLab CI/CD Variables
  • その他のプラットフォームシークレットマネージャー

本番:

  • 環境変数 (プラットフォームによって注入)
  • シークレット管理サービス (AWS Secrets Manager、HashiCorp Vault)
  • コードにハードコードしない

ローテーションポリシー

注: NIST SP 800-63-4 (2025) は、ユーザーに対する必須の定期的なパスワードローテーションに反対しています。代わりに、イベントベースのローテーション (侵害時、チームメンバーの退職時、またはセキュリティインシデント時) を使用してください。定期的なローテーションは、サービスアカウントと特権アクセスには引き続き推奨されます。

シークレットの種類 ローテーション頻度
サービスアカウントの認証情報 90 日 (四半期ごと)
API キー 365 日 (年 1 回) または侵害時
ユーザーパスワード 侵害時のみ (NIST 2025 ガイダンス)
特権アカウントのパスワード 90 日 (四半期ごと)
証明書 有効期限の 30 日前に警告
すべてのシークレット チームメンバーの退職時に即時

コード例については、examples/core.md を参照してください。


パターン 2: 依存関係のセキュリティ

a

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Security Patterns

Quick Guide: Managing secrets? Use .env.local (gitignored), CI secrets, rotate on compromise or team changes. Dependency security? Enable automated scanning (Dependabot), patch critical vulns within 24hrs. XSS prevention? Modern frameworks auto-escape output by default - never bypass with raw HTML injection unless sanitized with DOMPurify. Set CSP headers. CODEOWNERS? Require security team review for auth/, .env.example, workflows.

Detailed Resources:

Additional Examples:


<critical_requirements>

CRITICAL: Before Using This Skill

All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering, import type, named constants)

(You MUST NEVER commit secrets to the repository - use .env.local and CI secrets only)

(You MUST sanitize ALL user input before rendering raw HTML - use DOMPurify before any HTML injection)

(You MUST patch critical/high vulnerabilities within 24 hours - use Dependabot for automated scanning)

(You MUST use HttpOnly cookies for authentication tokens - NEVER localStorage or sessionStorage)

(You MUST configure CODEOWNERS for security-sensitive files - require security team approval)

</critical_requirements>


Auto-detection: security, secrets management, XSS prevention, CSRF protection, Dependabot, vulnerability scanning, authentication, DOMPurify, CSP headers, CODEOWNERS, HttpOnly cookies

When to use:

  • Managing secrets securely (never commit, use .env.local and CI secrets)
  • Setting up Dependabot for automated vulnerability scanning
  • Preventing XSS attacks (framework auto-escaping, DOMPurify, CSP headers)
  • Configuring CODEOWNERS for security-sensitive code
  • Implementing secure authentication and token storage

When NOT to use:

  • For general code quality reviews (not a security concern)
  • For performance optimization (different domain)
  • For CI/CD pipeline setup (security patterns here are for code, not infrastructure)
  • When security review would delay critical hotfixes (document for follow-up)

Key patterns covered:

  • Never commit secrets (.gitignore, CI secrets, rotation policies quarterly)
  • Automated dependency scanning with Dependabot (critical within 24h)
  • XSS prevention (framework auto-escaping, DOMPurify for HTML, CSP headers)
  • CSRF protection with tokens and SameSite cookies
  • CODEOWNERS for security-sensitive areas (.env.example, auth code, workflows)
  • Secure token storage (HttpOnly cookies, in-memory access tokens)

<philosophy>

Philosophy

Security is not a feature - it's a foundation. Every line of code must be written with security in mind. Defense in depth means multiple layers of protection, so if one fails, others catch the attack.

When to use security patterns:

  • Always - security is not optional
  • When handling user input (sanitize and validate)
  • When managing secrets (environment variables, rotation)
  • When storing authentication tokens (HttpOnly cookies)
  • When setting up CI/CD (vulnerability scanning, CODEOWNERS)

When NOT to compromise:

  • Never skip HTTPS in production
  • Never trust client-side validation alone
  • Never commit secrets to repository
  • Never use localStorage for sensitive tokens
  • Never bypass security reviews for critical code

Core principles:

  • Least privilege: Grant minimum necessary access
  • Defense in depth: Multiple layers of security
  • Fail securely: Default to deny, not allow
  • Don't trust user input: Always validate and sanitize
  • Assume breach: Plan for when (not if) attacks happen

</philosophy>


<patterns>

Core Patterns

Pattern 1: Secret Management

Never commit secrets to the repository. Use environment variables in .env.local (gitignored) for development, and CI/CD secret managers for production. Rotate secrets quarterly or on team member departure.

What Are Secrets

Secrets include: API keys, tokens, passwords, database credentials, private keys, certificates, OAuth client secrets, encryption keys, JWT secrets.

Where to Store Secrets

Development:

  • .env.local (gitignored)
  • Per-developer local overrides
  • Never committed to repository

CI/CD:

  • GitHub Secrets
  • Vercel Environment Variables
  • GitLab CI/CD Variables
  • Other platform secret managers

Production:

  • Environment variables (injected by platform)
  • Secret management services (AWS Secrets Manager, HashiCorp Vault)
  • Never hardcoded in code

Rotation Policies

Note: NIST SP 800-63-4 (2025) recommends against mandatory periodic password rotation for users. Instead, use event-based rotation (on compromise, team member departure, or security incident). Periodic rotation is still recommended for service accounts and privileged access.

Secret Type Rotation Frequency
Service account credentials 90 days (quarterly)
API keys 365 days (annually) or on compromise
User passwords On compromise only (NIST 2025 guidance)
Privileged account passwords 90 days (quarterly)
Certificates 30 days warning before expiry
All secrets Immediately on team member departure

See examples/core.md for code examples.


Pattern 2: Dependency Security

Enable automated vulnerability scanning with Dependabot to catch security issues in dependencies. Patch critical vulnerabilities within 24 hours, high within 1 week, medium within 1 month.

Update Policies

Security updates:

  • Critical vulnerabilities - Immediate (within 24 hours)
  • High vulnerabilities - Within 1 week
  • Medium vulnerabilities - Within 1 month
  • Low vulnerabilities - Next regular update cycle

Regular updates:

  • Patch updates (1.2.3 -> 1.2.4) - Auto-merge if tests pass
  • Minor updates (1.2.0 -> 1.3.0) - Review changes, test, merge
  • Major updates (1.0.0 -> 2.0.0) - Plan migration, test thoroughly

See examples/dependency-security.md for Dependabot configuration and CI security check scripts.


Pattern 3: XSS Prevention

Modern UI frameworks auto-escape user input by default. Never bypass this protection with raw HTML injection unless sanitized with DOMPurify. Configure Content Security Policy (CSP) headers to block unauthorized scripts.

Framework Auto-escaping

Most frameworks escape text content automatically. Only explicit HTML injection APIs (e.g., dangerouslySetInnerHTML, v-html, {@html}) bypass this protection.

DOMPurify Sanitization

When HTML rendering is required, use DOMPurify with a whitelist of allowed tags and attributes.

Content Security Policy

Configure CSP headers to prevent unauthorized script execution even if XSS occurs.

See examples/xss-prevention.md for DOMPurify and CSP code examples.


OWASP Top 10:2025 Coverage

This skill addresses the following OWASP Top 10:2025 categories:

OWASP Category Coverage
A01: Broken Access Control CODEOWNERS, branch protection, rate limiting
A02: Security Misconfiguration CSP headers, security headers, Dependabot
A03: Software Supply Chain Failures Dependabot, CI security audits, dependency review
A04: Cryptographic Failures HttpOnly/Secure cookies, HTTPS enforcement
A05: Injection DOMPurify, framework auto-escaping, CSP
A07: Authentication Failures HttpOnly cookies, session management
A10: Mishandling of Exceptional Conditions Fail securely principle, error handling

</patterns>


Defense in depth layers:

  • Secrets: .env.local (dev) -> CI secrets -> Environment variables (production)
  • XSS: Framework auto-escaping -> DOMPurify sanitization -> CSP headers
  • CSRF: Tokens -> SameSite cookies -> Server-side validation
  • Dependencies: Automated scanning -> CI security audit -> Manual review

<red_flags>

RED FLAGS

High Priority Issues:

  • Committing secrets to repository (.env files, API keys in code)
  • Injecting raw HTML with unsanitized user input (enables XSS attacks)
  • Storing authentication tokens in localStorage/sessionStorage (accessible to XSS)
  • No CSRF protection on state-changing operations (allows forged requests)
  • Critical/high vulnerabilities unpatched (exploit window open)

Medium Priority Issues:

  • No Dependabot configuration (manual vulnerability detection only)
  • Missing CODEOWNERS for security-sensitive files (no automatic review)
  • No CSP headers configured (no script execution controls)
  • Individual CODEOWNERS instead of teams (single point of failure)
  • Trusting client-side validation only (easily bypassed)
  • Exposing internal error details to users (information leakage)

Gotchas & Edge Cases:

  • .env.local is gitignored by default in some frameworks but not all - verify your .gitignore
  • DOMPurify's default config allows <style> and <form> tags - use explicit whitelist
  • SameSite=Strict blocks legitimate cross-site requests - use Lax for general session cookies
  • CSP nonces must be unique per request - generate fresh nonces server-side
  • X-XSS-Protection header is deprecated - set to "0" or omit, use CSP instead

See reference.md for common mistakes, anti-patterns with code examples, and decision frameworks.

</red_flags>


<critical_reminders>

CRITICAL REMINDERS

All code must follow project conventions in CLAUDE.md

(You MUST NEVER commit secrets to the repository - use .env.local and CI secrets only)

(You MUST sanitize ALL user input before rendering raw HTML - use DOMPurify before any HTML injection)

(You MUST patch critical/high vulnerabilities within 24 hours - use Dependabot for automated scanning)

(You MUST use HttpOnly cookies for authentication tokens - NEVER localStorage or sessionStorage)

(You MUST configure CODEOWNERS for security-sensitive files - require security team approval)

Failure to follow these rules will create security vulnerabilities enabling XSS attacks, token theft, CSRF attacks, and data breaches.

</critical_reminders>