-
Notifications
You must be signed in to change notification settings - Fork 4
/
569.txt
631 lines (491 loc) · 38.5 KB
/
569.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
[4]
[DFN[[RUBYB[同一起源ポリシー]@en[same origin policy]]]]は、
[[Web]] において、[[スクリプト]]が異なる[[起源]] [WEAK[([[URL scheme]]、[[ホスト]]、[[ポート]]の組など)]]
に由来する[[物体]]に対してアクセスすることを制限する[[セキュリティー]]に関する大原則です。
;; [55] たまに [DFN[[[SOP]]]] と略されることがあります。
* 仕様書
[REFS[
- [3] '''[CITE@en-US-x-hixie[HTML 5]] ([TIME[2008-07-04 05:49:35 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#origin>'''
]REFS]
* 同一起源ポリシーの原理
[56] [[Webアプリケーション]]は、[[鯖]]が提供した[[スクリプト]]等を [[Webブラウザー]]上の環境において実行、
評価するものですが、適切な[[セキュリティー・モデル]]が無ければ[[利用者]]やその他の人が意図しない有害な動作がなされてしまうかもしれません。
[[同一起源方針]]は [[Webブラウザー]]上で動作する[[Webアプリケーション]]のための[[セキュリティー・モデル]]として発展、収束してきたものです。
[[RFC 6454]] で [[Adam Barth]] は次の基本原理をまとめています。
[FIG(short list)[
- Trust
- Origin
- Authority
- Policy
]FIG]
** Trust
[57] [[同一起源方針]]においては [[URL]] によって [[trust]] を指定していると言えます。
[EG[
[58] 例えば [CODE(HTMLe)@en[[[script]]]] [[要素]]によって [[URL]]
を指定して外部の[[スクリプト]]を読み込むことは、
自身の持つ[[特権]]を当該 [[URL]] に対して付与していることになります。
つまり当該 [[URL]] から得られる情報の[[一貫性]]を信頼 (trust) すると宣言していると言えます。
]EG]
[EG[
[59] また [CODE(HTMLe)@en[[[form]]]] [[要素]]によって [[POST]] 先の [[URL]]
を指定することは、秘密のデータを当該 [[URL]] に対して開示することになります。
つまり当該 [[URL]] に送られるデータの秘匿性を信頼 (trust) すると宣言していると言えます。
]EG]
** Origin
[60] あらゆる [[URL]] にそれぞれ個別の保護された領域を与えることもできますが、
それでは実用上不便なので、[[同一起源方針]]にあっては[[ドメイン]]などが共通する [[URL]] 群を
[[起源]] (origin) と呼び、これを保護の単位とします。
[EG[
[61] 例えば [CODE(URI)@en[http://example.com/]] と [CODE(URI)@en[http://example.com/~mypage/]]
は [CODE(URI)[http://example.com]] という共通の[[起源]]を持ちます。しかし
[CODE(URI)[http://www.example.com/]] や [CODE(URI)@en[http://example.com:8080/]]
の[[起源]]はそれぞれ
[CODE(URI)[http://www.example.com]] や [CODE(URI)@en[http://example.com:8080]]
であり、異なります。
]EG]
** Authority
[62] [[起源]]が同じであっても、[[資源]]はそれぞれの権限 (authority) を持っています。
どれだけの権限を与えるかは [[MIME型]]により決まります。
[EG[
[63] 例えば [CODE(MIME)@en[[[image/png]]]] の[[資源]]は[[画像]]であり、 [[API]]
その他へのアクセス権を有しません。一方 [CODE(MIME)@en[[[text/html]]]] の[[資源]]は
[[HTML文書]]であり、[[スクリプト]]の実行その他の様々な権限を有します。
]EG]
** Policy
[64] [[同一起源方針]]においては[[起源]]はそれぞれ別に管理されており、他の[[起源]]との通信は制限されています。
他の[[起源]]の[[API]]アクセスは原則として禁止されていますし、他の[[起源]]の[[資源]]を読み取ることもできません。
他の[[起源]]に情報を送ることは認められていますが、一部の決められた形式に制限されています。
[EG[
[65] 例えば [[DOM]] の [[API]] によって他の[[起源]]の[[文書]]にアクセスすることはできません。
[CODE(DOM)@en[[[postMessage]]]] など例外はありますが、それ以外は [[Webブラウザー]]により厳密に管理されています。
]EG]
[EG[
[66] [[XHR]] によって他の[[起源]]の[[資源]]を読み取ることは、 [[CORS]] により例外的に認められていない限り、
禁止されています。
]EG]
** 同一起源ポリシーが保護しないもの
[18] 一見セキュリティーに関わりそうな次の要素は、[[起源]]の定義には含まれていませんから、
[[同一起源ポリシー]]の保護対象外です。
[FIG(list)[
- [148] [[ドメイン名]]と [[IPアドレス]]の関係
- [149] [[サーバー証明書]]
- [150] [[credentials]] の有無
]FIG]
[151] [[著者]]は、必要なら対策を講じる必要があります。
[EG[
[152] 例えば同じ[[起源]]の一部のページは認証不要で公開されており、
他のページは[[HTTP認証]]により保護されているとします。
まず保護されたページに認証つきでアクセスし、 [CODE[localStorage]] に何らかのデータを保存します。
次に認証不要なページに認証つきでアクセスし、 [CODE[localStorage]] を参照すると、
前に保存したデータが得られます。
なぜなら、 [CODE[localStorage]] は[[起源]]単位のストレージであり、
認証の有無は[[起源]]の違いとならないからです。
[153] これが問題となるかどうかは、[[アプリケーション]]の性質に依存します。
問題となるのであれば、 ([[Webブラウザー]]のセキュリティーホールではなく[[アプリケーション]]設計の問題なので)
[[著者]]が対策を検討しなければなりません。
]EG]
* 適用対象
[9]
いくつかの挙動はそれが同じ[[起源]]に対して行われた操作に由来するか否かによって変化します。
一般に他の[[起源]]の状態や処理結果は取得できません。
@@ このリストは不完全です。
[FIG[
-[20] [CODE(DOMa)@en[[[window]]]] や [CODE(DOMa)@en[[[location]]]]
の[[メンバー]] (一部例外を除きます。) に対する[[スクリプト]]からのアクセス
[SRC@en[[[HTML 5]]]]
--[26] ただし、[[Webブラウザ]]によっては、 [[HTML 5]] で例外とされている[[メンバー]]以外にも異なる[[起源]]の[[スクリプト]]からアクセスできてしまいます。
(例えば [[Gecko]] では [CODE(DOMa)@en[[[name]]]] や [CODE(DOMa)@en[[[status]]]] にアクセスできます。
[CODE(DOMa)@en[[[name]]]] の項を参照。)
-- [84] [CODE(DOMi)@en[[[Window]]]]: [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#security-2>
-- [86] [CODE(DOMi)@en[[[Location]]]]: [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#security-3>
-- [82] [CODE(DOMa)@en[[[frameElement]]]]: [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#dom-frameelement>
-- [127] [CODE(DOMa)@en[[[contentDocument]]]]:
[CITE@en-US-x-hixie[HTML Standard]] ([TIME[2013-11-12 21:53:09 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#dom-iframe-contentdocument>
[CITE@en-US-x-hixie[HTML Standard]] ([TIME[2013-11-12 21:53:09 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#dom-object-contentdocument>
[CITE@en-US-x-hixie[HTML Standard]] ([TIME[2013-11-12 21:53:09 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#dom-frame-contentdocument>
-- [128] [CODE(DOMm)@en[[[getSVGDocument]]]]
-- [83] [[navigation]]: [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#allowed-to-navigate>
-[23] [[CSSOM]] へのアクセス [SRC[仕様なし]]
- [33] 外部資源へのアクセス
--[21] [CODE(DOMi)@en[[[XMLHttpRequest]]]] による[[外部資源]]へのアクセス
[SRC@en[[[XMLHttpRequest]], [[XMLHttpRequest]] 2]]
--[22] [[WebSocket接続の確立]] [SRC@en[[[HTML 5]]]]
--[31] [CODE(JS)@en[[[document.load]]]]
-- [34] [[XSLT]] [CODE(XPathf)@en[[[document()]]]] [[関数]]による別[[起源]]の[[資源]]へのアクセス [SRC[仕様なし]]
-[37] [CODE(DOMa)@en[[[mozIsLocallyAvailable]]]]
- [43] [[SOAP]]
-- <https://developer.mozilla.org/ja/SOAP_in_Gecko-based_Browsers>
- [73] [CODE(DOM)@en[[[onerror]]]]
-- [[エラーミュートフラグ]]
-- [95] [CODE(DOMi)@en[[[[Window]]]]: [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#runtime-script-errors>
-- [96] [CODE(HTMLe)@en[[[iframe]]]]: [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#the-iframe-element>
-- [[navigation]]: [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#navigating-across-documents>
- [74] [CODE(HTMLa)@en[[[seamless]]]]
-- [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#attr-iframe-seamless>
- [77] [CODE(HTMLe)@en[[[canvas]]]] の[[起源汚染]]
-- [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#security-with-canvas-elements>
- [75] [[Web Fonts]] の利用
-- [76] [CODE(DOMm)@en[[[measureText]]]] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#dom-context-2d-measuretext>
- [78] [CODE(HTMLa)@en[[[autofocus]]]] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#attr-fe-autofocus>
- [80] [CODE(HTMLa)@en[ping]] [[属性]]で指定された [[URL]]
に対して [CODE(HTTP)@en[Ping-From:]] [[ヘッダー]]を送信するかどうか
- [81] [[奇癖モード]]における [[[CODE(MIME)@en[Content-Type]]メタデータ]]の扱い [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#link-type-stylesheet>
- [85] [CODE(DOMm)@en[[[pushState]]]]/[CODE(DOMm)@en[[[replaceState]]]]
-- [[文書の起源]]と[[文書の番地]]の[[起源]]と指定された [[URL]] の[[起源]]が同じでなければなりません。
- [87] [[AppCache]]
-- [88] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#navigating-across-documents>
-- [93] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#concept-appcache-matches-fallback>
-- [94] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#changesToNetworkingModel>
- [89] [[HTTP]] [[redirect]]
-- [90] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#navigating-across-documents>
- [97] [CODE(URI)@en[[[javascript:]]]] [[URL]]: [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#javascript-protocol>
- [98] [[dialog]]: [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#dom-showmodaldialog>
- [99] [CODE(DOMm)@en[[[registerProtocolHandler]]]], [CODE(DOMm)@en[[[registerContentHandler]]]]:
[CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#custom-handlers>
- [100] [CODE(DOMm)@en[[[IsSearchProviderInstalled]]]]:
[CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#dom-external-issearchproviderinstalled>
- [101] [CODE(JS)@en[[[new Worker]]]]
- [140] [CODE(JS)@en[[[new SharedWorker]]]]
- [106] [CODE(DOMa)@en[[[sessionStorage]]]]: [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#the-sessionstorage-attribute>
- [107] [CODE(DOMa)@en[[[localStorage]]]]: [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#the-localstorage-attribute>
- [108] [CODE(DOMe)@en[[[unload]]]] 中の [[navigation]]
-- [[Gecko]] と [[Opera]] では [[same-origin policy]] の対象になります。
[[WebKit]] ではまったく認められていません。
- [109] [CODE(DOMi)@en[[[PerformanceTiming]]]] から値を取得できるか否か
-- [CITE@en[Navigation Timing]] ([TIME[2012-12-13 06:51:35 +09:00]] 版) <http://www.w3.org/TR/2012/REC-navigation-timing-20121217/#sec-navigation-timing-interface>
- [114] [CODE(DOMe)@en[[[error]]]] [[イベント]]が[[発火]]するかどうか [SRC[[[HTML]]]]
- [144] [[祖先閲覧文脈]]等の制約が[[入れ子閲覧文脈]]等に伝播するもの:
-- [CODE(HTMLa)@en[[[sandbox]]]]
-- [CODE(HTTP)@en[[[Upgrade-Insecure-Requests:]]]]
]FIG]
[HISTORY[
[129] [CODE(DOMi)@en[[[Widget]]]] の [CODE(DOMa)@en[[[preferences]]]] にも[[同一起源ポリシー]]が適用されます。
]HISTORY]
* 起源の値によって動作が変わるもの
[115] [[起源]]が[[三項組]]であるか固有識別子であるか、あるいはその[[三項組]]がどのような値であるかによって、
挙動が変わることがあります。
[FIG[
- [68] [[fetch]] において [CODE(HTTP)@en[[[Referer:]]]] を送出する条件
-- [[起源]]が[[3項組]]で''なければ''、 [CODE(HTTP)@en[[[Referer:]]]] を送っては[['''なりません''']] [SRC[>>67]]。
-- [67] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#fetch>
- [70] [CODE(JS)@en[[[document.cookie]]]] を使える条件
-- [[起源]]が[[3項組]]で''なければ''、 [CODE(JS)@en[[[document.cookie]]]] には読み書きできません [SRC[>>69]]。
-- [69] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#dom-document-cookie>
- [79] [[ダウンロード]]時の[[ファイル名]] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#downloading-hyperlinks>
- [104] [CODE(DOMi)@en[[[WebSocket]]]]
-- [105] [[https:]] から [[ws:]] にはアクセスできない: [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#dom-websocket>
- [116] [[encoding sniffing algorithm]] において[[親閲覧文脈]]を参照するか否か
-- [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2013-04-30 04:07:36 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#encoding-sniffing-algorithm>
]FIG]
* 適用対象外
[10] 次の機能を使うと、[[同一起源ポリシー]]は適用されず、
他の[[起源]]のデータに (ある程度) アクセスできます。
[FIG(list)[
- [CODE(HTMLa)@en[[[src]]]] [[属性]]、
[CODE(HTMLe)@en[[[object]]]] [[要素]]、
[CODE(HTMLe)@en[[[embed]]]] [[要素]]、
[CODE(HTMLe)@en[[[link]]]] [[要素]]などによる外部[[資源]]の埋め込み
-- [CODE(HTMLe)@en[[[img]]]] [[要素]]や [CODE(HTMLe)@en[[[iframe]]]]
[[要素]]など
-- [CODE(HTMLe)@en[[[script]]]] [[要素]]による外部[[スクリプト]]の参照も含みます。
[[JSONP]] などで同一起源方針を擦り抜けるテクニックとしてよく利用されています。
-- これらの[[要素]]や[[属性]]を使うと、本来[[スクリプト]]から取得できないべきである、
異なる[[起源]]の情報を取得することができてしまいます。前述のスクリプト実行だけでなく、
例えば、[[画像]]の大きさを取得することで、その内容を推測できてしまうかもしれません。
-- 外部[[スタイル・シート]]については、非同一起源でも読み込まれて文書に適用されますが、
[[スクリプト]]による [[CSSOM]] の参照に関しては同一起源方針の適用対象になります
(ただし各[[ブラウザ]]とも動作が怪しい)。
-- [[delay the load event]]
- [[画像]]系 [[CSS]] [[特性]]による外部[[画像]]の埋め込み
- [CODE(CSS)@en[@[[import]]]] による外部 [[CSS]] [[スタイル・シート]]の[[輸入]]
-[25] [CODE(DOMm)@en[[[postMessage]]]] [[メソッド]]を使うと、
異なる[[起源]]の [[Web頁]]に対して[[メッセージ]]を伝達できます。
-[32] [CODE(HTMLa)@en[[[marginwidth]]]] など[[フレーム]]内の[[余白]]を設定する[[属性]]を使うと、
[[フレーム集合文書]]とは異なる[[起源]]の[[フレーム]]内[[文書]]の[[余白]]を設定できます。
-- [[フレーム]]は [[CSS]] によるレンダリング・モデル以前に実装された歴史的経緯によります。
- [38] [CODE(JS)@en[[[window.name]]]]
- [39] [CODE(HTMLa)@en[[[marginheight]]]], [CODE(HTMLa)@en[[[marginwidth]]]]
- [102] [CODE(DOMi)@en[[[EventSource]]]]
- [103] [CODE(DOMi)@en[[[WebSocket]]]]: 異なる[[起源]]でも接続できます。
実際に [[WebSocket接続を確立]]することを認めるかどうかは、[[WebSocketサーバー]]が判断できます。
- [[砂箱化の実装]]
- [CODE(HTMLa)@en[allowfullscreen]]/[CODE(HTMLa)@en[allowusermedia]]
- [CODE[history.index]] / [CODE[history.length]]
[HISTORY[
- [CODE(CSS)@en[[[-moz-binding]]]] [[特性]]による外部 [[XBL 1.0]]
[[文書]]の読み込み
- [[Webフォント]]
-- 一部ブラウザ実装。今後の動向次第で変更される可能性あり。
]HISTORY]
]FIG]
[138] ここに挙げたものの他、[[起源]]とは異なるものを適用対象の範囲とする機能もいくつかあります。
詳しくは[[起源]]の「起源と適用範囲が異なる機能」の項を参照。
* 要調査
@@
- [16] [[XSLT]] [[スタイル・シート]]
- [111] [CODE(XMLe)@en[[[xml]]]] [[要素]]
- [112] [[IE]] [CODE(HTMLa)@en[[[data*]]]]
- [113] [[HTC]] / [[XBL]]
* [11] 制約の緩和
- [15] [CODE(JS)@en[[[document]].[[domain]]]] [[DOM属性]]に値を設定することにより、
[[起源]]となる[[ドメイン名]]を変更することができます。
--ただし、新しい[[ドメイン名]]は元の[[ドメイン名]]の上位階層に当たるものでなければなりません。
- [12] [[CORS]] により、''外部[[資源]]は''、異なる[[起源]]からのアクセスを許可することができます。
-- [13] [[Microsoft]] が提案し、 [[WinIE 8]] で実装している
[CODE(DOMi)@en[[[XDomainRequest]]]] を用いると、
異なる[[ドメイン]]の[[資源]]にアクセスできます。
- [14] [[WinIE]] で実装されている[[セキュリティ・ゾーン]]の機能により、
[[イントラネット]]等[[ゾーン]]毎に、
[[同一起源方針]]を[[利用者]]の設定により緩和することができます。
-[17]
[[Adobe]] [[Air]] は異なる[[起源]]に対する [CODE(DOMi)@en[[[XMLHttpRequest]]]]
でのアクセスを可能にする [CODE(HTMLa)@en[[[allowcrossdomainxhr]]]]
[[属性]]を実装しています。
-[19] [CODE(DOMa)@en[[[globalStorage]]]]
--かつて [[HTML 5]] に含まれていました。
--現在は削除され、代わりに [CODE(DOMa)@en[[[localStorage]]]] が定義されていますが、
こちらは[[同一起源方針]]に完全に従っています。
-- [[Firefox]] 3 が実装しています。
-- [CODE(JS)@en[[[document]].[[domain]]]] [[DOM属性]]の設定と同じようなアクセス制約があります。
- [44] [[Gecko]] は特権を取得することで一部制限を回避できるらしい
-- <https://developer.mozilla.org/ja/SOAP_in_Gecko-based_Browsers>
[136] [[Firefox拡張]]は拡張 ([CODE(URI)@en[[[chrome:]]]]) から[[内容]]
([CODE(XMLe)@en[[[browser]]]] の[[閲覧文脈]]) にアクセスでき、
[[同一起源ポリシー]]無く操作できます。[[拡張]]から[[内容]]内の[[節点]]で
[[DOMイベント]]を [[dispatch]] して、情報を伝えることがあります。
[137] [[ブラウザー拡張]]によっては[[内容スクリプト]]を[[拡張]]から[[内容]]に注入できることがあります。
[[拡張]]と[[内容スクリプト]]で通信する手段を提供していることもありますが、
それ以外での両者間のアクセスは制限されています。
[139] 逆に、 [CODE(HTMLa)@en[[[sandbox]]]] を使うと、本来[[同じ起源]]となるものを異なる[[起源]]として扱わせることができます。
* 媒体
[30] [CITE[Re: Same-origin checking for media elements]] ([[Ian Hickson <ian@...>]] 著, [TIME[2008-11-17 01:37:36 +09:00]] 版) <http://permalink.gmane.org/gmane.org.w3c.whatwg.discuss/16571>
* 労働者
@@ ・・・
* 局所ファイル
[27] [[HTML5]] は[[局所ファイル]]に関しては[[相互運用性]]に関係しないため適用範囲外として規定していません。
[28] [CITE@ja[Chromeセキュリティモデル、IE/Firefox/Safari/Operaのいいとこ取り | エンタープライズ | マイコミジャーナル]] ([[Mainichi Communications Inc.]] 著, [TIME[2008-12-09 08:24:36 +09:00]] 版) <http://journal.mycom.co.jp/news/2008/12/08/031/>
[29] [CITE[Chromium Blog: Security in Depth: Local Web Pages]] ([TIME[2008-12-13 15:47:53 +09:00]] 版) <http://blog.chromium.org/2008/12/security-in-depth-local-web-pages.html>
* 歴史
[6] 同一起源方針は、 [[Netscape Navigator]] 2.0 で [[JavaScript]]
と共に導入され [SRC[>>1、>>2]]、2.01 および 2.02 で不具合の修正がなされました
[SRC[>>1]]。
[7] [[Internet Explorer]] をはじめとする他ブラウザも同様にこの制限を実装しましたが、
[[ECMAScript]] 仕様や [[DOM]] 仕様としての標準化の対象外とされ、
長らく明文化された規定が存在していませんでした。
[165] 暗黙の標準だった時期の[[同一起源ポリシー]]は、実装ごとに細かな違いがありました。
例えば[[ポート]]を[[起源]]の区別に寄与させるかどうかは、
現在の [CODE(JS)@en[document.domain]] や[[クッキー]]の適用範囲にも影響を残しています。
[[Internet Explorer]] の[[セキュリティーゾーン]]のように、
[[同一起源ポリシー]]の原則から外れた機能も存在していました。
-*-*-
[8] [[HTML DOM]] に関係する部分はようやく2005年頃に [[WHATWG]]
によって [[HTML 5]] 仕様の一部として仕様の明文化が行われ始めました。
また、 [[XMLHttpRequest]] に関しては [[HTML 5]] 仕様を参照する形で規定されています。
[126] [CODE(DOMi)@en[[[Document]]]] は、当初は[[オブジェクト]]そのものは取得できるものの、
そのメンバーは一切読み書きできないとなっていましたが、 [CODE(DOMa)@en[[[contentDocument]]]]
などが異なる[[起源]]の場合 [[null]] を返すよう変更され、異なる[[起源]]の [CODE(DOMi)@en[[[Document]]]]
[[オブジェクト]]にアクセスすること自体ができなくなりました。
[REFS[
- [5] '''[CITE@en[RFC 6454 - The Web Origin Concept]] ([TIME[2011-12-12 09:13:37 +09:00]] 版) <http://tools.ietf.org/html/rfc6454>'''
]REFS]
[24] [[起源]]に関する基本的な規定は [[RFC 6454]] となりましたが、2014年に
[[HTML Standard]]、[[URL Standard]]、[[Fetch Standard]] により[[廃止]]されています。
;; [[起源]]を参照。
[REFS[
- [124] [CITE@en[Web Applications 1.0 r8272 Change iframe, frame, and object.contentDocument to return null when cross-origin documents are involved.]] ([TIME[2013-11-13 06:50:00 +09:00]] 版) <http://html5.org/tools/web-apps-tracker?from=8271&to=8272>
- [125] [CITE@en[Web Applications 1.0 r8273 Remove security checks on Document since there should now be no way to get to a Document from another origin.]] ([TIME[2013-11-13 06:53:00 +09:00]] 版) <http://html5.org/tools/web-apps-tracker?from=8272&to=8273>
]REFS]
[2]
[CITE[JavaScript Security: Same Origin]] ([CODE[2008-06-18 04:13:16 +09:00]] 版) <http://www.mozilla.org/projects/security/components/same-origin.html>
[1]
[CITE@en[Same origin policy - Wikipedia, the free encyclopedia]] ([CODE[2008-07-02 01:06:45 +09:00]] 版) <http://en.wikipedia.org/wiki/Same_origin_policy>
[35] [CITE@en-us[Same origin policy for JavaScript - MDC]] ([TIME[2009-02-17 13:34:30 +09:00]] 版) <https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript>
[36] [CITE[The Multi-Principal OS Construction of the Gazelle Web Browser - Microsoft Research]] ([TIME[2009-03-07 00:35:15 +09:00]] 版) <http://research.microsoft.com/apps/pubs/default.aspx?id=79655>
[[Webブラウザー]]の[[プロセス]]を[[起源]]毎に分離することによって[[保安性]]の向上を図る[[論文]]だそうです。
[40] [CITE@en[(X)HTML5 Tracking]]
([TIME[2009-09-30 00:11:40 +09:00]] 版)
<http://html5.org/tools/web-apps-tracker?from=4041&to=4042>
[41] [CITE[IRC logs: freenode / #whatwg / 20100223]]
([TIME[2010-02-25 09:03:01 +09:00]] 版)
<http://krijnhoetmer.nl/irc-logs/whatwg/20100223>
[42] [CITE['''['''whatwg''']''' Canvas 2D Context Proposal: resetOriginClean]]
([TIME[2010-04-25 01:54:34 +09:00]] 版)
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2010-April/026006.html>
[45] [CITE@en[Guidelines for Web Content Transformation Proxies 1.0]]
( ([TIME[2010-10-22 17:20:31 +09:00]] 版))
<http://www.w3.org/TR/2010/NOTE-ct-guidelines-20101026/#term-same-origin>
[46] [CITE@en[Web Applications 1.0 r5873 Make sure cross-origin fonts can't leak data via <canvas>.]]
( ([TIME[2011-02-11 10:48:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=5872&to=5873>
[47] [CITE[Embedder's Guide - V8 JavaScript Engine - Google Code]]
( ([TIME[2010-11-13 19:00:12 +09:00]] 版))
<http://code.google.com/intl/ja/apis/v8/embed.html>
[48] [CITE@en[draft-abarth-principles-of-origin-00 - Principles of the Same-Origin Policy]]
([TIME[2011-02-22 08:21:31 +09:00]] 版)
<http://tools.ietf.org/html/draft-abarth-principles-of-origin-00>
[49] [CITE@en[Thoughts on font linking and embedding]]
( ([[Maciej Stachowiak]] 著, [TIME[2011-02-17 04:28:23 +09:00]] 版))
<http://lists.w3.org/Archives/Public/public-webfonts-wg/2011Feb/0066.html>
[50] [CITE@en[Thoughts on font linking and embedding]]
( ([[Maciej Stachowiak]] 著, [TIME[2011-02-17 04:28:23 +09:00]] 版))
<http://lists.w3.org/Archives/Public/public-webfonts-wg/2011Feb/0066.html>
[51] [CITE['''['''whatwg''']''' Canvas and drawWindow]]
([TIME[2011-03-15 13:03:35 +09:00]] 版)
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2011-March/030862.html>
[52] [CITE[IRC logs: freenode / #whatwg / 20110202]]
( ([TIME[2011-03-19 11:10:11 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20110202>
[53] [CITE[IRC logs: freenode / #whatwg / 20110214]]
( ([TIME[2011-03-23 00:25:04 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20110214>
[54] [CITE[クロスドメイン通信方法のまとめ - nopnopの日記]]
( ([TIME[2011-04-24 11:59:01 +09:00]] 版))
<http://d.hatena.ne.jp/nopnop/20080408/1207669947>
[110] [CITE[''''''[''''''whatwg'''''']'''''' Need to define same-origin policy for WebIDL operations/getters/setters]]
( ([TIME[2013-01-08 08:41:09 +09:00]] 版))
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-January/038529.html>
[117] [CITE@en[Web Applications 1.0 r7975 Make showModalDialog()'s dialogArguments and returnValue only be useful same-origin, to avoid origins attacking each other]]
( ([TIME[2013-06-15 03:12:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7974&to=7975>
[118] [CITE@en[Web Applications 1.0 r7975 Make showModalDialog()'s dialogArguments and returnValue only be useful same-origin, to avoid origins attacking each other]]
( ([TIME[2013-06-15 03:12:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7974&to=7975>
[119] [CITE[''''''[''''''whatwg'''''']'''''' Adding crossorigin="" to more elements]]
( ([TIME[2013-06-17 19:04:22 +09:00]] 版))
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-June/039752.html>
[120] [CITE@en[Web Applications 1.0 r7997 Block enumeration of cross-origin objects, and clean up the language around those objects to be more consistent so that differences can more easily be seen.]]
( ([TIME[2013-06-25 05:28:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7996&to=7997>
[121] [CITE@en[Web Applications 1.0 r8090 Remove the weird stuff around document.domain and localStorage. It doesn't really do anything anyway.]]
( ([TIME[2013-07-26 09:13:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8089&to=8090>
[122] [CITE@en[Web Applications 1.0 r8196 Add warning notes to the Security sections of Location and Window since they are in flux with no end in sight.]]
( ([TIME[2013-09-24 06:42:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8195&to=8196>
[123] [CITE[IRC logs: freenode / #whatwg / 20130925]]
( ([TIME[2013-09-26 20:51:11 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20130925>
[130] [CITE@en[Web Applications 1.0 r8713 getSVGDocument()]]
( ([TIME[2014-08-07 03:26:00 +09:00]] 版))
<http://html5.org/r/8713>
[72] [CITE@en-US[Same-origin policy - Web security | MDN]]
( ([TIME[2015-01-15 06:35:29 +09:00]] 版))
<https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy>
[131] [CITE@en[524223 – (CVE-2010-0654) Cross-domain data theft using CSS]]
([TIME[2015-02-24 12:35:55 +09:00]] 版)
<https://bugzilla.mozilla.org/show_bug.cgi?id=524223>
[132] [CITE[Same-origin policy — Anne’s Blog]]
([TIME[2015-03-21 15:12:46 +09:00]] 版)
<https://annevankesteren.nl/2015/02/same-origin-policy>
[133] [CITE[Part2 - browsersec - Browser Security Handbook, part 2 - Browser Security Handbook - Google Project Hosting]]
([TIME[2015-03-31 16:36:25 +09:00]] 版)
<https://code.google.com/p/browsersec/wiki/Part2>
[FIG(quote)[
[FIGCAPTION[
[134] [CITE@en[From the Aether to the Ethernet – Attacking the Internet using Broadcast Digital Television | the morning paper]]
([TIME[2015-04-28 14:29:31 +09:00]] 版)
<http://blog.acolyer.org/2015/04/23/from-the-aether-to-the-ethernet-attacking-the-internet-using-broadcast-digital-television/>
]FIGCAPTION]
> What’s the origin if you provide content over the broadcast transport though?
> The HbbTV specification suggests that in this case the broadcast stream should explicitly define its own web origin by setting the simple_application_boundary_descriptor property in the AIT to any desired domain name.
> Yes, you can be anyone you want to be.
]FIG]
[135] [CITE@en[HbbTV and Web origins]]
([[Mark Nottingham]] 著, [TIME[2015-04-27 11:22:58 +09:00]] 版)
<https://lists.w3.org/Archives/Public/www-tag/2015Apr/0052.html>
[91] [CITE@en[Abusing HTTP status codes to deanonymize web users]]
([[Ahmed Elsobky]] 著, [TIME[2015-05-08 05:50:55 +09:00]] 版)
<https://lists.w3.org/Archives/Public/public-webappsec/2015May/0043.html>
[92] [CITE@en[Re: Abusing HTTP status codes to deanonymize web users]]
([[Anne van Kesteren]] 著, [TIME[2015-05-09 02:20:54 +09:00]] 版)
<https://lists.w3.org/Archives/Public/public-webappsec/2015May/0047.html>
[71] [CITE[Widget Interface]]
([TIME[2015-01-27 11:24:04 +09:00]] 版)
<http://w3c.github.io/packaged-webapps/api/Overview.html#preference-origin-security-check>
[FIG(quote)[
[FIGCAPTION[
[141] [CITE@ja[Introduction to DHTML Behaviors]]
([TIME[2015-07-23 18:15:21 +09:00]] 版)
<https://msdn.microsoft.com/ja-jp/library/ms531079(v=vs.85).aspx>
]FIGCAPTION]
> Behaviors are subject to the About Cross-Frame Scripting and Security rules of Internet Explorer. In other words, a Web page that refers to a behavior located on another server in another domain results in an "access denied" error in the page's onerror event handler. In the same way, a Web page that refers to a behavior of a different security protocol than the referring page will result in the same error. For example, a Web page on http://server1/page.htm might not refer to a behavior on https://server1/hilite.htc.
]FIG]
[FIG(quote)[
[FIGCAPTION[
[142] [CITE@ja[ja:midori:faq ''''''[''''''Xfce Wiki'''''']'''''']]
([TIME[2015-07-25 11:27:03 +09:00]] 版)
<https://wiki.xfce.org/ja/midori/faq>
]FIGCAPTION]
> 同一生成元ポリシー (Same Origin Policy) を無効に出来ますか? Midori の設定にない Webkit の設定変更はできませんか?
> Midori の設定ファイル (Unix の場合は ~/.config/midori/config、Windows の場合は %APPDATA%\midori\config) で WebKitWebSettings のすべての値を変更できます。例えば、ローカルファイルで同一生成元ポリシーを無効にする場合、以下を追加してください:
> enable-universal-access-from-file-uris=true
]FIG]
[FIG(quote)[
[FIGCAPTION[
[143] [CITE@en-US[Mozilla XForms Specials - Archive of obsolete content | MDN]]
([TIME[2014-04-15 00:00:08 +09:00]] 版)
<https://developer.mozilla.org/en-US/docs/Archive/Web/XForms/Mozilla_XForms_Specials>
]FIGCAPTION]
> Not exactly either a limitation, or an extension, but it is worth mentioning here. For security reasons, it is not per default possible for an XForms to submit data to another domain. This is due to security reasons. Information about how to whitelist domain can be found in the Release Notes
> The cross domain check also includes forms loaded from file://. Forms loaded from that URL should be local files, and thus trusted, but it is not always the case. So there is not automatic "whitelisting" of local files.
]FIG]
[145] [CITE@en[Merge pull request #44 from yoavweiss/timing_allow_same_origin_pass · w3c/resource-timing@960a8cb]]
([TIME[2015-10-27 13:00:25 +09:00]] 版)
<https://github.com/w3c/resource-timing/commit/960a8cbd77d640a5ac981ba9c77208aee6bb84e0>
[146] [CITE@en[Add some more parameters to the "perform a security check" hook (for … · heycam/webidl@adf3772]]
([TIME[2016-01-14 15:20:08 +09:00]] 版)
<https://github.com/heycam/webidl/commit/adf37720bd92138f9f1627a214330287550c0004>
[147] [CITE@en[Merge pull request #65 from andrey-logvinov/gh-pages]]
( ([[andrey-logvinov]]著, [TIME[2016-06-17 20:51:59 +09:00]]))
<https://github.com/w3c/wake-lock/commit/7a019503df2a917ca28f3655bcfd953f243703ca>
[154] [CITE@en[Cross-origin objects: do not wrap JavaScript functions]]
( ([[annevk]]著, [TIME[2016-06-22 00:21:17 +09:00]]))
<https://github.com/whatwg/html/commit/db361b608157b5cf9fd0d491d7dc76cdce80380b>
[155] [CITE@en[Remove unnecessary and unimplemented canvas tainting when painting text]]
([[domenic]]著, [TIME[2016-07-15 02:21:54 +09:00]])
<https://github.com/whatwg/html/commit/6c76b617d2b45326afea2625d174ce2fd5ab6423>
[FIG(quote)[
[FIGCAPTION[
[156] [CITE@ja[IE11とFirefoxのAdobe PDFで意図しない情報漏洩の可能性 | スラド セキュリティ]]
([TIME[2016-11-17 16:32:13 +09:00]])
<https://security.srad.jp/story/16/11/16/147247/>
]FIGCAPTION]
> 問題の脆弱性は、PDFにプログラムを埋め込める「FormCalc」という機能に関連するもの。FormCalcにはネットワーク経由でコンテンツの取得や送信を行える「Get」や「Post」、「Put」といった命令が用意されている。これを利用してPDFが配信されているドメインと同じドメイン上のデータを取得し、それを外部サーバーに送信するという処理をPDFを閲覧するマシン上で自動実行させることができるという。
> 一般的なWebブラウザでは、スクリプトによるHTTPリクエストについて、リクエスト先をそのスクリプトを配信するドメインに限定する、「同一オリジンポリシー(same-origin policy)」が適用されている(Mozillaによるドキュメント)。しかし、FormCalcではこの制限が緩く、取得した情報を別のサイトに送信できてしまうという。
]FIG]
[157] [CITE@en[Reports feature violates the same-origin policy]]
([[Anne van Kesteren]]著, [TIME[2017-02-16 00:51:15 +09:00]])
<https://lists.w3.org/Archives/Public/public-webappsec/2017Feb/0009.html>
[158] [CITE@en[Re: Reports feature violates the same-origin policy]]
([[Mike West]]著, [TIME[2017-02-16 01:56:39 +09:00]])
<https://lists.w3.org/Archives/Public/public-webappsec/2017Feb/0013.html>
[159] [CITE@en[Re: Reports feature violates the same-origin policy]]
([[Daniel Veditz]]著, [TIME[2017-02-16 05:09:24 +09:00]])
<https://lists.w3.org/Archives/Public/public-webappsec/2017Feb/0019.html>
[160] [CITE@en[Re: Reports feature violates the same-origin policy]]
([[Anne van Kesteren]]著, [TIME[2017-02-16 15:25:35 +09:00]])
<https://lists.w3.org/Archives/Public/public-webappsec/2017Feb/0021.html>
[161] [CITE@en["Script error." message in window.onerror makes bad DevExp trade off · Issue #2440 · whatwg/html]]
([TIME[2017-03-17 16:14:32 +09:00]])
<https://github.com/whatwg/html/issues/2440>
[162] [CITE@en[Single Trust and Same-Origin Policy v2]]
([[John Wilander]]著, [TIME[2017-03-25 04:25:03 +09:00]])
<https://lists.w3.org/Archives/Public/public-webappsec/2017Mar/0034.html>
[163] [CITE@en[Re: Single Trust and Same-Origin Policy v2]]
([[Mike West]]著, [TIME[2017-03-28 21:28:08 +09:00]])
<https://lists.w3.org/Archives/Public/public-webappsec/2017Mar/0054.html>
[164] [CITE@en[Make <body topmargin> win over <iframe marginheight> (#2489)]]
([[zcorpan]]著, [TIME[2017-04-18 06:41:29 +09:00]])
<https://github.com/whatwg/html/commit/3fc830124986d8fb0aa53cd2d2f2fea12a926e5d>
[166] [CITE@en[Enumerate fewer cross-origin properties]]
([[annevk]]著, [TIME[2017-11-07 01:09:46 +09:00]])
<https://github.com/whatwg/html/commit/ad8823782e7f6b7d60f8e216901bb76d1a53dd6d>
[167] [CITE@en[A primer on cross-origin information leaks]]
([[Artur Janc]]著, [TIME[2018-05-16 08:24:03 +09:00]])
<https://lists.w3.org/Archives/Public/public-webappsec/2018May/0009.html>
[168] [CITE@en[Exposing CSS subresource URLs · Issue #70 · w3c/resource-timing]]
([TIME[2018-08-23 19:08:02 +09:00]])
<https://github.com/w3c/resource-timing/issues/70>
[169] [CITE@en[Take tainted origin flag into account for the same origin check]]
([[annevk]]著, [TIME[2018-11-20 18:09:39 +09:00]])
<https://github.com/whatwg/fetch/commit/986618a62b2d7d31f93177ed178f0cb21b570d85>