Client Side Securityのロゴ

Client Side Security

組織
RedHatProductSecurity
client-side-security

Apply when reviewing or writing browser-facing code that handles user input, renders HTML, sets cookies, or loads third-party scripts. Covers XSS, CSRF, CSP, clickjacking, XS-Leaks, and HTTP security headers.

概要

公開者RedHatProductSecurity
リポジトリprodsec-skills
スキル名client-side-security
スター
56
フォーク
9
同梱ファイル
指示のみ
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    RedHatProductSecurityがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルClient Side SecurityをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/RedHatProductSecurity/prodsec-skills/tree/main/module/skills/client-side-security
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/RedHatProductSecurity/prodsec-skills.git /tmp/prodsec-skills
mkdir -p .claude/skills
cp -r /tmp/prodsec-skills/module/skills/client-side-security .claude/skills/client-side-security
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでClient Side Securityを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にClient Side Securityを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Client Side Securityは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Client-Side Web Security

Protect browser clients against code injection, request forgery, UI redress, cross-site leaks, and unsafe third-party scripts with layered, context-aware controls.

XSS Prevention (Context-Aware)

  • HTML context: prefer textContent. If HTML is required, sanitize with a vetted library (e.g., DOMPurify) and strict allow-lists.
  • Attribute context: always quote attributes and encode values.
  • JavaScript context: do not build JS from untrusted strings; avoid inline event handlers; use addEventListener.
  • URL context: validate protocol/domain and encode; block javascript: and data URLs where inappropriate.
  • Redirects/forwards: never use user input directly for destinations; use server-side mapping (ID to URL) or validate against trusted domain allow-lists.
  • CSS context: allow-list values; never inject raw style text from users.

Example sanitization:

javascript
const clean = DOMPurify.sanitize(userHtml, {
  ALLOWED_TAGS: ['b','i','p','a','ul','li'],
  ALLOWED_ATTR: ['href','target','rel'],
  ALLOW_DATA_ATTR: false
});

DOM-based XSS and Dangerous Sinks

  • Prohibit innerHTML, outerHTML, document.write with untrusted data.
  • Prohibit eval, new Function, string-based setTimeout/setInterval.
  • Validate and encode data before assigning to location or event handler properties.
  • Use strict mode and explicit variable declarations to prevent global namespace pollution from DOM clobbering.
  • Adopt Trusted Types and enforce strict CSP to prevent DOM sink exploitation.

Trusted Types + CSP:

http
Content-Security-Policy: script-src 'self' 'nonce-{random}'; object-src 'none'; base-uri 'self'; require-trusted-types-for 'script'

Content Security Policy (CSP)

  • Prefer nonce-based or hash-based CSP over domain allow-lists.
  • Start with Report-Only mode; collect violations; then enforce.
  • Baseline to aim for: default-src 'self'; style-src 'self' 'unsafe-inline'; frame-ancestors 'self'; form-action 'self'; object-src 'none'; base-uri 'none'; upgrade-insecure-requests.

CSRF Defense

  • Fix XSS first; then layer CSRF defenses.
  • Use framework-native CSRF protections and synchronizer tokens on all state-changing requests.
  • Cookie settings: SameSite=Lax or Strict; sessions Secure and HttpOnly; use __Host- prefix when possible.
  • Validate Origin/Referer; require custom headers for API mutations in SPA token models.
  • Never use GET for state changes; validate tokens on POST/PUT/DELETE/PATCH only. Enforce HTTPS for all token transmission.

Clickjacking Defense

  • Primary: Content-Security-Policy: frame-ancestors 'none' or a specific allow-list.
  • Fallback for legacy browsers: X-Frame-Options: DENY or SAMEORIGIN.
  • Consider UX confirmations for sensitive actions when framing is required.

Cross-Site Leaks (XS-Leaks) Controls

  • Set SameSite=Strict cookies for sensitive actions and SameSite=Lax as the default for all other cookies.
  • Adopt Fetch Metadata protections to block suspicious cross-site requests.
  • Isolate browsing contexts: COOP/COEP and CORP where applicable.
  • Disable caching and add user-unique tokens for sensitive responses to prevent cache probing.

Third-Party JavaScript

  • Minimize and isolate: prefer sandboxed iframes with sandbox and postMessage origin checks.
  • Use Subresource Integrity (SRI) for external scripts and monitor for changes.
  • Provide a first-party, sanitized data layer; deny direct DOM access from tags unless a specific integration requires it.
  • Govern via tag manager controls and vendor contracts; keep libraries updated.

SRI example:

html
<script src="https://cdn.vendor.com/app.js"
  integrity="sha384-..." crossorigin="anonymous"></script>

HTML5, CORS, WebSockets, Storage

  • postMessage: always specify exact target origin; verify event.origin on receive.
  • CORS: avoid *; allow-list origins; validate preflights; do not rely on CORS for authorization.
  • WebSockets: require wss://, origin checks, auth, message size limits, and safe JSON parsing.
  • Client storage: never store secrets in localStorage/sessionStorage; prefer HttpOnly cookies; if unavoidable, isolate via Web Workers.
  • Links: add rel="noopener noreferrer" to external target=_blank links.

HTTP Security Headers

  • HSTS: enforce HTTPS everywhere.
  • X-Content-Type-Options: nosniff.
  • Referrer-Policy and Permissions-Policy: restrict sensitive signals and capabilities.

AJAX and Safe DOM APIs

  • Avoid dynamic code execution; use function callbacks, not strings.
  • Build JSON with JSON.stringify; never via string concatenation.
  • Prefer creating elements and setting textContent/safe attributes over raw HTML insertion.

Implementation Checklist

  • Contextual encoding/sanitization for every sink; no dangerous APIs without guards
  • Strict CSP with nonces and Trusted Types; violations monitored
  • CSRF tokens on all state-changing requests; secure cookie attributes
  • Frame protections set; XS-Leak mitigations enabled (Fetch Metadata, COOP/COEP/CORP)
  • Third-party JS isolated with SRI and sandbox; vetted data layer only
  • HTML5/CORS/WebSocket usage hardened; no secrets in web storage
  • Security headers enabled and validated

Test Plan

  • Automated checks for dangerous DOM/API patterns.
  • E2E tests for CSRF and clickjacking; CSP report monitoring.
  • Manual probes for XS-Leaks (frame count, timing, cache) and open redirect behavior.

よくある質問

AIスキル「Client Side Security」では何ができますか?

Apply when reviewing or writing browser-facing code that handles user input, renders HTML, sets cookies, or loads third-party scripts. Covers XSS, CSRF, CSP, clickjacking, XS-Leaks, and HTTP security headers.

TypingMindでClient Side Securityを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Client Side Securityはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにClient Side Securityをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/RedHatProductSecurity/prodsec-skills/tree/main/module/skills/client-side-securityを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Client Side Securityを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Client Side Securityは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもClient Side Securityを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Client Side Security」は無料ですか?

はい。RedHatProductSecurityがGitHubでApache-2.0ライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇