本文へスキップ
Skillpedia
セキュリティ75k · #2793

cross-origin-security

できること

このスキルは、サイトがオリジンをまたぐリクエストやメッセージをどう扱うかを確認します。攻撃者がデータを読んだり、利用者の代わりに動いたりするのを止めたい開発者向けです。

使う場面

  • ✓サイトが、他のウィンドウやiframeからのメッセージを受け取っているとき。
  • ✓CORSの設定が、ログイン後のルートであらゆるオリジンを許可しているとき。
  • ✓リダイレクトのパラメーターで、利用者を任意の外部のアドレスに送れるとき。

スキルのリンク

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/cross-origin-security/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/cross-origin-security/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“他のサイトがユーザーのデータを読めてしまうおそれがないか、私のサイトのメッセージのリスナーとCORSの設定を確認してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、メッセージのリスナーが各メッセージの送信元を確認しているか、認証されたルートでCORSが制限されているか、リダイレクトが承認された先にしか行かないかを確認します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Handle cross-origin requests securely

The Same-Origin Policy is the browser's primary defense against malicious sites stealing data or performing actions on behalf of your users. Misconfiguring CORS or failing to validate postMessage origins can allow attackers to bypass this protection — reading private data, submitting forms as users, or injecting content into your pages.

Quick Reference

  • Always verify event.origin before processing postMessage data
  • Never set Access-Control-Allow-Origin: * for authenticated endpoints
  • Validate and sanitize all data received from cross-origin messages
  • Use SameSite cookies to prevent CSRF from cross-origin requests
  • Reject unvalidated redirect targets such as next, redirect, or callbackUrl

Check

Check this code for insecure cross-origin patterns: missing origin validation in postMessage listeners, overly permissive CORS settings, and missing CSRF protections. Flag redirect parameters that accept arbitrary external URLs.

Fix

Add origin validation to postMessage listeners and review CORS configuration to ensure it's not overly permissive for authenticated routes. Reject or allow-list untrusted redirect destinations before navigating.

Explain

Explain the Same-Origin Policy, how CORS works, and how to securely use postMessage for cross-origin communication.

Code Review

Review scripts, client components, and browser execution paths related to Handle cross-origin requests securely. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser. Check login, logout, SSO, and return-to flows for open redirects.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/cross-origin-security

よくある質問

同一オリジンポリシーとは何ですか?

悪意のあるサイトが利用者のデータを読んだり、それに作用したりすることに対する、ブラウザの主要な防御だと、このスキルは説明しています。

メッセージについて、エージェントは何を確認しますか?

データを使う前に、メッセージの送信元のオリジンが確認されていることです。

リダイレクトのパラメーターは、なぜ危険ですか?

確認または承認されていない限り、利用者を任意の外部サイトに送るおそれがあると、このスキルは説明しています。

詳細

作者による元の説明

Use when reviewing scripts, client components, bundles, or runtime behavior related to Handle cross-origin requests securely. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

人気

GitHubのスター
75k
ランキング
#2793
ライセンス
MIT
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル