File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,9 +9,7 @@ open http
99sig Document {
1010 src: Url, -- URL from which this document was originated
1111 content: Resource -> Time, -- the content of the document (i.e., DOM)
12- -- "document.domain" property, at any time it could match several hosts (if
13- -- for example is set to something like *.foo.com)
14- domain: Domain -> Time,
12+ domain: Domain -> Time, -- "document.domain" property
1513}
1614
1715sig Browser extends Client {
Original file line number Diff line number Diff line change @@ -9,7 +9,18 @@ open call[Endpoint]
99abstract sig Resource {}
1010abstract sig Endpoint {}
1111
12- sig Protocol, Domain, Port, Path {}
12+ sig Protocol, Port, Path {}
13+ sig Domain { subsumes: set Domain }
14+
15+ fact subsumesRule {
16+ all disj d, d1, d2: Domain |
17+ -- reflexive
18+ d in d.subsumes and
19+ -- assymetric
20+ (d1 in d.subsumes => d not in d1.subsumes) and
21+ -- transitive
22+ (d1 in d.subsumes and d2 in d1.subsumes => d2 in d.subsumes)
23+ }
1324
1425sig Url {
1526 protocol: Protocol,
Original file line number Diff line number Diff line change @@ -19,4 +19,8 @@ fun origin[u: Url] : Origin {
1919 {o: Origin | o.host = u.host and o.protocol = u.protocol and o.port = u.port }
2020}
2121
22+ fun origin[u: Url, h: Domain] : Origin {
23+ {o: Origin | o.host = h and o.protocol = u.protocol and o.port = u.port }
24+ }
25+
2226run {}
Original file line number Diff line number Diff line change @@ -48,13 +48,6 @@ sig WriteDom extends BrowserOp { newDom: Resource }{
4848 domain.end = domain.start
4949}
5050
51- // Modify the document.domain property
52- sig SetDomain extends BrowserOp { newDomain: set Domain }{
53- doc = from.context
54- domain.end = domain.start ++ doc -> newDomain
55- -- no change to the content of the document
56- content.end = content.start
57- }
5851
5952// Handlers for browser script events
6053abstract sig EventHandler extends Call {
@@ -72,9 +65,3 @@ pred noBrowserChange[start, end: Time] {
7265pred noDocumentChange[start, end: Time] {
7366 content.end = content.start and domain.end = domain.start
7467}
75-
76- /* Commands */
77-
78- // Can a script set the "document.domain" property with a new_domain that doesn't
79- // match the src?
80- check { all sd: SetDomain | sd.doc.src.host in sd.newDomain }
Original file line number Diff line number Diff line change 1+ /**
2+ * setdomain.als
3+ * A model of the operations related to the document.domain
4+ * property
5+ */
6+ module setDomain
7+
8+ open http
9+ open script
10+
11+ // Modify the document.domain property
12+ sig SetDomain extends BrowserOp { newDomain: Domain }{
13+ doc = from.context
14+ domain.end = domain.start ++ doc -> newDomain
15+ -- no change to the content of the document
16+ content.end = content.start
17+ }
18+
19+ // Scripts can only set the domain property to only one that is a right-hand,
20+ // fully-qualified fragment of its hostname
21+ fact setDomainRule {
22+ all d: Document | d.src.host in (d.domain.Time).subsumes
23+ }
24+
25+ /* Commands */
26+
27+ // Can a script set the "document.domain" property with a new_domain that
28+ // doesn't match the host of the src?
29+ check { all sd: SetDomain | sd.doc.src.host = sd.newDomain }
30+
31+
32+ // Can a script set the "document.domain" property with a new_domain that
33+ // doesn't match the host of the src even if there are no domains that subsume
34+ // others?
35+ run {
36+ some SetDomain
37+ all sd: SetDomain | sd.doc.src.host != sd.newDomain
38+ no d: Domain | some d.subsumes
39+ }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ module sop
77open http
88open browser
99open script
10+ open setDomain
1011open cors
1112
1213pred sameOriginPolicy {
@@ -19,9 +20,13 @@ pred domSop {
1920 all c: ReadDom + WriteDom |
2021 -- A script can only access the DOM of a document with the same origin or
2122 origin[c.doc.src] = origin[c.from.context.src] or
22- -- (relaxation) script' s context and the target document have the same
23- -- domain property
24- c.doc.domain = c.from.context.domain
23+ -- (relaxation) the domain property of both the script' s context and the
24+ -- target document has either been set or unset in both and
25+ (#((c.prevs <: SetDomain).doc & (c.doc + c.from.context)) != 1 and
26+ -- they have the same origin (using the domain property as the host and not
27+ -- the src host)
28+ origin[c.doc.src, c.doc.domain.(c.start)] =
29+ origin[c.from.context.src, c.from.context.domain.(c.start)])
2530}
2631
2732pred xmlHttpReqSop {
@@ -31,3 +36,9 @@ pred xmlHttpReqSop {
3136 -- (relaxation) it' s a CORS request
3237 x in CorsRequest
3338}
39+
40+
41+ /* Commands */
42+
43+ // Can a script read or write the DOM of a document with another origin?
44+ check { no c: ReadDom + WriteDom | origin[c.doc.src] != origin[c.from.context.src] }
You can’t perform that action at this time.
0 commit comments