Skip to main content
security-review Use this skill when adding authentication, handling user input, working with secrets, creating API endpoints, or implementing payment/sensitive features. Provides comprehensive security checklist and patterns.
インストールへ移動 Skills Marketplace コミュニティが作成したAIスキルを発見・探索
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
直接コマンドでは確認用 Prompt が省略されます。実行前にソースを確認してください。
npx skills add https://github.com/linnefromice/claude-code-workspace --skill security-reviewコマンドは1行のまま表示されます。コピー前に横へスクロールして全体を確認してください。
ローカルで確認しますか?SkillsMP が現在取得できるファイルをダウンロードできます。
Zipをダウンロード ダウンロード中... cloud-infrastructure-security.md 12.1 KB name security-review description Use this skill when adding authentication, handling user input, working with secrets, creating API endpoints, or implementing payment/sensitive features. Provides comprehensive security checklist and patterns. origin ECC
セキュリティレビュースキル
このスキルはすべてのコードがセキュリティベストプラクティスに従い、潜在的な脆弱性を特定することを保証します。
起動条件
認証や認可を実装する時
ユーザー入力やファイルアップロードを処理する時
新しい API エンドポイントを作成する時
シークレットや認証情報を扱う時
決済機能を実装する時
機密データを保存または送信する時
サードパーティAPIを統合する時
セキュリティチェックリスト
1. シークレット管理
❌ 絶対にしないこと
const apiKey = "sk-proj-xxxxx"
const dbPassword = "password123"
✅ 常にすること
const apiKey = process.env .OPENAI_API_KEY
const dbUrl = process.env .DATABASE_URL
if (!apiKey) {
throw new Error ('OPENAI_API_KEY not configured' )
}
確認手順
2. 入力バリデーション
ユーザー入力は常にバリデーション import { z } from 'zod'
const CreateUserSchema = z.object ({
email : z.string ().email (),
name : z.string ().min (1 ).max (100 ),
age : z.number ().int ().min (0 ).max (150 )
})
export async function createUser (input : unknown ) {
try {
const validated = CreateUserSchema .parse (input)
return await db.users .create (validated)
} catch (error) {
if (error instanceof z.ZodError ) {
return { success : false , errors : error.errors }
}
throw error
}
}
ファイルアップロードバリデーション function validateFileUpload (file : File ) {
const maxSize = 5 * 1024 * 1024
if (file.size > maxSize) {
throw new Error ('File too large (max 5MB)' )
}
const allowedTypes = ['image/jpeg' , 'image/png' , 'image/gif' ]
if (!allowedTypes.includes (file.type )) {
throw new Error ('Invalid file type' )
}
const allowedExtensions = ['.jpg' , '.jpeg' , '.png' , '.gif' ]
const extension = file.name .toLowerCase ().match (/\.[^.]+$/ )?.[0 ]
if (!extension || !allowedExtensions.includes (extension)) {
throw new Error ('Invalid file extension' )
}
return true
}
確認手順
3. SQLインジェクション防止
❌ 絶対にSQLを連結しない
const query = `SELECT * FROM users WHERE email = '${userEmail} '`
await db.query (query)
✅ 常にパラメータ化クエリを使用
const { data } = await supabase
.from ('users' )
.select ('*' )
.eq ('email' , userEmail)
await db.query (
'SELECT * FROM users WHERE email = $1' ,
[userEmail]
)
確認手順
4. 認証と認可
JWTトークン処理
localStorage .setItem ('token' , token)
res.setHeader ('Set-Cookie' ,
`token=${token} ; HttpOnly; Secure; SameSite=Strict; Max-Age=3600` )
認可チェック export async function deleteUser (userId : string , requesterId : string ) {
const requester = await db.users .findUnique ({
where : { id : requesterId }
})
if (requester.role !== 'admin' ) {
return NextResponse .json (
{ error : 'Unauthorized' },
{ status : 403 }
)
}
await db.users .delete ({ where : { id : userId } })
}
Row Level Security(Supabase)
ALTER TABLE users ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Users view own data"
ON users FOR SELECT
USING (auth.uid() = id);
CREATE POLICY "Users update own data"
ON users FOR UPDATE
USING (auth.uid() = id);
確認手順
5. XSS防止
HTMLをサニタイズ import DOMPurify from 'isomorphic-dompurify'
function renderUserContent (html : string ) {
const clean = DOMPurify .sanitize (html, {
ALLOWED_TAGS : ['b' , 'i' , 'em' , 'strong' , 'p' ],
ALLOWED_ATTR : []
})
return <div dangerouslySetInnerHTML ={{ __html: clean }} />
}
Content Security Policy
const securityHeaders = [
{
key : 'Content-Security-Policy' ,
value : `
default-src 'self';
script-src 'self' 'unsafe-eval' 'unsafe-inline';
style-src 'self' 'unsafe-inline';
img-src 'self' data: https:;
font-src 'self';
connect-src 'self' https://api.example.com;
` .replace (/\s{2,}/g , ' ' ).trim ()
}
]
確認手順
6. CSRF保護
CSRFトークン import { csrf } from '@/lib/csrf'
export async function POST (request : Request ) {
const token = request.headers .get ('X-CSRF-Token' )
if (!csrf.verify (token)) {
return NextResponse .json (
{ error : 'Invalid CSRF token' },
{ status : 403 }
)
}
}
SameSiteクッキー res.setHeader ('Set-Cookie' ,
`session=${sessionId} ; HttpOnly; Secure; SameSite=Strict` )
確認手順
7. レート制限
APIレート制限 import rateLimit from 'express-rate-limit'
const limiter = rateLimit ({
windowMs : 15 * 60 * 1000 ,
max : 100 ,
message : 'Too many requests'
})
app.use ('/api/' , limiter)
コストの高い操作
const searchLimiter = rateLimit ({
windowMs : 60 * 1000 ,
max : 10 ,
message : 'Too many search requests'
})
app.use ('/api/search' , searchLimiter)
確認手順
8. 機密データ露出
ロギング
console .log ('User login:' , { email, password })
console .log ('Payment:' , { cardNumber, cvv })
console .log ('User login:' , { email, userId })
console .log ('Payment:' , { last4 : card.last4 , userId })
エラーメッセージ
catch (error) {
return NextResponse .json (
{ error : error.message , stack : error.stack },
{ status : 500 }
)
}
catch (error) {
console .error ('Internal error:' , error)
return NextResponse .json (
{ error : 'An error occurred. Please try again.' },
{ status : 500 }
)
}
確認手順
9. ブロックチェーンセキュリティ(Solana)
ウォレット検証 import { verify } from '@solana/web3.js'
async function verifyWalletOwnership (
publicKey : string ,
signature : string ,
message : string
) {
try {
const isValid = verify (
Buffer .from (message),
Buffer .from (signature, 'base64' ),
Buffer .from (publicKey, 'base64' )
)
return isValid
} catch (error) {
return false
}
}
確認手順
10. 依存関係セキュリティ
定期的な更新
npm audit
npm audit fix
npm update
npm outdated
ロックファイル
git add package-lock.json
npm ci
確認手順
デプロイ前セキュリティチェックリスト
リソース
覚えておくこと : セキュリティはオプションではない。1つの脆弱性がプラットフォーム全体を危険にさらす可能性がある。迷ったら、慎重な側に倒す。