5430
|
1 |
(* Title: HOL/Auth/NSP_Bad
|
|
2 |
ID: $Id$
|
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
4 |
Copyright 1996 University of Cambridge
|
|
5 |
|
|
6 |
Inductive relation "ns_public" for the Needham-Schroeder Public-Key protocol.
|
|
7 |
Flawed version, vulnerable to Lowe's attack.
|
|
8 |
|
|
9 |
From page 260 of
|
|
10 |
Burrows, Abadi and Needham. A Logic of Authentication.
|
|
11 |
Proc. Royal Soc. 426 (1989)
|
|
12 |
*)
|
|
13 |
|
|
14 |
AddEs spies_partsEs;
|
|
15 |
AddDs [impOfSubs analz_subset_parts];
|
|
16 |
AddDs [impOfSubs Fake_parts_insert];
|
|
17 |
|
|
18 |
AddIffs [Spy_in_bad];
|
|
19 |
|
|
20 |
(*For other theories, e.g. Mutex and Lift, using AddIffs slows proofs down.
|
|
21 |
Here, it facilitates re-use of the Auth proofs.*)
|
|
22 |
|
|
23 |
AddIffs (map simp_of_act [Fake_def, NS1_def, NS2_def, NS3_def]);
|
|
24 |
|
|
25 |
Addsimps [Nprg_def RS def_prg_simps];
|
|
26 |
|
|
27 |
(*A "possibility property": there are traces that reach the end*)
|
|
28 |
Goal "A ~= B ==> EX NB. EX s: reachable Nprg. \
|
|
29 |
\ Says A B (Crypt (pubK B) (Nonce NB)) : set s";
|
|
30 |
by (REPEAT (resolve_tac [exI,bexI] 1));
|
|
31 |
by (res_inst_tac [("act", "NS3")] reachable.Acts 2);
|
|
32 |
by (res_inst_tac [("act", "NS2")] reachable.Acts 3);
|
|
33 |
by (res_inst_tac [("act", "NS1")] reachable.Acts 4);
|
|
34 |
br reachable.Init 5;
|
|
35 |
by (ALLGOALS Asm_simp_tac);
|
|
36 |
by (REPEAT_FIRST (resolve_tac [exI]));
|
|
37 |
by possibility_tac;
|
|
38 |
result();
|
|
39 |
|
|
40 |
|
|
41 |
(**** Inductive proofs about ns_public ****)
|
|
42 |
|
|
43 |
(*Nobody sends themselves messages*)
|
|
44 |
Goal "Invariant Nprg {s. ALL X. Says A A X ~: set s}";
|
|
45 |
by (rtac InvariantI 1);
|
|
46 |
by (Force_tac 1);
|
|
47 |
by (constrains_tac 1);
|
|
48 |
by Auto_tac;
|
|
49 |
qed "not_Says_to_self";
|
|
50 |
|
|
51 |
(** HOW TO USE?? They don't seem to be needed!
|
|
52 |
Addsimps [not_Says_to_self];
|
|
53 |
AddSEs [not_Says_to_self RSN (2, rev_notE)];
|
|
54 |
**)
|
|
55 |
|
|
56 |
|
|
57 |
(*can be used to simulate analz_mono_contra_tac
|
|
58 |
val analz_impI = read_instantiate_sg (sign_of thy)
|
|
59 |
[("P", "?Y ~: analz (spies ?evs)")] impI;
|
|
60 |
|
|
61 |
val spies_Says_analz_contraD =
|
|
62 |
spies_subset_spies_Says RS analz_mono RS contra_subsetD;
|
|
63 |
|
|
64 |
by (rtac analz_impI 2);
|
|
65 |
by (auto_tac (claset() addSDs [spies_Says_analz_contraD], simpset()));
|
|
66 |
*)
|
|
67 |
|
|
68 |
val parts_induct_tac =
|
|
69 |
(SELECT_GOAL o EVERY)
|
|
70 |
[etac reachable.induct 1,
|
|
71 |
Force_tac 1,
|
|
72 |
Full_simp_tac 1,
|
|
73 |
safe_tac (claset() delrules [impI,impCE]),
|
|
74 |
REPEAT (FIRSTGOAL analz_mono_contra_tac),
|
|
75 |
ALLGOALS Asm_simp_tac];
|
|
76 |
|
|
77 |
|
|
78 |
(** Theorems of the form X ~: parts (spies evs) imply that NOBODY
|
|
79 |
sends messages containing X! **)
|
|
80 |
|
|
81 |
(*Spy never sees another agent's private key! (unless it's bad at start)*)
|
|
82 |
Goal "Invariant Nprg {s. (Key (priK A) : parts (spies s)) = (A : bad)}";
|
|
83 |
by (rtac InvariantI 1);
|
|
84 |
by (Force_tac 1);
|
|
85 |
by (constrains_tac 1);
|
|
86 |
by Auto_tac;
|
|
87 |
qed "Spy_see_priK";
|
|
88 |
|
|
89 |
(** HOW TO USE??
|
|
90 |
Addsimps [Spy_see_priK];
|
|
91 |
*)
|
|
92 |
|
|
93 |
Goal "s : reachable Nprg ==> (Key (priK A) : parts (spies s)) = (A : bad)";
|
|
94 |
be reachable.induct 1;
|
|
95 |
by Auto_tac;
|
|
96 |
qed "Spy_see_priK";
|
|
97 |
Addsimps [Spy_see_priK];
|
|
98 |
|
|
99 |
Goal "s : reachable Nprg ==> (Key (priK A) : analz (spies s)) = (A : bad)";
|
|
100 |
by Auto_tac;
|
|
101 |
qed "Spy_analz_priK";
|
|
102 |
Addsimps [Spy_analz_priK];
|
|
103 |
|
|
104 |
AddSDs [Spy_see_priK RSN (2, rev_iffD1),
|
|
105 |
Spy_analz_priK RSN (2, rev_iffD1)];
|
|
106 |
|
|
107 |
|
|
108 |
(**** Authenticity properties obtained from NS2 ****)
|
|
109 |
|
|
110 |
(*It is impossible to re-use a nonce in both NS1 and NS2, provided the nonce
|
|
111 |
is secret. (Honest users generate fresh nonces.)*)
|
|
112 |
Goal "[| Crypt (pubK B) {|Nonce NA, Agent A|} : parts (spies s); \
|
|
113 |
\ Nonce NA ~: analz (spies s); s : reachable Nprg |] \
|
|
114 |
\ ==> Crypt (pubK C) {|NA', Nonce NA|} ~: parts (spies s)";
|
|
115 |
by (etac rev_mp 1);
|
|
116 |
by (etac rev_mp 1);
|
|
117 |
by (parts_induct_tac 1);
|
|
118 |
by (ALLGOALS Blast_tac);
|
|
119 |
qed "no_nonce_NS1_NS2";
|
|
120 |
|
|
121 |
(*Adding it to the claset slows down proofs...*)
|
|
122 |
val nonce_NS1_NS2_E = no_nonce_NS1_NS2 RSN (2, rev_notE);
|
|
123 |
|
|
124 |
|
|
125 |
(*Unicity for NS1: nonce NA identifies agents A and B*)
|
|
126 |
Goal "[| Nonce NA ~: analz (spies s); s : reachable Nprg |] \
|
|
127 |
\ ==> EX A' B'. ALL A B. \
|
|
128 |
\ Crypt (pubK B) {|Nonce NA, Agent A|} : parts (spies s) --> \
|
|
129 |
\ A=A' & B=B'";
|
|
130 |
by (etac rev_mp 1);
|
|
131 |
by (parts_induct_tac 1);
|
|
132 |
by (ALLGOALS (simp_tac (simpset() addsimps [all_conj_distrib])));
|
|
133 |
(*NS1*)
|
|
134 |
by (expand_case_tac "NA = ?y" 2 THEN Blast_tac 2);
|
|
135 |
(*Fake*)
|
|
136 |
by (Blast_tac 1);
|
|
137 |
val lemma = result();
|
|
138 |
|
|
139 |
Goal "[| Crypt(pubK B) {|Nonce NA, Agent A|} : parts(spies s); \
|
|
140 |
\ Crypt(pubK B') {|Nonce NA, Agent A'|} : parts(spies s); \
|
|
141 |
\ Nonce NA ~: analz (spies s); \
|
|
142 |
\ s : reachable Nprg |] \
|
|
143 |
\ ==> A=A' & B=B'";
|
|
144 |
by (prove_unique_tac lemma 1);
|
|
145 |
qed "unique_NA";
|
|
146 |
|
|
147 |
|
|
148 |
(*Tactic for proving secrecy theorems*)
|
|
149 |
val analz_induct_tac =
|
|
150 |
(SELECT_GOAL o EVERY)
|
|
151 |
[etac reachable.induct 1,
|
|
152 |
Force_tac 1,
|
|
153 |
Full_simp_tac 1,
|
|
154 |
safe_tac (claset() delrules [impI,impCE]),
|
|
155 |
ALLGOALS Asm_simp_tac];
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
(*Secrecy: Spy does not see the nonce sent in msg NS1 if A and B are secure*)
|
|
160 |
Goal "[| Says A B (Crypt(pubK B) {|Nonce NA, Agent A|}) : set s; \
|
|
161 |
\ A ~: bad; B ~: bad; s : reachable Nprg |] \
|
|
162 |
\ ==> Nonce NA ~: analz (spies s)";
|
|
163 |
by (etac rev_mp 1);
|
|
164 |
by (analz_induct_tac 1);
|
|
165 |
(*NS3*)
|
|
166 |
by (blast_tac (claset() addEs [nonce_NS1_NS2_E]) 4);
|
|
167 |
(*NS2*)
|
|
168 |
by (blast_tac (claset() addDs [unique_NA]) 3);
|
|
169 |
(*NS1*)
|
|
170 |
by (Blast_tac 2);
|
|
171 |
(*Fake*)
|
|
172 |
by (spy_analz_tac 1);
|
|
173 |
qed "Spy_not_see_NA";
|
|
174 |
|
|
175 |
|
|
176 |
(*Authentication for A: if she receives message 2 and has used NA
|
|
177 |
to start a run, then B has sent message 2.*)
|
|
178 |
Goal "[| Says A B (Crypt(pubK B) {|Nonce NA, Agent A|}) : set s; \
|
|
179 |
\ Says B' A (Crypt(pubK A) {|Nonce NA, Nonce NB|}): set s; \
|
|
180 |
\ A ~: bad; B ~: bad; s : reachable Nprg |] \
|
|
181 |
\ ==> Says B A (Crypt(pubK A) {|Nonce NA, Nonce NB|}): set s";
|
|
182 |
by (etac rev_mp 1);
|
|
183 |
(*prepare induction over Crypt (pubK A) {|NA,NB|} : parts H*)
|
|
184 |
by (etac (Says_imp_spies RS parts.Inj RS rev_mp) 1);
|
|
185 |
by (parts_induct_tac 1);
|
|
186 |
by (ALLGOALS Clarify_tac);
|
|
187 |
(*NS2*)
|
|
188 |
by (blast_tac (claset() addDs [Spy_not_see_NA, unique_NA]) 3);
|
|
189 |
(*NS1*)
|
|
190 |
by (Blast_tac 2);
|
|
191 |
(*Fake*)
|
|
192 |
by (blast_tac (claset() addDs [Spy_not_see_NA]) 1);
|
|
193 |
qed "A_trusts_NS2";
|
|
194 |
|
|
195 |
|
|
196 |
(*If the encrypted message appears then it originated with Alice in NS1*)
|
|
197 |
Goal "[| Crypt (pubK B) {|Nonce NA, Agent A|} : parts (spies s); \
|
|
198 |
\ Nonce NA ~: analz (spies s); \
|
|
199 |
\ s : reachable Nprg |] \
|
|
200 |
\ ==> Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set s";
|
|
201 |
by (etac rev_mp 1);
|
|
202 |
by (etac rev_mp 1);
|
|
203 |
by (parts_induct_tac 1);
|
|
204 |
by (Blast_tac 1);
|
|
205 |
qed "B_trusts_NS1";
|
|
206 |
|
|
207 |
|
|
208 |
|
|
209 |
(**** Authenticity properties obtained from NS2 ****)
|
|
210 |
|
|
211 |
(*Unicity for NS2: nonce NB identifies nonce NA and agent A
|
|
212 |
[proof closely follows that for unique_NA] *)
|
|
213 |
Goal "[| Nonce NB ~: analz (spies s); s : reachable Nprg |] \
|
|
214 |
\ ==> EX A' NA'. ALL A NA. \
|
|
215 |
\ Crypt (pubK A) {|Nonce NA, Nonce NB|} : parts (spies s) \
|
|
216 |
\ --> A=A' & NA=NA'";
|
|
217 |
by (etac rev_mp 1);
|
|
218 |
by (parts_induct_tac 1);
|
|
219 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [all_conj_distrib])));
|
|
220 |
(*NS2*)
|
|
221 |
by (expand_case_tac "NB = ?y" 2 THEN Blast_tac 2);
|
|
222 |
(*Fake*)
|
|
223 |
by (Blast_tac 1);
|
|
224 |
val lemma = result();
|
|
225 |
|
|
226 |
Goal "[| Crypt(pubK A) {|Nonce NA, Nonce NB|} : parts(spies s); \
|
|
227 |
\ Crypt(pubK A'){|Nonce NA', Nonce NB|} : parts(spies s); \
|
|
228 |
\ Nonce NB ~: analz (spies s); \
|
|
229 |
\ s : reachable Nprg |] \
|
|
230 |
\ ==> A=A' & NA=NA'";
|
|
231 |
by (prove_unique_tac lemma 1);
|
|
232 |
qed "unique_NB";
|
|
233 |
|
|
234 |
|
|
235 |
(*NB remains secret PROVIDED Alice never responds with round 3*)
|
|
236 |
Goal "[| Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s; \
|
|
237 |
\ ALL C. Says A C (Crypt (pubK C) (Nonce NB)) ~: set s; \
|
|
238 |
\ A ~: bad; B ~: bad; s : reachable Nprg |] \
|
|
239 |
\ ==> Nonce NB ~: analz (spies s)";
|
|
240 |
by (etac rev_mp 1);
|
|
241 |
by (etac rev_mp 1);
|
|
242 |
by (analz_induct_tac 1);
|
|
243 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [all_conj_distrib])));
|
|
244 |
by (ALLGOALS Clarify_tac);
|
|
245 |
(*NS3: because NB determines A*)
|
|
246 |
by (blast_tac (claset() addDs [unique_NB]) 4);
|
|
247 |
(*NS2: by freshness and unicity of NB*)
|
|
248 |
by (blast_tac (claset() addEs [nonce_NS1_NS2_E]) 3);
|
|
249 |
(*NS1: by freshness*)
|
|
250 |
by (Blast_tac 2);
|
|
251 |
(*Fake*)
|
|
252 |
by (spy_analz_tac 1);
|
|
253 |
qed "Spy_not_see_NB";
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
(*Authentication for B: if he receives message 3 and has used NB
|
|
258 |
in message 2, then A has sent message 3--to somebody....*)
|
|
259 |
Goal "[| Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s; \
|
|
260 |
\ Says A' B (Crypt (pubK B) (Nonce NB)): set s; \
|
|
261 |
\ A ~: bad; B ~: bad; s : reachable Nprg |] \
|
|
262 |
\ ==> EX C. Says A C (Crypt (pubK C) (Nonce NB)) : set s";
|
|
263 |
by (etac rev_mp 1);
|
|
264 |
(*prepare induction over Crypt (pubK B) NB : parts H*)
|
|
265 |
by (etac (Says_imp_spies RS parts.Inj RS rev_mp) 1);
|
|
266 |
by (parts_induct_tac 1);
|
|
267 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [ex_disj_distrib])));
|
|
268 |
by (ALLGOALS Clarify_tac);
|
|
269 |
(*NS3: because NB determines A (this use of unique_NB is more robust) *)
|
|
270 |
by (blast_tac (claset() addDs [Spy_not_see_NB]
|
|
271 |
addIs [unique_NB RS conjunct1]) 3);
|
|
272 |
(*NS1: by freshness*)
|
|
273 |
by (Blast_tac 2);
|
|
274 |
(*Fake*)
|
|
275 |
by (blast_tac (claset() addDs [Spy_not_see_NB]) 1);
|
|
276 |
qed "B_trusts_NS3";
|
|
277 |
|
|
278 |
|
|
279 |
(*Can we strengthen the secrecy theorem? NO*)
|
|
280 |
Goal "[| A ~: bad; B ~: bad; s : reachable Nprg |] \
|
|
281 |
\ ==> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s \
|
|
282 |
\ --> Nonce NB ~: analz (spies s)";
|
|
283 |
by (analz_induct_tac 1);
|
|
284 |
by (ALLGOALS Clarify_tac);
|
|
285 |
(*NS2: by freshness and unicity of NB*)
|
|
286 |
by (blast_tac (claset() addEs [nonce_NS1_NS2_E]) 3);
|
|
287 |
(*NS1: by freshness*)
|
|
288 |
by (Blast_tac 2);
|
|
289 |
(*Fake*)
|
|
290 |
by (spy_analz_tac 1);
|
|
291 |
(*NS3: unicity of NB identifies A and NA, but not B*)
|
|
292 |
by (forw_inst_tac [("A'","A")] (Says_imp_spies RS parts.Inj RS unique_NB) 1
|
|
293 |
THEN REPEAT (eresolve_tac [asm_rl, Says_imp_spies RS parts.Inj] 1));
|
|
294 |
by Auto_tac;
|
|
295 |
by (rename_tac "s B' C" 1);
|
|
296 |
|
|
297 |
(*
|
|
298 |
THIS IS THE ATTACK!
|
|
299 |
Level 8
|
|
300 |
!!s. [| A ~: bad; B ~: bad; s : reachable Nprg |]
|
|
301 |
==> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s -->
|
|
302 |
Nonce NB ~: analz (spies s)
|
|
303 |
1. !!s B' C.
|
|
304 |
[| A ~: bad; B ~: bad; s : reachable Nprg;
|
|
305 |
Says A C (Crypt (pubK C) {|Nonce NA, Agent A|}) : set s;
|
|
306 |
Says B' A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s; C : bad;
|
|
307 |
Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s;
|
|
308 |
Nonce NB ~: analz (spies s) |]
|
|
309 |
==> False
|
|
310 |
*)
|