Skip to content
Back to skills

Collection

ASecurity

Webアプリケーションセキュリティヘッダーの設定パターン。 📚 リソース参照: このスキルには以下のリソースが含まれています。 必要に応じて該当するリソースを参照してください: - `.claude/skills/security-headers/resources/csp-configuration.md`: Csp Configurationリソース - `.claude/skills/security-headers/resources/csrf-prevention.md`: Csrf Preventionリソース - `.claude/skills/security-headers/templates/nextjs-security-headers-template.js`: Nextjs Security Headersテンプレート - `.claude/skills/security-headers/scripts/validate-security-headers.mjs`: Validate Security Headersスクリプト

  • 24 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
developmentjavascripttypescriptjavabashnextjsnodesecurity

Works with

  • cli

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add mattnigh/skills_collection --skill collection --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Collection?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Collection
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mattnigh-collection-310514ae/badge)](https://www.skillsdirectory.com/skills/mattnigh-collection-310514ae)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: .claude/skills/security-headers/SKILL.md
description: |
  Webアプリケーションセキュリティヘッダーの設定パターン。

  📚 リソース参照:
  このスキルには以下のリソースが含まれています。
  必要に応じて該当するリソースを参照してください:

  - `.claude/skills/security-headers/resources/csp-configuration.md`: Csp Configurationリソース
  - `.claude/skills/security-headers/resources/csrf-prevention.md`: Csrf Preventionリソース

  - `.claude/skills/security-headers/templates/nextjs-security-headers-template.js`: Nextjs Security Headersテンプレート

  - `.claude/skills/security-headers/scripts/validate-security-headers.mjs`: Validate Security Headersスクリプト

version: 1.0.0
---

# Security Headers

## スキル概要

**コアドメイン**:

- セキュリティヘッダー設定
- Content Security Policy(CSP)
- CSRF/XSS/Clickjacking 対策

## 必須セキュリティヘッダー

### 1. Content-Security-Policy(CSP)

**目的**: XSS 攻撃とデータインジェクション攻撃を防止

**基本設定**:

```typescript
const cspHeader = `
  default-src 'self';
  script-src 'self' 'unsafe-inline' 'unsafe-eval';
  style-src 'self' 'unsafe-inline';
  img-src 'self' data: https:;
  font-src 'self';
  connect-src 'self';
  frame-ancestors 'none';
`
  .replace(/\s{2,}/g, " ")
  .trim();
```

**推奨設定(厳格)**:

```typescript
const strictCspHeader = `
  default-src 'self';
  script-src 'self';
  style-src 'self';
  img-src 'self' data:;
  font-src 'self';
  connect-src 'self';
  frame-ancestors 'none';
  base-uri 'self';
  form-action 'self';
`
  .replace(/\s{2,}/g, " ")
  .trim();
```

### 2. X-Frame-Options

**目的**: Clickjacking 攻撃を防止

```typescript
'X-Frame-Options': 'DENY'
// または
'X-Frame-Options': 'SAMEORIGIN'
```

### 3. X-Content-Type-Options

**目的**: MIME タイプスニッフィング攻撃を防止

```typescript
'X-Content-Type-Options': 'nosniff'
```

### 4. Strict-Transport-Security(HSTS)

**目的**: HTTPS 接続を強制

```typescript
'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
```

### 5. Referrer-Policy

**目的**: リファラー情報の制御

```typescript
'Referrer-Policy': 'strict-origin-when-cross-origin'
```

### 6. Permissions-Policy

**目的**: ブラウザ機能へのアクセス制御

```typescript
'Permissions-Policy': 'camera=(), microphone=(), geolocation=()'
```

## Next.js での設定

### next.config.js

```javascript
const nextConfig = {
  async headers() {
    return [
      {
        source: "/:path*",
        headers: [
          {
            key: "Content-Security-Policy",
            value: cspHeader,
          },
          {
            key: "X-Frame-Options",
            value: "DENY",
          },
          {
            key: "X-Content-Type-Options",
            value: "nosniff",
          },
          {
            key: "Strict-Transport-Security",
            value: "max-age=31536000; includeSubDomains",
          },
          {
            key: "Referrer-Policy",
            value: "strict-origin-when-cross-origin",
          },
          {
            key: "Permissions-Policy",
            value: "camera=(), microphone=(), geolocation=()",
          },
        ],
      },
    ];
  },
};
```

## CSRF 対策

### SameSite Cookie 属性

```typescript
cookies().set("session_token", token, {
  sameSite: "lax", // またはstrict
});
```

### CSRF トークン検証(追加保護)

```typescript
// ミドルウェア
export async function verifyCsrfToken(request: Request): Promise<boolean> {
  if (request.method === "GET" || request.method === "HEAD") {
    return true; // 読み取りのみ操作はスキップ
  }

  const token = request.headers.get("X-CSRF-Token");
  const sessionToken = cookies().get("csrf_token")?.value;

  return token === sessionToken;
}
```

## リソース参照

```bash
cat .claude/skills/security-headers/resources/csp-configuration.md
cat .claude/skills/security-headers/resources/csrf-prevention.md
```

## テンプレート参照

```bash
cat .claude/skills/security-headers/templates/nextjs-security-headers-template.js
```

## スクリプト実行

```bash
node .claude/skills/security-headers/scripts/validate-security-headers.mjs next.config.js
```

## 判断基準

- [ ] すべての OWASP 推奨ヘッダーが設定されているか?
- [ ] CSP はアプリケーション要件と互換性があるか?
- [ ] CSRF 対策は多層化されているか?
- [ ] Cookie 属性は適切か(HttpOnly、Secure、SameSite)?

## ベストプラクティス

1. **CSP 厳格化**: 'unsafe-inline'/'unsafe-eval'を避ける
2. **HSTS 有効化**: HTTPS 強制
3. **SameSite Cookie**: Lax/Strict 推奨
4. **多層 CSRF 対策**: SameSite + CSRF トークン

## バージョン履歴

| バージョン | 日付       | 変更内容                                        |
| ---------- | ---------- | ----------------------------------------------- |
| 1.0.0      | 2025-11-26 | 初版リリース - セキュリティヘッダー設定パターン |

Files in this skill

  • 0Chan-smc__claude-code-workflow-lab__claude__skills__frontend-dev-guidelines__SKILL.md15.1 KB
  • 17hz__nextjs-template__claude__skills__example-skill__SKILL.md316 B
  • 1ambda__dataops-platform__claude__skills__context-synthesis__SKILL.md3.5 KB
  • 1natsu172__dotfiles__claude__skills__git-analysis__SKILL.md5.4 KB
  • 1natsu172__dotfiles__claude__skills__github-pr-best-practices__SKILL.md7.7 KB
  • 23Maestro__prospect-pipeline__claude__skills__npid-fastapi-skill.md26.1 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-code-javascript__SKILL.md15.7 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-code-python__SKILL.md17.5 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-expression-syntax__SKILL.md9.4 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-mcp-tools-expert__SKILL.md12.5 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-node-configuration__SKILL.md16.6 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-workflow-patterns__SKILL.md11.2 KB
  • 3x-Projetos__claude-memory-framework__claude__skills__scientist__SKILL.md14.8 KB
  • 5MinFutures__futures-arena__claude__skills__migration-tracker__SKILL.md16.2 KB
  • 5MinFutures__futures-arena__claude__skills__planning-guidelines__SKILL.md11.8 KB
  • 92Bilal26__TaskPilotAI__claude__skills__assessment-builder__SKILL.md17.5 KB
  • 92Bilal26__TaskPilotAI__claude__skills__book-scaffolding__SKILL.md19.1 KB
  • 92Bilal26__TaskPilotAI__claude__skills__code-validation-sandbox__SKILL.md6.2 KB
  • 92Bilal26__TaskPilotAI__claude__skills__exercise-designer__SKILL.md18.1 KB
  • 92Bilal26__TaskPilotAI__claude__skills__learning-objectives__SKILL.md24.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.