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

subresource-integrity

できること

このスキルは、ウェブページの外部のスクリプトとスタイルを確認し、integrity ハッシュを追加します。自分のサーバー以外からコードを読み込む開発者向けです。

使う場面

  • ✓CDN から JavaScript や CSS を読み込んでいて、integrity 属性がないとき。
  • ✓外部のスクリプトやスタイルのタグを含む HTML テンプレートをレビューしているとき。
  • ✓CDN が侵害された場合に、訪問者を守る方法を知りたいとき。

スキルのリンク

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/subresource-integrity/SKILL.md

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

使い方

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

貼り付け用メッセージ

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

AIへの頼み方の例

“私のサイトは CDN からスクリプトを読み込んでいます。誰かが悪意のあるコードに差し替えないようにするには、どうすればよいですか。”

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

仕組み

エージェントは、フィンガープリントがない外部ファイルを見つけ、ハッシュを追加します。するとブラウザは、ダウンロードされたファイルとハッシュを比べ、一致しないファイルの実行を止めます。

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

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

Add Subresource Integrity to external scripts

When you load JavaScript from a CDN, you're trusting that CDN completely — if it's compromised, attackers can serve malicious JavaScript to all your users. SRI adds a cryptographic hash to the tag; the browser refuses to execute the script if the hash doesn't match the downloaded content, protecting users even if the CDN is compromised or the URL is hijacked.

Quick Reference

  • Add integrity="sha384-..." to <script> and <link> tags loading from CDNs
  • Always pair integrity with crossorigin="anonymous"
  • Generate hashes with openssl or online tools — CDN providers usually supply them
  • SRI blocks execution if the file hash doesn't match, preventing CDN compromise attacks

Check

Find all external <script> and <link rel=stylesheet> tags in this HTML that load from CDNs and don't have integrity attributes. List each one.

Fix

Add appropriate integrity and crossorigin attributes to external CDN resources. Generate the SHA-384 hashes for each resource.

Explain

Explain Subresource Integrity, how it protects against CDN compromise, how to generate SRI hashes, and its limitations.

Code Review

Review templates, server-rendered HTML, and shared components that output markup related to Add Subresource Integrity to external scripts. Flag exact elements, attributes, and routes where the rendered HTML violates the rule.


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

Rule page: https://frontendchecklist.io/rules/html/subresource-integrity

よくある質問

サブリソース整合性のハッシュとは何ですか?

ファイルの内容を正確に表す短いコードです。ブラウザは、実行前にダウンロードされたファイルとこれを比べます。

自分のサーバーでホストしているファイルにも必要ですか?

このスキルは外部の CDN のファイルを主な対象としています。自分のサイトでホストしているファイルは、ここでの主な対象ではありません。

この方法の限界についても説明されていますか?

はい。このスキルは、この方法が何を守り、何を守らないかも説明しています。

詳細

作者による元の説明

Use when reviewing templates, rendered HTML, or shared components related to Add Subresource Integrity to external scripts. Validate the final browser-facing markup, not just the source framework abstraction.

repo: thedaviddias/Front-End-Checklist

人気

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

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

0

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

コメント

  • …

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

似ているスキル