security-fundamentals
Auto-invoke when reviewing authentication, authorization, input handling, data exposure, or any user-facing code. Enforces OWASP top 10 awareness and security-first thinking.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o security-fundamentals.zip https://jpskill.com/download/18289.zip && unzip -o security-fundamentals.zip && rm security-fundamentals.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/18289.zip -OutFile "$d\security-fundamentals.zip"; Expand-Archive "$d\security-fundamentals.zip" -DestinationPath $d -Force; ri "$d\security-fundamentals.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
security-fundamentals.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
security-fundamentalsフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
セキュリティの基礎レビュー
「セキュリティは機能ではない。土台である。砂の上に家を建てれば、家は倒れる。」
適用時期
以下のレビュー時にこのスキルを有効にします。
- 認証/ログインフロー
- 認可チェック
- ユーザー入力の処理
- データベースクエリ
- ファイルアップロード
- API エンドポイント
- レスポンスにおけるデータ露出
レビューチェックリスト
入力検証 (クライアントを決して信用しない)
- [ ] すべての入力が検証されているか: すべてのユーザー入力は使用前にチェックされていますか?
- [ ] サーバーサイド検証: 検証はクライアントだけでなく、サーバー上で行われていますか?
- [ ] 型チェック: 予期される型は強制されていますか?
- [ ] 長さ制限: 文字列の長さに制限はありますか?
- [ ] ブラックリストよりもホワイトリスト: 許可される値は明示的に定義されていますか?
認証
- [ ] パスワードハッシュ: パスワードは暗号化ではなく、ハッシュ化(bcrypt、argon2)されていますか?
- [ ] 平文のシークレットがないか: シークレットはコードではなく、環境変数にありますか?
- [ ] トークンの有効期限: JWT/セッションには妥当な有効期限がありますか?
- [ ] 安全な伝送: HTTPS は強制されていますか?
認可
- [ ] 所有権チェック: ユーザーは自分のデータにのみアクセスできますか?
- [ ] ロール検証: 管理者ルートはロールチェックによって保護されていますか?
- [ ] クライアントサイド認証がないか: 認可はサーバーサイドで強制されていますか?
データ露出
- [ ] 最小限のレスポンス: API は必要なフィールドのみを返しますか?
- [ ] URL に機密データがないか: トークン/ID はクエリ文字列に含まれていませんか?
- [ ] ログに機密データがないか: パスワード/トークンはログから除外されていますか?
OWASP Top 10 クイックチェック
1. インジェクション (SQL, NoSQL, コマンド)
❌ db.query(`SELECT * FROM users WHERE id = ${userId}`);
✅ db.query('SELECT * FROM users WHERE id = ?', [userId]);
2. 認証の不備
❌ if (req.headers.admin === 'true') { /* allow admin */ }
✅ const user = await verifyToken(req.headers.authorization);
if (user.role !== 'admin') throw new ForbiddenError();
3. 機密データの露出
❌ res.json({ user: { ...user, password, ssn } });
✅ res.json({ user: { id: user.id, name: user.name } });
4. 不適切なアクセス制御
❌ app.get('/users/:id', async (req, res) => {
const user = await User.findById(req.params.id);
res.json(user);
});
✅ app.get('/users/:id', async (req, res) => {
const user = await User.findById(req.params.id);
if (user.id !== req.user.id && req.user.role !== 'admin') {
throw new ForbiddenError();
}
res.json(user);
});
5. セキュリティ設定の誤り
❌ CORS: origin: '*'
❌ Detailed error messages in production
❌ Debug mode enabled in production
✅ CORS: origin: process.env.ALLOWED_ORIGINS
✅ Generic error messages to clients
✅ Debug mode disabled in production
6. クロスサイトスクリプティング (XSS)
❌ element.innerHTML = userInput;
✅ element.textContent = userInput;
✅ DOMPurify.sanitize(userInput);
ソクラテス式質問
ジュニアに答えを与える代わりに、これらの質問をしてください。
- 信頼: 「悪意のあるユーザーがここで好きなものを送信するのを防ぐものは何ですか?」
- 所有権: 「このユーザーがこのリソースを所有していることをどのように知っていますか?」
- 露出: 「このエンドポイントが公開された場合、最悪の事態は何ですか?」
- シークレット: 「このリポジトリを
git cloneした場合、どのようなシークレットが表示されますか?」 - インジェクション: 「誰かが
'; DROP TABLE users; --を入力として送信したらどうなりますか?」
指摘すべき危険信号
| フラグ | リスク | 質問 |
|---|---|---|
| クエリ内の文字列連結 | SQL インジェクション | 「この入力に SQL が含まれる可能性はありますか?」 |
eval() または new Function() |
コードインジェクション | 「なぜ動的なコード実行が必要なのですか?」 |
ユーザーデータを含む innerHTML |
XSS | 「ユーザーが <script> を含めたらどうなりますか?」 |
| ログ内のパスワード | データ漏洩 | 「誰がこれらのログを見ることができますか?」 |
| 認証に対するレート制限がない | ブルートフォース | 「誰かがすべてのパスワードを試すのを防ぐものは何ですか?」 |
CORS: * |
セキュリティバイパス | 「どのウェブサイトもこの API を呼び出すことができるようにする必要がありますか?」 |
| 有効期限のない JWT | トークン窃盗 | 「このトークンが盗まれた場合、どうなりますか?」 |
| URL 内の ID | IDOR | 「ユーザー A は ID を変更することでユーザー B のデータにアクセスできますか?」 |
デプロイ前のセキュリティチェックリスト
- [ ] すべてのシークレットは環境変数に格納されている
- [ ] HTTPS が強制されている
- [ ] すべてのエンドポイントで入力検証が行われている
- [ ] SQL/NoSQL インジェクションが防止されている (パラメータ化されたクエリ)
- [ ] XSS が防止されている (出力エンコーディング)
- [ ] CSRF 保護が有効になっている
- [ ] 認証エンドポイントにレート制限が設定されている
- [ ] 機密データがレスポンスから除外されている
- [ ] すべての保護されたルートで認可チェックが行われている
- [ ] セキュリティヘッダーが設定されている (helmet.js または同等のもの)
絶対にやってはいけないこと
| アクション | 理由 |
|---|---|
| パスワードを平文で保存する | 1 回の侵害ですべてのユーザーが危険にさらされる |
| コードにシークレットを記述する | Git の履歴は永遠に残る |
| クライアントサイドの検証のみを信頼する | 誰でもクライアントをバイパスできる |
| データベースオブジェクト全体を返す | 内部フィールドが公開される |
| 機密データをログに記録する | ログも侵害される可能性がある |
パスワードに md5 または sha1 を使用する |
暗号学的に脆弱である |
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Security Fundamentals Review
"Security is not a feature. It's a foundation. Build on sand, and the house falls."
When to Apply
Activate this skill when reviewing:
- Authentication/login flows
- Authorization checks
- User input handling
- Database queries
- File uploads
- API endpoints
- Data exposure in responses
Review Checklist
Input Validation (NEVER Trust the Client)
- [ ] All inputs validated: Is every user input checked before use?
- [ ] Server-side validation: Is validation done on the server, not just client?
- [ ] Type checking: Are expected types enforced?
- [ ] Length limits: Are string lengths bounded?
- [ ] Whitelist over blacklist: Are allowed values explicitly defined?
Authentication
- [ ] Password hashing: Are passwords hashed (bcrypt, argon2), not encrypted?
- [ ] No plaintext secrets: Are secrets in env vars, not code?
- [ ] Token expiry: Do JWTs/sessions have reasonable expiration?
- [ ] Secure transmission: Is HTTPS enforced?
Authorization
- [ ] Ownership checks: Can users only access THEIR data?
- [ ] Role verification: Are admin routes protected by role checks?
- [ ] No client-side auth: Is authorization enforced server-side?
Data Exposure
- [ ] Minimal response: Does the API return only necessary fields?
- [ ] No sensitive data in URLs: Are tokens/IDs not in query strings?
- [ ] No sensitive data in logs: Are passwords/tokens excluded from logs?
OWASP Top 10 Quick Check
1. Injection (SQL, NoSQL, Command)
❌ db.query(`SELECT * FROM users WHERE id = ${userId}`);
✅ db.query('SELECT * FROM users WHERE id = ?', [userId]);
2. Broken Authentication
❌ if (req.headers.admin === 'true') { /* allow admin */ }
✅ const user = await verifyToken(req.headers.authorization);
if (user.role !== 'admin') throw new ForbiddenError();
3. Sensitive Data Exposure
❌ res.json({ user: { ...user, password, ssn } });
✅ res.json({ user: { id: user.id, name: user.name } });
4. Broken Access Control
❌ app.get('/users/:id', async (req, res) => {
const user = await User.findById(req.params.id);
res.json(user);
});
✅ app.get('/users/:id', async (req, res) => {
const user = await User.findById(req.params.id);
if (user.id !== req.user.id && req.user.role !== 'admin') {
throw new ForbiddenError();
}
res.json(user);
});
5. Security Misconfiguration
❌ CORS: origin: '*'
❌ Detailed error messages in production
❌ Debug mode enabled in production
✅ CORS: origin: process.env.ALLOWED_ORIGINS
✅ Generic error messages to clients
✅ Debug mode disabled in production
6. Cross-Site Scripting (XSS)
❌ element.innerHTML = userInput;
✅ element.textContent = userInput;
✅ DOMPurify.sanitize(userInput);
Socratic Questions
Ask the junior these questions instead of giving answers:
- Trust: "What stops a malicious user from sending anything they want here?"
- Ownership: "How do you know this user owns this resource?"
- Exposure: "What's the worst thing that could happen if this endpoint is exposed?"
- Secrets: "If I
git clonethis repo, what secrets would I see?" - Injection: "What if someone sends
'; DROP TABLE users; --as input?"
Red Flags to Call Out
| Flag | Risk | Question |
|---|---|---|
| String concatenation in queries | SQL Injection | "Can this input contain SQL?" |
eval() or new Function() |
Code Injection | "Why is dynamic code execution needed?" |
innerHTML with user data |
XSS | "What if the user includes <script>?" |
| Passwords in logs | Data Leak | "Who can see these logs?" |
| No rate limiting on auth | Brute Force | "What stops someone from trying every password?" |
CORS: * |
Security Bypass | "Should any website be able to call this API?" |
| JWT with no expiry | Token Theft | "What happens if this token is stolen?" |
| IDs in URLs | IDOR | "Can user A access user B's data by changing the ID?" |
Security Checklist Before Deploy
- [ ] All secrets in environment variables
- [ ] HTTPS enforced
- [ ] Input validation on all endpoints
- [ ] SQL/NoSQL injection prevented (parameterized queries)
- [ ] XSS prevented (output encoding)
- [ ] CSRF protection enabled
- [ ] Rate limiting on auth endpoints
- [ ] Sensitive data excluded from responses
- [ ] Authorization checks on every protected route
- [ ] Security headers set (helmet.js or equivalent)
Never Do This
| Action | Why |
|---|---|
| Store passwords in plaintext | One breach exposes all users |
| Put secrets in code | Git history is forever |
| Trust client-side validation only | Anyone can bypass the client |
| Return full database objects | Exposes internal fields |
| Log sensitive data | Logs get compromised too |
Use md5 or sha1 for passwords |
Cryptographically broken |