author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Thu, 25 Sep 2014 00:24:41 +0100 | |
changeset 175 | 4ebc97e6fdf0 |
parent 174 | e2180cead443 |
child 176 | 5336ad2fd3fa |
permissions | -rw-r--r-- |
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
1 |
\documentclass{article} |
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
\usepackage{../style} |
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
3 |
\usepackage{../langs} |
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
5 |
\lstset{language=JavaScript} |
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
|
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
7 |
\begin{document} |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
|
167
d8657ff8cca1
typos
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
160
diff
changeset
|
9 |
\section*{Handout 1 (Security Engineering)} |
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
|
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
Much of the material and inspiration in this module is taken |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
from the works of Bruce Schneier, Ross Anderson and Alex |
159
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
13 |
Halderman. I think they are the world experts in the area of |
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
14 |
security engineering. I especially like that they argue that a |
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
15 |
security engineer requires a certain \emph{security mindset}. |
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
16 |
Bruce Schneier for example writes: |
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
|
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
\begin{quote} |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
\it ``Security engineers --- at least the good ones --- see |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
the world differently. They can't walk into a store without |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
noticing how they might shoplift. They can't use a computer |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
without wondering about the security vulnerabilities. They |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
can't vote without trying to figure out how to vote twice. |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
They just can't help it.'' |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
\end{quote} |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
|
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
27 |
\begin{quote} |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
\it ``Security engineering\ldots requires you to think |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
29 |
differently. You need to figure out not how something works, |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
30 |
but how something can be made to not work. You have to imagine |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
31 |
an intelligent and malicious adversary inside your system |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
\ldots, constantly trying new ways to |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
subvert it. You have to consider all the ways your system can |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
fail, most of them having nothing to do with the design |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
35 |
itself. You have to look at everything backwards, upside down, |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
36 |
and sideways. You have to think like an alien.'' |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
\end{quote} |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
38 |
|
159
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
39 |
\noindent In this module I like to teach you this security |
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
40 |
mindset. This might be a mindset that you think is very |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
41 |
foreign to you---after all we are all good citizens and not |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
42 |
hack into things. I beg to differ: You have this mindset |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
43 |
already when in school you were thinking, at least |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
44 |
hypothetically, about ways in which you can cheat in an exam |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
45 |
(whether it is about hiding notes or looking over the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
46 |
shoulders of your fellow pupils). Right? To defend a system, |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
47 |
you need to have this kind mindset and be able to think like |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
48 |
an attacker. This will include understanding techniques that |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
49 |
can be used to compromise security and privacy in systems. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
50 |
This will many times result in insights where well-intended |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
51 |
security mechanisms made a system actually less |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
52 |
secure.\smallskip |
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
53 |
|
159
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
54 |
{\Large\bf Warning!} However, don’t be evil! Using those |
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
55 |
techniques in the real world may violate the law or King’s |
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
56 |
rules, and it may be unethical. Under some circumstances, even |
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
57 |
probing for weaknesses of a system may result in severe |
160
4cbd6ca025e6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
159
diff
changeset
|
58 |
penalties, up to and including expulsion, fines and |
159
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
59 |
jail time. Acting lawfully and ethically is your |
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
60 |
responsibility. Ethics requires you to refrain from doing |
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
61 |
harm. Always respect privacy and rights of others. Do not |
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
62 |
tamper with any of King's systems. If you try out a technique, |
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
63 |
always make doubly sure you are working in a safe environment |
160
4cbd6ca025e6
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
159
diff
changeset
|
64 |
so that you cannot cause any harm, not even accidentally. |
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
65 |
Don't be evil. Be an ethical hacker.\medskip |
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
66 |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
67 |
\noindent |
169
2866fae8c1cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
168
diff
changeset
|
68 |
In this lecture I want to make you familiar with the security mindset |
2866fae8c1cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
168
diff
changeset
|
69 |
and dispel the myth that encryption is the answer to all security |
2866fae8c1cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
168
diff
changeset
|
70 |
problems (it is certainly often part of an answer, but almost always |
2866fae8c1cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
168
diff
changeset
|
71 |
never a sufficient one). This is actually an important thread going |
159
77cf0362b87a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
158
diff
changeset
|
72 |
through the whole course: We will assume that encryption works |
169
2866fae8c1cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
168
diff
changeset
|
73 |
perfectly, but still attack ``things''. By ``works perfectly'' we mean |
2866fae8c1cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
168
diff
changeset
|
74 |
that we will assume encryption is a black box and, for example, will |
2866fae8c1cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
168
diff
changeset
|
75 |
not look at the underlying mathematics and break the |
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
76 |
algorithms.\footnote{Though fascinating this might be.} |
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
77 |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
78 |
For a secure system, it seems, four requirements need to come |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
79 |
together: First a security policy (what is supposed to be |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
80 |
achieved?); second a mechanism (cipher, access controls, |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
81 |
tamper resistance etc); third the assurance we obtain from the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
82 |
mechanism (the amount of reliance we can put on the mechanism) |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
83 |
and finally the incentives (the motive that the people |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
84 |
guarding and maintaining the system have to do their job |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
85 |
properly, and also the motive that the attackers have to try |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
86 |
to defeat your policy). The last point is often overlooked, |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
87 |
but plays an important role. To illustrate this lets look at |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
88 |
an example. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
89 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
90 |
The questions is whether the Chip-and-PIN system with credit |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
91 |
cards is more secure than the older method of signing receipts |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
92 |
at the till. On first glance, Chip-and PIN seems obviously |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
93 |
more secure and this was also the central plank in the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
94 |
``marketing speak'' of the banks behind Chip-and-PIN. The |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
95 |
earlier system was based on a magnetic stripe or a mechanical |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
96 |
imprint on the card and required customers to sign receipts at |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
97 |
the till whenever they bought something. This signature |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
98 |
authorises the transactions. Although in use for a long time, |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
99 |
this system had some crucial security flaws, including making |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
100 |
clones of credit cards and forging signatures. Chip-and-PIN, |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
101 |
as the name suggests, relies on data being stored on |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
102 |
a chip on the card and a PIN number for authorisation. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
103 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
104 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
105 |
Although the banks involved trumpeted their system as being |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
106 |
secure and indeed fraud rates initially went down, security |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
107 |
researchers were not convinced (especially the group around |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
108 |
Ross Anderson). To begin with, the Chip-and-PIN system |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
109 |
introduced a ``new player'' that needed to be trusted: the PIN |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
110 |
terminals and their manufacturers. Of course it was claimed |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
111 |
that these terminals are tamper-resistant, but needless to say |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
112 |
this was a weak link in the system, which criminals |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
113 |
successfully attacked. Some terminals were even so skilfully |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
114 |
manipulated that they transmitted PIN numbers via a built-in |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
115 |
mobile phone connection. To mitigate this security flaw, you |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
116 |
need to vet quite closely the supply chain of such |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
117 |
terminals---something that also needs to be done in other |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
118 |
industries. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
119 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
120 |
Later on, Ross Anderson and his group managed to launch |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
121 |
man-in-the-middle attacks against Chip-and-PIN. Essentially |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
122 |
they made the terminal think the correct PIN was entered and |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
123 |
the card think that a signature was used. This flaw was |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
124 |
mitigated by requiring that a link between the card and the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
125 |
bank is established at every time the card is used. Even |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
126 |
later this group found another problem with Chip-and-PIN and |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
127 |
ATMs which do not generate random enough numbers (nonces) |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
128 |
on which the security of the underlying protocols relies. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
129 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
130 |
The problem with all this is that the banks who introduced |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
131 |
Chip-and-PIN managed to shift the liability for any fraud and |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
132 |
the burden of proof onto the customer with the new system. In |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
133 |
the old system, the banks had to prove that the customer used |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
134 |
the card, which they often did not bother about. In effect if |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
135 |
fraud occurred the customers were either refunded fully or |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
136 |
lost only a small amount of money. This |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
137 |
taking-responsibility-of-potential-fraud was part of the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
138 |
``business plan'' of the banks and did not reduce their |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
139 |
profits too much. Since they successfully claimed that their |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
140 |
Chip-and-PIN system is secure, banks were able to point the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
141 |
finger at the customer when fraud occurred: it must have been |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
142 |
the fault of the customer, who must have been negligent |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
143 |
loosing the PIN. The customer had almost no means to defend |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
144 |
themselves in such situations. That is why the work of |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
145 |
\emph{ethical} hackers like Ross Anderson's group was so |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
146 |
important, because they and others established that the bank's |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
147 |
claim, their system is secure and it must have been the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
148 |
customer's fault, was bogus. In 2009 for example the law |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
149 |
changed the burden of proof back to the banks whether |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
150 |
it was really the customer who used a card or not. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
151 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
152 |
It is a classic example where a security design principle was |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
153 |
violated: The one who is in the position to improve security, |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
154 |
also needs to bear the financial losses if things go wrong. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
155 |
Otherwise, you end up with an insecure system. In case of the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
156 |
Chip-and-PIN system, no good security engineer would actually |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
157 |
think that it is secure: the specification of the EMV protocol |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
158 |
(underlying Chip-and-PIN) is some 700 pages long, but still |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
159 |
leaves out many things (like how to implement a good random |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
160 |
number generator). Moreover, banks can add their own |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
161 |
sub-protocols to it. With all the experience we already have, |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
162 |
it is as clear as day that criminals were able to poke holes |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
163 |
into it. With how the system was set up, the banks had no |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
164 |
incentive to come up with a system that is really secure. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
165 |
Getting the incentives right in favour of security is often a |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
166 |
tricky business. |
173
9126c13a7d93
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
169
diff
changeset
|
167 |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
168 |
\subsection*{Of Cookies and Salts} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
169 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
170 |
Lets look at another example which helps us to understand how |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
171 |
passwords should be verified and stored. Imagine you need to |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
172 |
develop a web-application that has the feature of recording |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
173 |
how many times a customer visits a page. For example to |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
174 |
give a discount whenever the customer visited a webpage some |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
175 |
$x$ number of times (say $x$ equal $5$). For a number of years |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
176 |
the webpage of the New York Times operated in this way: it |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
177 |
allowed you to read ten articles per months for free; if |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
178 |
you wanted to read more you had to pay. There is one more |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
179 |
constraint: we want to store the information about the number |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
180 |
of times a customer has visited inside a cookie. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
181 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
182 |
A typical web-application works as follows: The browser sends |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
183 |
a GET request for a particular page to a server. The server |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
184 |
answers is request. A simple JavaScript program that realises |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
185 |
a ``hello world'' webpage is as follows: |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
186 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
187 |
\begin{center} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
188 |
\lstinputlisting{../progs/ap0.js} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
189 |
\end{center} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
190 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
191 |
\noindent The interesting lines are 4 to 7 where the answer |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
192 |
to the GET request is generated\ldots in this case it is just |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
193 |
a simple string. This program is run on the server and will |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
194 |
be run whenever a browser initiates such a GET request. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
195 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
196 |
For our web-application of interest is the feature that the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
197 |
server when answering the request can store some information |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
198 |
on the client. This information is called a \emph{cookie}. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
199 |
The next time the browser makes another GET request to the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
200 |
same webpage, this cookie can be read by the browser. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
201 |
Therefore we can use a cookie in order to store a counter |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
202 |
recording the number of times a webpage has been visited. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
203 |
This can be realised with the following small program |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
204 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
205 |
\begin{center} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
206 |
\lstinputlisting{../progs/ap2.js} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
207 |
\end{center} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
208 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
209 |
\noindent The overall structure of this code is the same as |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
210 |
the earlier program: Lines 7 to 17 generate the answer to a |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
211 |
GET-request. The new part is in Line 8 where we read the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
212 |
cookie called \pcode{counter}. If present, this cookie will be |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
213 |
send together with the GET-request from the client. The value |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
214 |
of this counter will come in form of a string, therefore we |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
215 |
use the function \pcode{parseInt} in order to transform it |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
216 |
into a string. In case the cookie is not present, or has been |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
217 |
deleted, we default the counter to zero. The odd looking |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
218 |
construction \code{...|| 0} is realising this in JavaScript. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
219 |
In Line 9 we increase the counter by one and store it back |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
220 |
to the client (under the name \pcode{counter}, since potentially |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
221 |
more than one value could be stored). In Lines 10 to 15 we |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
222 |
test whether this counter is greater or equal than 5 and |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
223 |
send accordingly a message back to the client. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
224 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
225 |
Let us step back and analyse this program from a security |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
226 |
perspective. We store a counter in plain text on the client's |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
227 |
browser (which is not under our control at all). Depending on |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
228 |
this value we want to unlock a resource (like a discount) when |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
229 |
it reaches a threshold. If the client deletes the cookie, then |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
230 |
the counter will just be reset to zero. This does not bother |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
231 |
us, because the purported discount will just be granted later. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
232 |
This does not lose us any (hypothetical) money. What we need |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
233 |
to be concerned about is when a client artificially increases |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
234 |
this counter without having visited our web-page. This is |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
235 |
actually a trivial task for a knowledgeable person, since |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
236 |
there are convenient tools that allow us to set a cookie to an |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
237 |
arbitrary value, for example above our threshold for the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
238 |
discount. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
239 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
240 |
There is no real way to prevent this kind of tampering with |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
241 |
cookies, because the whole purpose of cookies is that they are |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
242 |
stored on the client's side, which from the the server's |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
243 |
perspective is in a potentially hostile environment. What we |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
244 |
need to ensure is the integrity of this counter in this |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
245 |
hostile environment. We could think of encrypting the counter. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
246 |
But this has two drawbacks to do with the key for encryption. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
247 |
If you use a `global' key for all our client's that visit our |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
248 |
site, then we risk that our whole ``business'' might colapse |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
249 |
when this key gets known to the outside world. Suddenly all |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
250 |
cookies we might have set in the past, can now be manipulated. |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
251 |
If on the other hand, we use a ``private'' key for every |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
252 |
client, then we have to solve the problem of having to |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
253 |
securely store this key on our server side (obviously we |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
254 |
cannot store the key with the client because then the client |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
255 |
again has all data to tamper with the counter; and obviously |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
256 |
we also cannot encrypt the key, lest we can solve a |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
257 |
chicken-and-egg problem). So encryption seems to not solve the |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
258 |
problem we face with the integrity of our counter. |
169
2866fae8c1cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
168
diff
changeset
|
259 |
|
175
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
260 |
Fortunately, \emph{hash function} seem to be more suitable for |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
261 |
our purpose. Like encryption, hash functions scrambles data |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
262 |
but in such a way that it is easy to calculate the output of a |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
263 |
has function from the input. But it is hard (i.e.~practically |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
264 |
impossible) to calculate the input from knowing the output. |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
265 |
Therefore has functions are often called one-way functions. |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
266 |
There are several such hashing function. For example SHA-1 |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
267 |
would has the string \pcode{"hello world"} to |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
268 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
269 |
\begin{center} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
270 |
\pcode{2aae6c35c94fcfb415dbe95f408b9ce91ee846ed} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
271 |
\end{center} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
272 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
273 |
\noindent Another handy feature of hash functions is that if |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
274 |
the input changes a little bit, the output changes |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
275 |
drastically. For example \pcode{"iello world"} produces under |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
276 |
SHA-1 the output |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
277 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
278 |
\begin{center} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
279 |
\pcode{d2b1402d84e8bcef5ae18f828e43e7065b841ff1} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
280 |
\end{center} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
281 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
282 |
\noindent That means it is not predictable what the output |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
283 |
will be from input that is ``close by''. |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
284 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
285 |
We can use hashes and store in the cookie the value of the |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
286 |
counter together with its hash. We need to store both pieces |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
287 |
of data such we can extract both components (below I will just |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
288 |
separate them using a \pcode{"-"}). If we now read back the |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
289 |
cookie when the client visits our webpage, we can extract the |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
290 |
counter, hash it again and compare the result to the stored |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
291 |
hash value inside the cookie. If these hashes disagree, then |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
292 |
we can deduce that cookie has been tampered with. |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
293 |
Unfortunately if they agree, we can still not be entirely sure |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
294 |
that not a clever hacker has tampered with the cookie. The |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
295 |
reason is that the hacker can see the clear text part of the |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
296 |
cookie, say \pcode{3}, and its hash. It does not take much |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
297 |
trial and error to find out that we used the SHA-1 hashing |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
298 |
functions and then graft a cookie accordingly. This is eased |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
299 |
by the fact that for SHA-1 many strings and corresponding |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
300 |
hashvalues are precalculated. Type into Google for example the |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
301 |
hash value for \pcode{"hello wolrd"} and you will actually |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
302 |
pretty quickly find that it was generated by \pcode{"hello |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
303 |
wolrd"}. This defeats the purpose of a hashing functions and |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
304 |
would not help us for our web-applications. The corresponding |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
305 |
attack is called \emph{dictionary attack}\ldots hashes are not |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
306 |
reversed by brute force calculations, that is trying out all |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
307 |
possible combinations. |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
308 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
309 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
310 |
There is one ingredient missing, which happens to be called |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
311 |
\emph{salt}. The salt is a random key, which is added to the |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
312 |
counter before the hash is calculated. In our case we need |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
313 |
to keep the salt secrete. |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
314 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
315 |
\begin{figure}[p] |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
316 |
\lstinputlisting{../progs/App3.js} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
317 |
\end{figure} |
169
2866fae8c1cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
168
diff
changeset
|
318 |
|
2866fae8c1cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
168
diff
changeset
|
319 |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
320 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
321 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
322 |
Note ....NYT |
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
323 |
\end{document} |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
324 |
|
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
325 |
%%% Local Variables: |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
326 |
%%% mode: latex |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
327 |
%%% TeX-master: t |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
328 |
%%% End: |