-
Notifications
You must be signed in to change notification settings - Fork 0
/
engine.als
267 lines (203 loc) · 7.41 KB
/
engine.als
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
open declarations as d
open browserFacts
open requestAPIFacts
pred isNotCookieOwnerOrClient[c:madeBy.NormalPrincipal,ne : NetworkEndpoint]{
ne !in c.madeBy.servers
no t:HTTPTransaction | t.resp.from in c.madeBy.servers and ne = t.req.from
}
pred SecureUsesSecureCookies {
all e:HTTPResponse |
all c:(e.headers & SetCookieHeader).thecookie |
e.from in SECURE.servers implies c in SecureCookie
}
pred CorrectSTSRequirement {
all t : ScriptContext.transactions | some (getPrincipalFromOrigin[t.req.host] &SECURE) implies correctHTTPSTransaction[t] //implies HTTPS
}
pred noDNSRebinding {
all p:Principal | no d:DNS | d in p.dnslabels and d.resolvesTo !in p.servers
}
fact principalsOnlyTrustThemselves{
all p:Principal, response:p.servers[from] | (response.headers & AccessControlAllowOrigin).origin.dnslabel in p.dnslabels
}
fact {
NetworkEndpoint = Principal.servers + HTTPClient
// all sc:ScriptContext | no disj t1,t2:sc.transactions | some ( t1.cause & t2.cause & HTTPTransaction)
// no client:HTTPClient | client in Principal.servers
// all t1,t2:HTTPTransaction | t1=t2.cause implies t1+t2 in ScriptContext.transactions
// ScriptContext only connects to DNSLabels that it knows exists/owned by some Principal
DNS in Principal.dnslabels
}
run WebAttackerCanBeClient {
some req:HTTPRequest | req.host.dnslabel in SECURE.dnslabels and req.from in WEBATTACKER.servers
} for 6 but exactly 2 Time
run DNSRebindingIsPossible {
some p : Principal - SECURE | some (p.dnslabels.resolvesTo & SECURE.servers)
} for 5
run ActiveAttackerCanSpoof {
some resp:HTTPResponse | resp.from !in resp.host.dnslabel.resolvesTo
} for 8
check NonActiveAttackerCantSpoof {
no resp:HTTPResponse | resp.from !in resp.host.dnslabel.resolvesTo
} for 8 but exactly 0 ACTIVEATTACKER
run GoodCanBeForged{
some t:ScriptContext.transactions | let p = getPrincipalFromOrigin[t.resp.host] | {
some ( p & GOOD )
t.resp.from !in p.servers
}
} for 6 but exactly 1 ACTIVEATTACKER,3 Time
run SecureCanBeForged{
some t:ScriptContext.transactions | let p = getPrincipalFromOrigin[t.resp.host] | {
some ( p & SECURE)
t.resp.from !in p.servers
}
} for 6 but exactly 1 ACTIVEATTACKER,3 Time
check SecureCantBeForgedbyNonActive{
no t:ScriptContext.transactions | let p = getPrincipalFromOrigin[t.resp.host] | {
some ( p & SECURE)
t.resp.from !in p.servers
}
} for 8 but exactly 0 ACTIVEATTACKER//,3 Time//,0 HTTPHeader,0 RequestAPI
check HTTPSProtectsNormalPrincipals{
no t:ScriptContext.transactions | {
t.resp.from !in getPrincipalFromOrigin[t.resp.host].servers
t.resp.host.schema = HTTPS
some (getPrincipalFromOrigin[t.resp.host] & NormalPrincipal )
(transactions.t).location in smartClient
}
} for 8
run HTTPSDoesNotProtectOthers{
no t:ScriptContext.transactions | t.resp.from !in getPrincipalFromOrigin[t.resp.host].servers and t.resp.host.schema = HTTPS and getPrincipalFromOrigin[t.resp.host] in NormalPrincipal and (transactions.t).location in smartClient
} for 4 but exactly 3 Time
check STSProtectsSecure{
CorrectSTSRequirement implies {
no t:ScriptContext.transactions | let p = getPrincipalFromOrigin[t.resp.host] | {
some ( p & SECURE)
t.resp.from !in p.servers
(transactions.t).location in smartClient
}
}
} for 8// 5 but exactly 3 Time
run PrincipalsCanControlHTTPClient {
some (Principal.servers & HTTPClient)
} for 4
check GOODCACERTS{
no c:Certificate |{
c.ca = GOODCA
c.ne !in (dnslabels.(c.cn).servers)
c.cn.parent != DNSRoot
}
} for 8
check originHeaderProtectsFromCSRF{
no t:HTTPTransaction | {
// Transaction is in a OriginDraftConformingBrowser
some ( (transactions.t).location & (OriginDraftConformingBrowsers))
//Intended for an OriginAware Principal
some getPrincipalFromOrigin[t.req.host]
getPrincipalFromOrigin[t.req.host] in ORIGINAWARE
// Its a non trivial request
t.req.method in Method - safeMethods
// The OriginAwareServer Responds
some t.resp
t.resp.from in ORIGINAWARE.servers
//CSRF Protection protects against only 200 responses
t.resp.statusCode = c200
//And the WebAttacker is involved in the causal chain
some (WEBATTACKER.servers & involvedServers[t])
}
} for 10 but 0 ACTIVEATTACKER, 1 WEBATTACKER, 1 ORIGINAWARE, 0 GOOD, 0 SECURE ,0 Secret, 1 HTTPClient//, 2 Origin, 0 PreFlightRequest, 0 CORSRequestHeader, 0 CORSResponseHeader, 0 Secret//,8 Time//, 1 RequestAPI, 0 Secret
fun involvedServers[t:HTTPTransaction]:set NetworkEndpoint{
( (t.*cause & HTTPTransaction).resp.from + getPrincipalFromOrigin[(transactions.t).owner].servers )
}
check noAttackerInvolvedDeleteToSecure{
noDNSRebinding implies {
no t:ScriptContext.transactions | {
(transactions.t).location in OriginDraftConformingBrowsers
some (getPrincipalFromOrigin[t.req.host] & SECURE)
some ((Principal - NormalPrincipal).servers & involvedServers[t])
t.req.method in DELETE + PUT
}
}
} for 6 but 0 ACTIVEATTACKER
run GoodCookiesCanLeak{
some c:Cookie,ne:NetworkEndpoint,e:Event,sc:ScriptContext | some t:sc.transactions {
c.madeBy in GOOD
ne !in GOOD.servers
httpPacketHasCookie[c,t.resp]
ne != sc.location
t.resp.from in GOOD.servers
hasKnowledgeCookie[c,ne,e]
}
} for 6
run SecureServerCookieCanLeak{
some sc:ScriptContext, c:Cookie,ne:NetworkEndpoint,e:Event | some t:sc.transactions {
c.madeBy in SECURE
ne !in SECURE.servers
httpPacketHasCookie[c,t.resp]
ne != t.req.from
t.resp.from in SECURE.servers
// so there is ne which is not the client nor the SecureServer who has knowledge
hasKnowledgeCookie[c,ne,e]
}
} for 5
run SecureCookiesLeak_DumbClients{
some sc:ScriptContext, c:SecureCookie,ne:NetworkEndpoint,e:Event | some t:sc.transactions {
c.madeBy in SECURE
ne !in SECURE.servers
httpPacketHasCookie[c,t.resp]
ne != t.req.from
t.resp.from in SECURE.servers
// so there is ne which is not the client nor the SecureServer who has knowledge
hasKnowledgeCookie[c,ne,e]
}
} for 6//but exactly 12 Time
check SecureCookiesDontLeak_SmartClient{
no sc:ScriptContext, c:SecureCookie,ne:NetworkEndpoint,e:Event | some t:sc.transactions {
c.madeBy in SECURE
ne !in SECURE.servers
httpPacketHasCookie[c,t.resp]
ne != t.req.from
t.resp.from in SECURE.servers
// so there is ne which is not the client nor the SecureServer who has knowledge
hasKnowledgeCookie[c,ne,e]
sc.location in smartClient
}
} for 6
check STSMeansNoLeakageForAnyone{
CorrectSTSRequirement implies {
no sc:ScriptContext, c:SecureCookie,ne:NetworkEndpoint,e:Event | some t:sc.transactions {
c.madeBy in SECURE
ne !in SECURE.servers
httpPacketHasCookie[c,t.resp]
ne != t.req.from
t.resp.from in SECURE.servers
// so there is ne which is not the client nor the SecureServer who has knowledge
hasKnowledgeCookie[c,ne,e]
// sc.location in smartClient
}
}
} for 6
fun trSchema[]:HTTPTransaction -> Schema {
(ScriptContext.transactions <: iden).req.host.schema
//~((~owner).transactions).schema
}
fun requestTo_http[]:HTTPRequest->Principal {
d/HTTPRequest <: host.dnslabel.~dnslabels
}
fun responseFrom_http[]:HTTPResponse->Principal {
d/HTTPResponse <: host.dnslabel.~dnslabels
}
fun scOwner[]: ScriptContext -> Principal {
owner.dnslabel.~dnslabels
}
fun httpreqOrigin[]:HTTPRequest -> Principal {
(d/HTTPRequest <: headers).theorigin.dnslabel.~dnslabels
}
fun responseFrom_actual[]:HTTPResponse -> Principal {
HTTPResponse <: from.~servers
}
fun DNSOwnedBy[]:DNS->Principal {
~dnslabels
}
fun DNSownerServers[]:DNS->NetworkEndpoint {
~dnslabels.servers
}