/
439.txt
211 lines (149 loc) · 9.49 KB
/
439.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
[18] [[HTTP]] の[[ダイジェスト認証]]の [[nonce]] は、
次の場所で使われます。
[FIG(short list)[
- [CODE(HTTP)@en[[[nonce]]]] [[引数]] ([CODE(ABNF)@en[[[auth-param]]]])
- [CODE(HTTP)@en[[[cnonce]]]] [[引数]]
- [CODE(HTTP)@en[[[nextnonce]]]] [[引数]]
]FIG]
[19] [[HTML]] の [[nonce]] は、次の場所で使われます。
[FIG(short list)[
- [CODE(HTTP)@en[[[nonce]]]] [[引数]] ([[CSP]])
- [CODE(HTMLa)@en[[[nonce]]]] [[属性]]
]FIG]
* 仕様書
[REFS[
- [3] [CITE@en[RFC 7616 - HTTP Digest Access Authentication]] ([TIME[2015-11-10 07:05:08 +09:00]] 版) <https://tools.ietf.org/html/rfc7616#section-3.3>
- [22] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2016-02-16 01:30:20 +09:00]] 版) <https://html.spec.whatwg.org/#the-script-element>
-- [24] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2016-02-21 07:50:23 +09:00]] 版) <https://html.spec.whatwg.org/#attr-script-nonce>
- [32] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2016-04-07 05:08:43 +09:00]] 版) <https://html.spec.whatwg.org/#concept-module-script-nonce>
]REFS]
* nonce (CSP、HTML)
** 意味
[25] [CODE(HTMLa)@en[[[nonce]]]] [[属性]]は、 [[CSP]]
で[[スクリプト]]を実行するかどうか決定するために使う[RUBYB[暗号学的]@en[cryptographic]]
[[nonce]] (number used once) を指定するものです [SRC[>>24]]。
** 属性値
[26] [[属性値]]は、[[テキスト]]です [SRC[>>24]]。
** 文脈
[36] [CODE(HTMLa)@en[nonce]] [[属性]]は、
[CODE(HTMLe)@en[script]] [[要素]]と [CODE(HTMLe)@en[link]] [[要素]]で指定できます。
[23] [CODE(HTMLe)@en[[[script]]]] [[要素]]の種別が[[データブロック]]の時は、
[CODE(HTMLa)@en[[[nonce]]]] [[属性]]を使っては[['''なりません''']] [SRC[>>22]]。
[31] [[スクリプトfetchオプション群]]は、[DFN[[F[[RUBYB[[[暗号学的nonce]]]@en[cryptographic nonce]]]]]]を持ちます [SRC[>>32]]。
これは[[スクリプトのfetch]]で使われます。
** 処理
[27] [CODE(HTMLe)@en[[[script]]]] 参照。
[28] なお、初回処理時の値が使われるので、動的に変更しても、意味を持ちません [SRC[>>24]]。
** [CODE(DOMi)@en[HTMLScriptElement]] インターフェイス, [CODE(DOMi)@en[HTMLLinkElement]] インターフェイス [CODE(DOMa)@en[nonce]] 属性
[29] [CODE(DOMi)@en[HTMLScriptElement]] [[インターフェイス]],
[CODE(DOMi)@en[HTMLLinkElement]] [[インターフェイス]]の
[DFN[[CODE(DOMa)@en[[[nonce]]]]]] [[IDL属性]]は、
[CODE(HTMLa)@en[[[nonce]]]] [[内容属性]]を[[反映]]しなければ[MUST[なりません]]
[SRC[>>22]]。これは[[文字列]]として[[反映]]するものです。
** 歴史
[5] [CITE@en[Bug 26081 – Consider defining or mentioning the nonce attribute]]
( ([TIME[2014-06-14 02:59:38 +09:00]] 版))
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=26081>
[2] [CITE@en[Merge pull request #171 from fmarier/csp2-remove-base64url · b4ab556 · w3c/webappsec]]
([TIME[2015-02-11 16:36:15 +09:00]] 版)
<https://github.com/w3c/webappsec/commit/b4ab55679f2261b05db896bd9399f25bc1314787>
[7] [CITE@en[Call out to CSP's inline element hooks · whatwg/html@ee3486e]]
([TIME[2015-11-08 16:32:08 +09:00]] 版)
<https://github.com/whatwg/html/commit/ee3486eb129bc350b5ca684d0c91dff23453ac1a>
[8] [CITE@en[Define script@nonce and style@nonce attributes · whatwg/html@882803c]]
([TIME[2015-11-12 00:04:23 +09:00]] 版)
<https://github.com/whatwg/html/commit/882803c4cc8fba2fa5472b76f628d95cc82c421d>
[9] [CITE@en[Accept base64url characters in nonces and hashes. · w3c/webappsec-csp@b4c5543]]
([TIME[2015-11-20 18:45:10 +09:00]] 版)
<https://github.com/w3c/webappsec-csp/commit/b4c5543c350417eb24f1f33247defe20e3430643>
* [CODE(HTTP)@en[nonce]] 引数 (auth-param)
** 意味
[10] [[nonce]] は、 [CODE(HTTP)[[[401]]]] [[応答]]の作成の度に毎回固有に[[生成]]するべき、
[[サーバー]]が指定する[[文字列]]です。 [SRC[>>3]]
[14] [[nonce]] は[[クライアント]]にとっては[[不透明]]です [SRC[>>3]]。
** 構文
[17] [CODE(ABNF)@en[[[auth-param]]]]
の[[引用文字列]]構文を使わなければ[['''なりません''']] [SRC[>>3]]。
[11] [[nonce]] は、 [[Base64]] や[[十六進数]]で表記した[[文字列]]とすると[RUBYB[いいです]@en[advise]]。
[SRC[>>3]]
[12] 具体的な内容は、[[実装依存]]です [SRC[>>3]]。
** 文脈
[15] [CODE(HTTP)@en[[[nonce]]]] [[引数]]は、[[ダイジェスト認証]]の [[challenge]]
に指定できます [SRC[>>3]]。
[20] [CODE(HTTP)@en[[[nonce]]]] [[引数]]は必須です。
;; [21] [[RFC 2617]] 時代は、 [[ABNF]] [SRC[>>4]]
で必須であることを主張しようとした形跡があります。 [[RFC 7616]]
には必須であるような規定はありません。しかし[[クライアント]]が [[credentials]]
の [CODE(HTTP)@en[[[response]]]] [[引数]]の計算に [CODE(HTTP)@en[[[nonce]]]]
を使いますから、[[サーバー]]は [[challenge]]
に [CODE(HTTP)@en[[[nonce]]]] を指定しないといけません。
** 処理
[13] 実装は、[[replay攻撃]]を防ぐため、前に使われた [[nonce]]
の再利用を認めないこととできます。 [SRC[>>3]]
[16] [CODE[[[response]]]] [[引数]]の値の計算に使われます。
** 歴史
[REFS[
- [1] [CITE@en[RFC 2069 - An Extension to HTTP : Digest Access Authentication]] ([TIME[2012-02-26 10:05:21 +09:00]] 版) <http://tools.ietf.org/html/rfc2069#page-5>
- [4] [CITE@en[RFC 2617 - HTTP Authentication: Basic and Digest Access Authentication]] ([TIME[2012-01-09 21:04:30 +09:00]] 版) <http://tools.ietf.org/html/rfc2617#section-3.2.1>
]REFS]
* メモ
[6] [CITE@ja-jp[ナンス ‐ 通信用語の基礎知識]]
([TIME[2015-07-14 22:47:40 +09:00]] 版)
<http://www.wdic.org/w/WDIC/%E3%83%8A%E3%83%B3%E3%82%B9>
[30] [CITE@en[Add 'cryptographic nonce metadata' to requests · whatwg/fetch@667ca32]]
([TIME[2016-04-06 16:33:03 +09:00]] 版)
<https://github.com/whatwg/fetch/commit/667ca3264e94ee4e5c7a1e1b85feb3344d107a1f>
[33] [CITE@en[Pass cryptographic nonce metadata to Fetch · whatwg/html@5479e07]]
([TIME[2016-04-07 16:08:44 +09:00]] 版)
<https://github.com/whatwg/html/commit/5479e07a6f6e01062b85b5fe6799752b0370336c>
[34] [CITE@en[Wire nonces up to Fetch's cryptographic nonce metadata. · w3c/webappsec-csp@86ae8b1]]
([TIME[2016-04-12 17:14:01 +09:00]] 版)
<https://github.com/w3c/webappsec-csp/commit/86ae8b1bcbd95c95dcac029f6b27c668e59164dd>
[35] [CITE@en[Add <link nonce>]]
([[mikewest]]著, [TIME[2016-09-28 20:17:08 +09:00]])
<https://github.com/whatwg/html/commit/1d4fc66465169312deaa8945fcb359813abc3fe0>
[37] [CITE@en[Value-agnostic nonce matching (#222)]]
([[andypaicu]]著, [TIME[2017-05-30 21:51:31 +09:00]])
<https://github.com/w3c/webappsec-csp/commit/af76f746928d6db9372d1ce5bc02f74c7ec88607>
[38] [CITE@en[Make integrity="" work on module scripts]]
([[domenic]]著, [TIME[2017-09-14 18:00:24 +09:00]])
<https://github.com/whatwg/html/commit/9275d955dcd604e959cfcc672e0c234b1b8c00db>
[39] [CITE@en[NoncedElement link.]]
([[mikewest]]著, [TIME[2017-12-01 22:53:04 +09:00]])
<https://github.com/w3c/webappsec-csp/commit/7024fc63655667d380056848966204c350669c8e>
[40] [CITE@en[Hide nonce content attribute values]]
([[mikewest]]著, [TIME[2017-11-23 00:15:47 +09:00]])
<https://github.com/whatwg/html/commit/19f5cce801550d278b9459f8c4797f9f86aae864>
[41] [CITE@en[Consider hiding `nonce` content attributes. · Issue #2369 · whatwg/html]]
([TIME[2018-02-17 23:20:14 +09:00]])
<https://github.com/whatwg/html/issues/2369>
[42] [CITE@en[Consider not exposing nonce="" to the page · Issue #65 · w3c/webappsec-csp]]
([TIME[2018-02-17 23:22:57 +09:00]])
<https://github.com/w3c/webappsec-csp/issues/65>
[43] [CITE@en[Hide `nonce` content attribute values. (#2369) by mikewest · Pull Request #2373 · whatwg/html]]
([TIME[2018-02-17 23:23:03 +09:00]])
<https://github.com/whatwg/html/pull/2373>
[44] [CITE@en[Hide `nonce` content attribute values from non-script sources. by mikewest · Pull Request #436 · whatwg/dom]]
([TIME[2018-02-17 23:40:09 +09:00]])
<https://github.com/whatwg/dom/pull/436>
[45] [CITE@en[Add HTMLOrSVGElement interface mixin]]
([[annevk]]著, [TIME[2018-03-23 19:30:45 +09:00]])
<https://github.com/whatwg/html/commit/81e82437a7ef1ee37d4ce2b5a982bc297d5b58b1>
[46] [CITE@en[Fix and clarify some '''['''CEReactions''']''' annotations]]
([[domenic]]著, [TIME[2018-08-11 19:59:46 +09:00]])
<https://github.com/whatwg/html/commit/023c11216ca2ee1c653df09a594b98fca1323975>
[47] [CITE@en[nonce IDL attribute should have the semantics of CEReactions · Issue #3887 · whatwg/html]]
([TIME[2018-08-18 23:59:26 +09:00]])
<https://github.com/whatwg/html/issues/3887>
[48] [CITE@en[Fix and clarify some '''['''CEReactions''']''' annotations by domenic · Pull Request #3901 · whatwg/html]]
([TIME[2018-08-19 00:00:06 +09:00]])
<https://github.com/whatwg/html/pull/3901>
[49] [CITE@en[Convert string to UTF-8 before applying hash algorithms (#342)]]
([[andypaicu]]著, [TIME[2018-10-04 21:44:55 +09:00]])
<https://github.com/w3c/webappsec-csp/commit/84cc0d929ed90b21575e2ec1973438a5745d5562>
[50] [CITE@en[Convert string to UTF-8 before applying hash algorithms by andypaicu · Pull Request #342 · w3c/webappsec-csp]]
([TIME[2018-10-22 01:19:24 +09:00]])
<https://github.com/w3c/webappsec-csp/pull/342>
[51] [CITE@en[Hash encodings should be converted to UTF-8 · Issue #109 · w3c/webappsec-csp]]
([TIME[2018-10-22 01:19:39 +09:00]])
<https://github.com/w3c/webappsec-csp/issues/109>