実効ドメイン

Document インターフェイス domain 属性 (DOM)

[44] document.domain IDL属性は、 実効スクリプト起源ホスト名部分を表すものです。

[48] document.domain はセキュリティーホールを容易に作れてしまい危険です。 ほとんどの場合は、 postMessage など他の方法を探すべきです。

仕様書

意味

[22] document.domain は、同じドメインの異なるホストのページが互いの DOM のアクセスできるようにするものです >>17

[23] document.domain を使って同一起源ポリシーの制約を緩和すると、 起源ポート部分は無視されることになりますから、注意が必要です。 特に同じIPアドレスで複数の(異なる著者の)異なるポートHTTPサーバーが動作しているような場合には、document.domain によって通常ならアクセスできない起源のページから DOM にアクセスできてしまうことがあります。 >>17

取得器

[18] document.domain IDL属性取得器は、 次のようにしなければなりません >>17

  1. [63] 文脈オブジェクト起源実効ドメインnull の場合、
    1. [98] 空文字列を返します。
  2. [99] それ以外の場合、
    1. [100] 文脈オブジェクト起源実効ドメインを返します。

[33] 諸々の定義から、 document.domain が返す値は常に ASCIIドメイン名となります。

設定器

[19] document.domain IDL属性設定器は、 次のようにしなければなりません >>17

  1. [59] 新しい値を、新しい値を USVString として解釈した結果に設定します。
  2. [28]
    ... のいずれかの場合、
    1. [97] SecurityError DOMException投げ、ここで停止します。
  3. [39] 文脈オブジェクト起源ドメインを、 新しい値ホスト構文解析器を適用した結果に設定します。
[36] IPアドレスを指定できるのはIPアドレス文書だけですし、 IPアドレス文書で指定できるのはIPアドレスだけで、 しかも同じIPアドレスしか指定できません。そうでなければ SecurityError になります。
[37] document.domain を何度も新しい値に変えていく場合は、 どんどん短くしていかなければなりません。 (そしていつか変えれなくなります。)

[40] 起源オブジェクトは、 複数の文書起源として共有されていることがあります。 document.domain が変更されると、 その変更は同じ起源オブジェクトを共有する他の文書にも当然に伝播します。

起源のドメイン

[162] 項組起源ドメイン >>78 は、 document.domain に関する値を表しています。

[79] その値は、 null またはドメインです。初期値は null です。 >>78

[80] 項組起源も参照。

[82] 起源起源実効ドメイン (effective domain) は、 次のようにして得られる値です >>78

  1. [83] 起源不透明起源の場合、
    1. [85] null を返します。
  2. [84] それ以外の場合、
    1. [86] 起源ドメインnull なら、
      1. [87] 起源ホストを返します。
    2. [88] それ以外の場合、
      1. [89] 起源ドメインを返します。
ドメインでなく、IPアドレスが返される場合もあります。

関連

[46] 関連類似起源閲覧文脈の単位は、 document.domain の用法を考慮した閲覧文脈群の単位です。

歴史

[76] 起源の歴史の項も参照。

[1] Abe Fettig’s Weblog » How to make XmlHttpRequest calls to another server in your domain http://fettig.net/weblog/2005/11/28/how-to-make-xmlhttprequest-connections-to-another-server-in-your-domain/

[6] IE8 Security Part VI: Beta 2 Update - IEBlog - Site Home - MSDN Blogs ( ( 版)) http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx

[7] Document Object Model for MathML ( ( 版)) http://www.w3.org/TR/2001/REC-MathML2-20010221/appendixd.html#dom_Document

[8] Document Object Model for MathML ( ( 版)) http://www.w3.org/Math/DOM/mathml2/appendixd.html#dom_Document

[9] IRC logs: freenode / #whatwg / 20130110 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20130110

[10] Web Applications 1.0 r8275 Make sandboxed iframes block document.domain setting ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8274&to=8275

[11] IRC logs: freenode / #whatwg / 20140311 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20140311#l-447

[12] Web Applications 1.0 r8262 Move the spec from a stack of incumbent scripts to a stack of script settings object. This should in theory have no concrete effects (though I may have changed some of the origin used for Web Workers started from document.domain-affected scripts that were called from other scripts with different original origins). ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8261&to=8262

[13] IRC logs: freenode / #whatwg / 20141018 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20141018

[14] 340494 – access document.domain at about:plugins produces NS_ERROR_FAILURE. No error at about:config ( ( 版)) https://bugzilla.mozilla.org/show_bug.cgi?id=340494

[15] ブラウザ JavaScript ( 版) http://www.opera.com/docs/browserjs/

最後の TLD には document.domain はセットできない

[16] Part2 - browsersec - Browser Security Handbook, part 2 - Browser Security Handbook - Google Project Hosting ( 版) https://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_DOM_access

[49] Re: CSP policy to constrain cookies to origin (Mike West 著, 版) https://lists.w3.org/Archives/Public/public-webappsec/2015Aug/0127.html

[50] Allow user agents to consider usage of `document.domain` non-secure. · w3c/webappsec-secure-contexts@1bd4ef2 ( 版) https://github.com/w3c/webappsec-secure-contexts/commit/1bd4ef2ce9acb0c4ddca283415501b42b2a768ca

[51] Remove the storage mutex due to lack of implementation · whatwg/html@1b918cf ( 版) https://github.com/whatwg/html/commit/1b918cf72fcbba011f83b92ab5d1f483fb1cafa3

実効スクリプト起源

[45] 2016年3月改訂まで存在した実効スクリプト起源は、 document.domain に相当する仕様書上の概念です。 多くの場合は起源と同じ値ですが、 document.domain によって異なる値に設定されることがあります。

[71] スクリプトを介した色々な操作のアクセス制御が同一起源ポリシーによって行われます。 その時、 環境設定群オブジェクト実効スクリプト起源 >>69 が参照されることがあります。

[70] これらは以前は「スクリプト実効スクリプト起源」などと呼ばれていたこともありました。

環境設定群オブジェクトの歴史の項も参照。

[72] 環境設定群オブジェクト実効スクリプト起源は、 その作成時に決まります。その後も document.domain の変更の影響を受けます。

[74] 文書実効スクリプト起源を持ちます >>73

[75] その値は、作成時に決まります。多くの場合は文書の起源と同じです。 作成方法によっては、作成元の実効スクリプト起源の値を引き継ぎます。 その後も document.domain の変更の影響を受けます。

Document の作成の項、navigate の項も参照。

手動上書き

[41]手動上書き (manual override) 」 は、起源の比較において「手動上書き」と同じで、 それ以外のどの値とも同じでないような値です >>17

[92] document.domain に新しい値を設定すると、 起源ポートが「手動上書き」に設定されることになっていました。

[42] ですから、 document.domain = document.domain と同じ値を設定すると、 元の実効スクリプト起源とは異なる起源になりますから、元の実効スクリプト起源の別の文書にはアクセスできなくなります。
[43] 「手動上書き」値は直列化できませんが、 実効スクリプト起源直列化されることは無いはずなので、問題ありません。

[93] 実効スクリプト起源起源の統合により、 この値を使わない形の規定となりました。

ホストの定義の明確化

[66] 2016年2月には、ホストの解釈が URL Standard の定義に統一される形で明確化されました。

[52] Revamp the way document.domain is defined · whatwg/html@2a03759 ( 版) https://github.com/whatwg/html/commit/2a03759f2fbf4199d187c046074d574a9ae0e209

[54] Fix document.domain for IPv6 addresses to match browser behavior with respect to brackets · Issue #670 · whatwg/html ( 版) https://github.com/whatwg/html/issues/670

[25] 文書のドメインIPv6アドレスなら、その前後の [ と ] は省略した中身の部分だけを初期値としなければなりません >>17

[53] という規定が以前はありましたが、 Firefox のみそう実装しており、 Firefox も他のブラウザーに合わせて仕様変更したため >>54、 2016年2月に仕様からもこの規定は削除されました >>52

[21] 文書は、ドメイン (domain) を持ちます >>20

[24] 文書文書ドメインは、初期状態で次のように設定しなければなりません >>17

  1. [26] 文書閲覧文脈がない場合、
    1. [27] ドメインに設定します。
  2. [55] それ以外で、文書起源三項組の場合、
    1. [56] 文書起源ホストに設定します。
  3. [57] それ以外の場合、
    1. [58] ドメインに設定します。

実効スクリプト起源と起源の統合

[91] 2016年3月の改訂で実効スクリプト起源は廃止され、起源と統合されました。

[67] Remove the section on document.domain · w3c/webappsec-secure-contexts@40985fc ( 版) https://github.com/w3c/webappsec-secure-contexts/commit/40985fc5a7d81c08cacf86b04a7d041ea683c5f9

[68] Remove the origin aliasing concept · whatwg/html@438155d ( 版) https://github.com/whatwg/html/commit/438155d2a2255aa5ea84ae390744d8a8662ebec2

[77] Cleanup origin serialization · whatwg/html@5dcc1ee ( 版) https://github.com/whatwg/html/commit/5dcc1ee2124b5e54955845790bb47f5d1351d672

[81] Merge effective script origin into origin · whatwg/html@8a843f2 ( 版) https://github.com/whatwg/html/commit/8a843f2169a6864a3024c4329528dccb2051d275

[62] Use USVString for document.domain/referrer/cookie · whatwg/html@8170d82 ( 版) https://github.com/whatwg/html/commit/8170d82a2fc93c8ff7981c54aa4ccafd54204552

[64] Fix minor document.domain regression (annevk著, ) https://github.com/whatwg/html/commit/05cab5eca759b5ad6773189635d3e8bf4f9aab36

[65] "Allowed to use" should allow same-origin without the attribute · Issue #2184 · whatwg/html () https://github.com/whatwg/html/issues/2184

[107] Define document.domain in terms of a reusable algorithm (jcjones著, ) https://github.com/whatwg/html/commit/03bbc6e92b6b8c9735b4565722916d49fe3eab61

[108] Define document.domain in terms of a reusable algorithm (jcjones著, ) https://github.com/whatwg/html/commit/03bbc6e92b6b8c9735b4565722916d49fe3eab61

[31] Re: Single Trust and Same-Origin Policy v2 (Daniel Veditz著, ) https://lists.w3.org/Archives/Public/public-webappsec/2017Mar/0051.html

[32] Phasing out document.domain · Issue #829 · whatwg/html () https://github.com/whatwg/html/issues/829

[35] Remove the risk of `document.domain`. · Issue #10 · w3c/webappsec-secure-contexts () https://github.com/w3c/webappsec-secure-contexts/issues/10

[60] 1329764 - Support relaxing the same origin policy for WebAuthn () https://bugzilla.mozilla.org/show_bug.cgi?id=1329764

[61] Make document.domain's getter not conditonal on a browsing context (annevk著, ) https://github.com/whatwg/html/commit/c0d2a3208376d315c4101d09c72997415d23d8bc

[90] investigate if HTMLDocument.domain setter shouldn't throw when document doesn't have browsing context · Issue #1794 · whatwg/html () https://github.com/whatwg/html/issues/1794

[94] document.domain getter without browsing context · Issue #2697 · whatwg/html () https://github.com/whatwg/html/issues/2697

[95] Make document.domain's getter not conditonal on a browsing context by annevk · Pull Request #3742 · whatwg/html () https://github.com/whatwg/html/pull/3742

[96] Define hosts' public suffix and registrable domain. by mikewest · Pull Request #391 · whatwg/url () https://github.com/whatwg/url/pull/391

[101] Build upon URL rather than PSL (annevk著, ) https://github.com/whatwg/html/commit/326c64415ddff5f619433028bd5d99408dad6430

[102] "If the given value is not a registrable domain ..." · Issue #3711 · whatwg/html () https://github.com/whatwg/html/issues/3711

[103] "If the given value is not a registrable domain ..." · Issue #3711 · whatwg/html () https://github.com/whatwg/html/issues/3711

[104] Build upon URL rather than PSL by annevk · Pull Request #3735 · whatwg/html () https://github.com/whatwg/html/pull/3735

[105] Integrate Feature Policy concepts into HTML (clelland著, ) https://github.com/whatwg/html/commit/78741b7b5471ba213c68a22caff1a53c56d35ce8

[106] Tie document.domain to a new policy-controlled feature (mikewest著, ) https://github.com/whatwg/html/commit/33b566f8b590afd3531e3100827b1921eb636109

[110] Proposal: Control over `document.domain` · Issue #241 · w3c/webappsec-feature-policy () https://github.com/w3c/webappsec-feature-policy/issues/241

[111] Don't forbid document.domain getter · Issue #23 · w3c/webappsec-feature-policy () https://github.com/w3c/webappsec-feature-policy/issues/23

[112] 277084 - Disallow setting document.domain in sandboxed iframes - chromium - Monorail () https://bugs.chromium.org/p/chromium/issues/detail?id=277084

[113] 907892 - Disallow setting document.domain in sandboxed iframes () https://bugzilla.mozilla.org/show_bug.cgi?id=907892

[114] Tie 'document.domain' to a new policy-controlled feature. by mikewest · Pull Request #4170 · whatwg/html () https://github.com/whatwg/html/pull/4170