author | Christian Urban <urbanc@in.tum.de> |
Sat, 09 Jun 2018 21:01:46 +0100 | |
changeset 565 | d58f8e3e78a5 |
parent 539 | 48e0c8b03ae5 |
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 |
|
366
34a8f73b2c94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
365
diff
changeset
|
7 |
|
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
\begin{document} |
565 | 9 |
\fnote{\copyright{} Christian Urban, King's College London, 2014, 2015, 2016} |
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
|
518 | 11 |
% passwords at dropbox |
565 | 12 |
% %https://blogs.dropbox.com/tech/2016/09/how-dropbox-securely-stores-your-passwords/ |
518 | 13 |
|
14 |
||
565 | 15 |
%Ross anderson https://youtu.be/FY2YKxBxOkg |
453
5921eebd9add
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
450
diff
changeset
|
16 |
%http://www.scmagazineuk.com/amazon-launches-open-source-tls-implementation-s2n/article/424360/ |
431
4b53f83c070c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
383
diff
changeset
|
17 |
|
457
38ef1ef6082d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
455
diff
changeset
|
18 |
%Singapurs Behörden gehen offline |
38ef1ef6082d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
455
diff
changeset
|
19 |
|
462
33dcbafb27ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
459
diff
changeset
|
20 |
% how to store passwords |
565 | 21 |
% https://nakedsecurity.sophos.com/2013/11/20/serious-security-how-to-store-your-users-passwords-safely/ |
457
38ef1ef6082d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
455
diff
changeset
|
22 |
|
508
c7b690b17b1d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
463
diff
changeset
|
23 |
%hashes |
c7b690b17b1d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
463
diff
changeset
|
24 |
%http://web.archive.org/web/20071226014140/http://www.cits.rub.de/MD5Collisions/ |
c7b690b17b1d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
463
diff
changeset
|
25 |
%https://blog.codinghorror.com/speed-hashing/ |
c7b690b17b1d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
463
diff
changeset
|
26 |
%https://blogs.dropbox.com/tech/2016/09/how-dropbox-securely-stores-your-passwords/ |
c7b690b17b1d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
463
diff
changeset
|
27 |
|
509
aa2a09b9823c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
508
diff
changeset
|
28 |
% Hello Kitty database stolen |
aa2a09b9823c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
508
diff
changeset
|
29 |
% https://nakedsecurity.sophos.com/2017/01/10/stolen-details-of-3-3m-hello-kitty-fans-including-kids-published-online/ |
aa2a09b9823c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
508
diff
changeset
|
30 |
% |
aa2a09b9823c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
508
diff
changeset
|
31 |
|
aa2a09b9823c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
508
diff
changeset
|
32 |
% IoT |
aa2a09b9823c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
508
diff
changeset
|
33 |
% https://nakedsecurity.sophos.com/2015/10/26/the-internet-of-things-stop-the-things-i-want-to-get-off/ |
aa2a09b9823c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
508
diff
changeset
|
34 |
|
514 | 35 |
% cloning creditc cards and passports |
565 | 36 |
% https://www.youtube.com/watch?v=-4_on9zj-zs |
514 | 37 |
|
38 |
||
167
d8657ff8cca1
typos
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
160
diff
changeset
|
39 |
\section*{Handout 1 (Security Engineering)} |
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
40 |
|
565 | 41 |
Much of the material and inspiration in this module is taken from the |
42 |
works of Bruce Schneier, Ross Anderson and Alex Halderman. I think they |
|
43 |
are the world experts in the area of security engineering. I especially |
|
44 |
like that they argue that a security engineer requires a certain |
|
45 |
\emph{security mindset}. Bruce Schneier for example writes: |
|
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
|
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |
\begin{quote} |
565 | 48 |
\it ``Security engineers --- at least the good ones --- see the world |
49 |
differently. They can't walk into a store without noticing how they |
|
50 |
might shoplift. They can't use a computer without wondering about the |
|
51 |
security vulnerabilities. They can't vote without trying to figure out |
|
52 |
how to vote twice. They just can't help it.'' |
|
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
53 |
\end{quote} |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
54 |
|
443
67d7d239c617
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
55 |
\noindent |
67d7d239c617
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
56 |
and |
67d7d239c617
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
57 |
|
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
58 |
\begin{quote} |
565 | 59 |
\it ``Security engineering\ldots requires you to think differently. You |
60 |
need to figure out not how something works, but how something can be |
|
61 |
made to not work. You have to imagine an intelligent and malicious |
|
62 |
adversary inside your system \ldots, constantly trying new ways to |
|
63 |
subvert it. You have to consider all the ways your system can fail, most |
|
64 |
of them having nothing to do with the design itself. You have to look at |
|
65 |
everything backwards, upside down, and sideways. You have to think like |
|
66 |
an alien.'' |
|
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
67 |
\end{quote} |
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
68 |
|
565 | 69 |
\noindent In this module I like to teach you this security mindset. This |
70 |
might be a mindset that you think is very foreign to you---after all we |
|
71 |
are all good citizens and do not hack into things. However, I beg to |
|
72 |
differ: You have this mindset already when in school you were thinking, |
|
73 |
at least hypothetically, about ways in which you can cheat in an exam |
|
74 |
(whether it is by hiding notes or by looking over the shoulders of your |
|
75 |
fellow pupils). Right? To defend a system, you need to have this kind of |
|
76 |
mindset and be able to think like an attacker. This will include |
|
77 |
understanding techniques that can be used to compromise security and |
|
78 |
privacy in systems. This will many times result in insights where |
|
443
67d7d239c617
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
79 |
well-intended security mechanisms made a system actually less |
184
55968b3205cc
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
80 |
secure.\medskip |
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
81 |
|
184
55968b3205cc
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
82 |
\noindent |
565 | 83 |
{\Large\bf Warning!} However, don’t be evil! Using those techniques in |
84 |
the real world may violate the law or King’s rules, and it may be |
|
85 |
unethical. Under some circumstances, even probing for weaknesses of a |
|
86 |
system may result in severe penalties, up to and including expulsion, |
|
87 |
fines and jail time. Acting lawfully and ethically is your |
|
88 |
responsibility. Ethics requires you to refrain from doing harm. Always |
|
89 |
respect privacy and rights of others. Do not tamper with any of King's |
|
90 |
systems. If you try out a technique, always make doubly sure you are |
|
91 |
working in a safe environment so that you cannot cause any harm, not |
|
92 |
even accidentally. 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
|
93 |
|
565 | 94 |
\noindent In this lecture I want to make you familiar with the security |
95 |
mindset and dispel the myth that encryption is the answer to all |
|
96 |
security problems (it is certainly often a part of an answer, but almost |
|
97 |
always never a sufficient one). This is actually an important thread |
|
98 |
going through the whole course: We will assume that encryption works |
|
99 |
perfectly, but still attack ``things''. By ``works perfectly'' we mean |
|
100 |
that we will assume encryption is a black box and, for example, will not |
|
101 |
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
|
102 |
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
|
103 |
|
565 | 104 |
For a secure system, it seems, four requirements need to come together: |
105 |
First a security policy (what is supposed to be achieved?); second a |
|
106 |
mechanism (cipher, access controls, tamper resistance etc); third the |
|
107 |
assurance we obtain from the mechanism (the amount of reliance we can |
|
108 |
put on the mechanism) and finally the incentives (the motive that the |
|
109 |
people guarding and maintaining the system have to do their job |
|
110 |
properly, and also the motive that the attackers have to try to defeat |
|
111 |
your policy). The last point is often overlooked, but plays an important |
|
112 |
role. To illustrate this let's look at an example. |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
113 |
|
446
64c20ed7941a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
114 |
\subsubsection*{Chip-and-PIN is Surely More Secure, No?} |
180
a95782c2f046
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
179
diff
changeset
|
115 |
|
565 | 116 |
The questions is whether the Chip-and-PIN system used with modern credit |
117 |
cards is more secure than the older method of signing receipts at the |
|
118 |
till? On first glance the answer seems obvious: Chip-and-PIN must be |
|
119 |
more secure and indeed improved security was the central plank in the |
|
120 |
``marketing speak'' of the banks behind Chip-and-PIN. The earlier system |
|
121 |
was based on a magnetic stripe or a mechanical imprint on the cards and |
|
122 |
required customers to sign receipts at the till whenever they bought |
|
123 |
something. This signature authorised the transactions. Although in use |
|
124 |
for a long time, this system had some crucial security flaws, including |
|
125 |
making clones of credit cards and forging signatures. |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
126 |
|
565 | 127 |
Chip-and-PIN, as the name suggests, relies on data being stored on a |
128 |
chip on the card and a PIN number for authorisation. Even though the |
|
129 |
banks involved trumpeted their system as being absolutely secure and |
|
130 |
indeed fraud rates initially went down, security researchers were not |
|
131 |
convinced (especially not the group around Ross |
|
132 |
Anderson).\footnote{Actually, historical data about fraud showed that |
|
133 |
first fraud rates went up (while early problems to do with the |
|
134 |
introduction of Chip-and-PIN we exploited), then down, but recently up |
|
135 |
again (because criminals getting more familiar with the technology and |
|
136 |
how it can be exploited).} To begin with, the Chip-and-PIN system |
|
137 |
introduced a ``new player'' into the system that needed to be trusted: |
|
138 |
the PIN terminals and their manufacturers. It was claimed that these |
|
139 |
terminals were tamper-resistant, but needless to say this was a weak |
|
140 |
link in the system, which criminals successfully attacked. Some |
|
141 |
terminals were even so skilfully manipulated that they transmitted |
|
142 |
skimmed PIN numbers via built-in mobile phone connections. To mitigate |
|
143 |
this flaw in the security of Chip-and-PIN, you need to be able to vet |
|
144 |
quite closely the supply chain of such terminals. This is something that |
|
145 |
is mostly beyond the control of customers who need to use these |
|
446
64c20ed7941a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
146 |
terminals. |
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
147 |
|
565 | 148 |
To make matters worse for Chip-and-PIN, around 2009 Ross Anderson and |
149 |
his group were able to perform man-in-the-middle attacks against |
|
150 |
Chip-and-PIN. Essentially they made the terminal think the correct PIN |
|
151 |
was entered and the card think that a signature was used. This is a kind |
|
152 |
of \emph{protocol failure}. After discovery, the flaw was mitigated by |
|
153 |
requiring that a link between the card and the bank is established at |
|
154 |
every time the card is used. Even later this group found another problem |
|
155 |
with Chip-and-PIN and ATMs which did not generate random enough numbers |
|
156 |
(cryptographic nonces) on which the security of the underlying protocols |
|
157 |
relies. |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
158 |
|
565 | 159 |
The overarching problem with all this is that the banks who introduced |
160 |
Chip-and-PIN managed with the new system to shift the liability for any |
|
161 |
fraud and the burden of proof onto the customer. In the old system, the |
|
162 |
banks had to prove that the customer used the card, which they often did |
|
163 |
not bother with. In effect, if fraud occurred the customers were either |
|
381
036a762b02cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
379
diff
changeset
|
164 |
refunded fully or lost only a small amount of money. This |
565 | 165 |
taking-responsibility-of-potential-fraud was part of the ``business |
166 |
plan'' of the banks and did not reduce their profits too much. |
|
167 |
||
177
46e581d66f3a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
176
diff
changeset
|
168 |
|
565 | 169 |
Since banks managed to successfully claim that their Chip-and-PIN system |
170 |
is secure, they were under the new system able to point the finger at |
|
171 |
the customer when fraud occurred: customers must have been negligent |
|
172 |
losing their PIN and customers had almost no way of defending themselves |
|
173 |
in such situations. That is why the work of \emph{ethical} hackers like |
|
174 |
Ross Anderson's group is so important, because they and others |
|
175 |
established that the banks' claim that their system is secure and it |
|
176 |
must have been the customer's fault, was bogus. In 2009 the law changed |
|
177 |
and the burden of proof went back to the banks. They need to prove |
|
178 |
whether it was really the customer who used a card or not. The current |
|
179 |
state of affairs, however, is that standing up for your right requires |
|
180 |
you to be knowledgeable, potentially having to go to court\ldots{}if |
|
446
64c20ed7941a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
181 |
not, the banks are happy to take advantage of you. |
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
182 |
|
565 | 183 |
This is a classic example where a fundamental security design principle |
184 |
was violated: Namely, the one who is in the position to improve |
|
185 |
security, also needs to bear the financial losses if things go wrong. |
|
186 |
Otherwise, you end up with an insecure system. In case of the |
|
187 |
Chip-and-PIN system, no good security engineer would dare to claim that |
|
188 |
it is secure beyond reproach: the specification of the EMV protocol |
|
189 |
(underlying Chip-and-PIN) is some 700 pages long, but still leaves out |
|
190 |
many things (like how to implement a good random number generator). No |
|
191 |
human being is able to scrutinise such a specification and ensure it |
|
192 |
contains no flaws. Moreover, banks can add their own sub-protocols to |
|
193 |
EMV. With all the experience we already have, it is as clear as day that |
|
194 |
criminals were bound to eventually be able to poke holes into it and |
|
195 |
measures need to be taken to address them. However, with how the system |
|
196 |
was set up, the banks had no real incentive to come up with a system |
|
197 |
that is really secure. Getting the incentives right in favour of |
|
198 |
security is often a tricky business. From a customer point of view, the |
|
199 |
Chip-and-PIN system was much less secure than the old signature-based |
|
200 |
method. The customer could now lose significant amounts of money. |
|
173
9126c13a7d93
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
169
diff
changeset
|
201 |
|
565 | 202 |
If you want to watch an entertaining talk about attacking Chip-and-PIN |
203 |
cards, then this talk from the 2014 Chaos Computer Club conference is |
|
204 |
for you: |
|
445
9ad6445a0354
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
443
diff
changeset
|
205 |
|
9ad6445a0354
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
443
diff
changeset
|
206 |
\begin{center} |
529 | 207 |
\url{https://goo.gl/zuwVHb} |
445
9ad6445a0354
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
443
diff
changeset
|
208 |
\end{center} |
9ad6445a0354
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
443
diff
changeset
|
209 |
|
565 | 210 |
\noindent They claim that they are able to clone Chip-and-PINs cards |
211 |
such that they get all data that was on the Magstripe, except for three |
|
212 |
digits (the CVV number). Remember, Chip-and-PIN cards were introduced |
|
213 |
exactly for preventing this. Ross Anderson also talked about his |
|
214 |
research at the BlackHat Conference in 2014: |
|
445
9ad6445a0354
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
443
diff
changeset
|
215 |
|
450
f3d5e57ca00a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
446
diff
changeset
|
216 |
\begin{center} |
f3d5e57ca00a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
446
diff
changeset
|
217 |
\url{https://www.youtube.com/watch?v=ET0MFkRorbo} |
f3d5e57ca00a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
446
diff
changeset
|
218 |
\end{center} |
445
9ad6445a0354
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
443
diff
changeset
|
219 |
|
565 | 220 |
\noindent An article about reverse-engineering a PIN-number skimmer is |
221 |
at |
|
455
2d9e005100f4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
453
diff
changeset
|
222 |
|
2d9e005100f4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
453
diff
changeset
|
223 |
\begin{center}\small |
2d9e005100f4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
453
diff
changeset
|
224 |
\url{https://trustfoundry.net/reverse-engineering-a-discovered-atm-skimmer/} |
2d9e005100f4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
453
diff
changeset
|
225 |
\end{center} |
2d9e005100f4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
453
diff
changeset
|
226 |
|
2d9e005100f4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
453
diff
changeset
|
227 |
\noindent |
565 | 228 |
including a scary video of how a PIN-pad overlay is installed by some |
229 |
crooks. |
|
455
2d9e005100f4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
453
diff
changeset
|
230 |
|
2d9e005100f4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
453
diff
changeset
|
231 |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
232 |
\subsection*{Of Cookies and Salts} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
233 |
|
355
619073c37649
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
234 |
Let us look at another example which will help with understanding how |
565 | 235 |
passwords should be verified and stored. Imagine you need to develop a |
236 |
web-application that has the feature of recording how many times a |
|
355
619073c37649
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
237 |
customer visits a page. For example in order to give a discount |
619073c37649
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
336
diff
changeset
|
238 |
whenever the customer has visited a webpage some $x$ number of times |
565 | 239 |
(say $x$ equals $5$). There is one more constraint: we want to store the |
240 |
information about the number of visits as a cookie on the browser. I |
|
241 |
think, for a number of years the webpage of the New York Times operated |
|
242 |
in this way: it allowed you to read ten articles per month for free; if |
|
243 |
you wanted to read more, you had to pay. My best guess is that it used |
|
244 |
cookies for recording how many times their pages was visited, because if |
|
245 |
I switched browsers I could easily circumvent the restriction about ten |
|
246 |
articles.\footnote{Another online media that works in this way is the |
|
247 |
Times Higher Education \url{http://www.timeshighereducation.co.uk}. It |
|
248 |
also seems to use cookies to restrict the number of free articles to |
|
249 |
five.} |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
250 |
|
565 | 251 |
To implement our web-application it is good to look under the hood what |
252 |
happens when a webpage is displayed in a browser. A typical |
|
253 |
web-application works as follows: The browser sends a GET request for a |
|
254 |
particular page to a server. The server answers this request with a |
|
255 |
webpage in HTML (for our purposes we can ignore the details about HTML). |
|
256 |
A simple JavaScript program that realises a server answering with a |
|
257 |
``Hello World'' webpage is as follows: |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
258 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
259 |
\begin{center} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
260 |
\lstinputlisting{../progs/ap0.js} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
261 |
\end{center} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
262 |
|
565 | 263 |
\noindent The interesting lines are 4 to 7 where the answer to the GET |
264 |
request is generated\ldots in this case it is just a simple string. This |
|
265 |
program is run on the server and will be executed whenever a browser |
|
266 |
initiates such a GET request. You can run this program on your computer |
|
267 |
and then direct a browser to the address \pcode{localhost:8000} in order |
|
268 |
to simulate a request over the internet. You are encouraged to try this |
|
269 |
out\ldots{}theory is always good, but practice is better. |
|
180
a95782c2f046
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
179
diff
changeset
|
270 |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
271 |
|
565 | 272 |
For our web-application of interest is the feature that the server when |
273 |
answering the request can store some information on the client's side. |
|
274 |
This information is called a \emph{cookie}. The next time the browser |
|
275 |
makes another GET request to the same webpage, this cookie can be read |
|
276 |
again by the server. We can use cookies in order to store a counter that |
|
277 |
records the number of times our webpage has been visited. This can be |
|
278 |
realised with the following small program |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
279 |
|
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
280 |
\begin{center} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
281 |
\lstinputlisting{../progs/ap2.js} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
282 |
\end{center} |
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
283 |
|
565 | 284 |
\noindent The overall structure of this program is the same as the |
285 |
earlier one: Lines 7 to 17 generate the answer to a GET-request. The new |
|
286 |
part is in Line 8 where we read the cookie called \pcode{counter}. If |
|
287 |
present, this cookie will be send together with the GET-request from the |
|
288 |
client. The value of this counter will come in form of a string, |
|
289 |
therefore we use the function \pcode{parseInt} in order to transform it |
|
290 |
into an integer. In case the cookie is not present, we default the |
|
291 |
counter to zero. The odd looking construction \code{...|| 0} is |
|
292 |
realising this defaulting in JavaScript. In Line 9 we increase the |
|
293 |
counter by one and store it back to the client (under the name |
|
294 |
\pcode{counter}, since potentially more than one value could be stored). |
|
295 |
In Lines 10 to 15 we test whether this counter is greater or equal than |
|
296 |
5 and send accordingly a specially grafted message back to the client. |
|
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
297 |
|
565 | 298 |
Let us step back and analyse this program from a security point of view. |
299 |
We store a counter in plain text on the client's browser (which is not |
|
300 |
under our control). Depending on this value we want to unlock a resource |
|
301 |
(like a discount) when it reaches a threshold. If the client deletes the |
|
302 |
cookie, then the counter will just be reset to zero. This does not |
|
303 |
bother us, because the purported discount will just not be granted. In |
|
304 |
this way we do not lose any (hypothetical) money. What we need to be |
|
305 |
concerned about is, however, when a client artificially increases this |
|
306 |
counter without having visited our web-page. This is actually a trivial |
|
307 |
task for a knowledgeable person, since there are convenient tools that |
|
308 |
allow one to set a cookie to an arbitrary value, for example above our |
|
180
a95782c2f046
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
179
diff
changeset
|
309 |
threshold for the discount. |
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
310 |
|
565 | 311 |
There seems to be no simple way to prevent this kind of tampering with |
312 |
cookies, because the whole purpose of cookies is that they are stored on |
|
313 |
the client's side, which from the the server's perspective is a |
|
314 |
potentially hostile environment. What we need to ensure is the integrity |
|
315 |
of this counter in this hostile environment. We could think of |
|
316 |
encrypting the counter. But this has two drawbacks to do with the keys |
|
317 |
for encryption. If you use a single, global key for all the clients that |
|
318 |
visit our site, then we risk that our whole ``business'' might collapse |
|
319 |
in the event this key gets known to the outside world. Then all cookies |
|
320 |
we might have set in the past, can now be decrypted and manipulated. If, |
|
321 |
on the other hand, we use many ``private'' keys for the clients, then we |
|
322 |
have to solve the problem of having to securely store this key on our |
|
323 |
server side (obviously we cannot store the key with the client because |
|
324 |
then the client again has all data to tamper with the counter; and |
|
325 |
obviously we also cannot encrypt the key, lest we can solve an |
|
326 |
impossible chicken-and-egg problem). So encryption seems to not solve |
|
327 |
the 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
|
328 |
|
565 | 329 |
Fortunately, \emph{cryptographic hash functions} seem to be more |
330 |
suitable for our purpose. Like encryption, hash functions scramble data |
|
331 |
in such a way that it is easy to calculate the output of a hash function |
|
332 |
from the input. But it is hard (i.e.~practically impossible) to |
|
333 |
calculate the input from knowing the output. This is often called |
|
334 |
\emph{preimage resistance}. Cryptographic hash functions also ensure |
|
335 |
that given a message and a hash, it is computationally infeasible to |
|
336 |
find another message with the same hash. This is called \emph{collusion |
|
337 |
resistance}. Because of these properties, hash functions are often |
|
338 |
called \emph{one-way functions}: you cannot go back from the output to |
|
339 |
the input (without some tricks, see below). |
|
336
3cb200fa6d6a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
325
diff
changeset
|
340 |
|
565 | 341 |
There are several such hashing function. For example SHA-1 would hash |
342 |
the string \pcode{"hello world"} to produce the hash-value |
|
175
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
343 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
344 |
\begin{center} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
345 |
\pcode{2aae6c35c94fcfb415dbe95f408b9ce91ee846ed} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
346 |
\end{center} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
347 |
|
565 | 348 |
\noindent Another handy feature of hash functions is that if the input |
349 |
changes only a little, the output changes drastically. For example |
|
350 |
\pcode{"iello world"} produces under SHA-1 the output |
|
175
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
351 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
352 |
\begin{center} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
353 |
\pcode{d2b1402d84e8bcef5ae18f828e43e7065b841ff1} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
354 |
\end{center} |
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
355 |
|
565 | 356 |
\noindent That means it is not predictable what the output will be from |
357 |
just looking at input that is ``close by''. |
|
175
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
358 |
|
565 | 359 |
We can use hashes in our web-application and store in the cookie the |
360 |
value of the counter in plain text but together with its hash. We need |
|
361 |
to store both pieces of data in such a way that we can extract them |
|
362 |
again later on. In the code below I will just separate them using a |
|
363 |
\pcode{"-"}. For the counter \pcode{1} for example |
|
184
55968b3205cc
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
364 |
|
55968b3205cc
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
365 |
\begin{center} |
55968b3205cc
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
366 |
\pcode{1-356a192b7913b04c54574d18c28d46e6395428ab} |
55968b3205cc
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
367 |
\end{center} |
55968b3205cc
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
368 |
|
565 | 369 |
\noindent If we now read back the cookie when the client visits our |
370 |
webpage, we can extract the counter, hash it again and compare the |
|
371 |
result to the stored hash value inside the cookie. If these hashes |
|
372 |
disagree, then we can deduce that the cookie has been tampered with. |
|
373 |
Unfortunately, if they agree, we can still not be entirely sure that not |
|
374 |
a clever hacker has tampered with the cookie. The reason is that the |
|
375 |
hacker can see the clear text part of the cookie, say \pcode{3}, and |
|
376 |
also its hash. It does not take much trial and error to find out that we |
|
377 |
used the SHA-1 hashing function and then the hacker can graft a cookie |
|
378 |
accordingly. This is eased by the fact that for SHA-1 many strings and |
|
379 |
corresponding hash-values are precalculated. Type, for example, into |
|
380 |
Google the hash value for \pcode{"hello world"} and you will actually |
|
381 |
pretty quickly find that it was generated by input string \pcode{"hello |
|
382 |
world"}. Similarly for the hash-value for \pcode{1}. This defeats the |
|
383 |
purpose of a hashing function and thus would not help us with our |
|
384 |
web-applications and later also not with how to store passwords |
|
385 |
properly. |
|
175
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
386 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
387 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
388 |
There is one ingredient missing, which happens to be called |
565 | 389 |
\emph{salts}. Salts are random keys, which are added to the counter |
390 |
before the hash is calculated. In our case we must keep the salt secret. |
|
391 |
As can be see in Figure~\ref{hashsalt}, we need to extract from the |
|
392 |
cookie the counter value and its hash (Lines 19 and 20). But before |
|
393 |
hashing the counter again (Line 22) we need to add the secret salt. |
|
394 |
Similarly, when we set the new increased counter, we will need to add |
|
395 |
the salt before hashing (this is done in Line 15). Our web-application |
|
178
13c6bd6e3477
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
177
diff
changeset
|
396 |
will now store cookies like |
175
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
397 |
|
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
398 |
\begin{figure}[p] |
178
13c6bd6e3477
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
177
diff
changeset
|
399 |
\lstinputlisting{../progs/App4.js} |
565 | 400 |
\caption{A Node.js web-app that sets a cookie in the client's browser |
401 |
for counting the number of visits to a page.\label{hashsalt}} |
|
175
4ebc97e6fdf0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
174
diff
changeset
|
402 |
\end{figure} |
169
2866fae8c1cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
168
diff
changeset
|
403 |
|
179
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
404 |
\begin{center}\tt |
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
405 |
\begin{tabular}{l} |
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
406 |
1 + salt - 8189effef4d4f7411f4153b13ff72546dd682c69\\ |
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
407 |
2 + salt - 1528375d5ceb7d71597053e6877cc570067a738f\\ |
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
408 |
3 + salt - d646e213d4f87e3971d9dd6d9f435840eb6a1c06\\ |
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
409 |
4 + salt - 5b9e85269e4461de0238a6bf463ed3f25778cbba\\ |
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
410 |
...\\ |
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
411 |
\end{tabular} |
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
412 |
\end{center} |
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
413 |
|
565 | 414 |
\noindent These hashes allow us to read and set the value of the |
415 |
counter, and also give us confidence that the counter has not been |
|
416 |
tampered with. This of course depends on being able to keep the salt |
|
417 |
secret. Once the salt is public, we better ignore all cookies and start |
|
418 |
setting them again with a new salt. |
|
179
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
419 |
|
565 | 420 |
There is an interesting and very subtle point to note with respect to |
421 |
the 'New York Times' way of checking the number visits. Essentially they |
|
422 |
have their `resource' unlocked at the beginning and lock it only when |
|
423 |
the data in the cookie states that the allowed free number of visits are |
|
424 |
up. As said before, this can be easily circumvented by just deleting the |
|
425 |
cookie or by switching the browser. This would mean the New York Times |
|
426 |
will lose revenue whenever this kind of tampering occurs. The `quick |
|
427 |
fix' to require that a cookie must always be present does not work, |
|
428 |
because then this newspaper will cut off any new readers, or anyone who |
|
429 |
gets a new computer. In contrast, our web-application has the resource |
|
430 |
(discount) locked at the beginning and only unlocks it if the cookie |
|
431 |
data says so. If the cookie is deleted, well then the resource just does |
|
432 |
not get unlocked. No major harm will result to us. You can see: the same |
|
433 |
security mechanism behaves rather differently depending on whether the |
|
434 |
``resource'' needs to be locked or unlocked. Apart from thinking about |
|
435 |
the difference very carefully, I do not know of any good ``theory'' that |
|
436 |
could help with solving such security intricacies in any other way. |
|
179
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
437 |
|
182
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
438 |
\subsection*{How to Store Passwords Properly?} |
179
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
439 |
|
565 | 440 |
While admittedly quite silly, the simple web-application in the previous |
441 |
section should help with the more important question of how passwords |
|
442 |
should be verified and stored. It is unbelievable that nowadays systems |
|
443 |
still do this with passwords in plain text. The idea behind such |
|
444 |
plain-text passwords is of course that if the user typed in |
|
445 |
\pcode{foobar} as password, we need to verify whether it matches with |
|
446 |
the password that is already stored for this user in the system. Why not |
|
447 |
doing this with plain-text passwords? Unfortunately doing this |
|
448 |
verification in plain text is really a bad idea. Alas, evidence suggests |
|
449 |
it is still a widespread practice. I leave you to think about why |
|
450 |
verifying passwords in plain text is a bad idea. |
|
181
a736a0c324a3
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
180
diff
changeset
|
451 |
|
565 | 452 |
Using hash functions, like in our web-application, we can do better. |
453 |
They allow us to not having to store passwords in plain text for |
|
454 |
verification whether a password matches or not. We can just hash the |
|
455 |
password and store the hash-value. And whenever the user types in a new |
|
456 |
password, well then we hash it again and check whether the hash-values |
|
457 |
agree. Just like in the web-application before. |
|
182
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
458 |
|
565 | 459 |
Lets analyse what happens when a hacker gets hold of such a hashed |
460 |
password database. That is the scenario we want to defend |
|
461 |
against.\footnote{If we could assume our servers can never be broken |
|
462 |
into, then storing passwords in plain text would be no problem. The |
|
463 |
point, however, is that servers are never absolutely secure.} The hacker |
|
464 |
has then a list of user names and associated hash-values, like |
|
181
a736a0c324a3
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
180
diff
changeset
|
465 |
|
a736a0c324a3
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
180
diff
changeset
|
466 |
\begin{center} |
a736a0c324a3
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
180
diff
changeset
|
467 |
\pcode{urbanc:2aae6c35c94fcfb415dbe95f408b9ce91ee846ed} |
a736a0c324a3
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
180
diff
changeset
|
468 |
\end{center} |
179
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
469 |
|
565 | 470 |
\noindent For a beginner-level hacker this information is of no use. It |
471 |
would not work to type in the hash value instead of the password, |
|
472 |
because it will go through the hashing function again and then the |
|
473 |
resulting two hash-values will not match. One attack a hacker can try, |
|
474 |
however, is called a \emph{brute force attack}. Essentially this means |
|
475 |
trying out exhaustively all strings |
|
181
a736a0c324a3
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
180
diff
changeset
|
476 |
|
a736a0c324a3
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
180
diff
changeset
|
477 |
\begin{center} |
565 | 478 |
\pcode{a}, \pcode{aa}, \pcode{...}, \pcode{ba}, \pcode{...}, |
181
a736a0c324a3
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
180
diff
changeset
|
479 |
\pcode{zzz}, |
a736a0c324a3
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
180
diff
changeset
|
480 |
\pcode{...} |
a736a0c324a3
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
180
diff
changeset
|
481 |
\end{center} |
a736a0c324a3
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
180
diff
changeset
|
482 |
|
565 | 483 |
\noindent and so on, hash them and check whether they match with the |
484 |
hash-values in the database. Such brute force attacks are surprisingly |
|
485 |
effective. With modern technology (usually GPU graphic cards), passwords |
|
486 |
of moderate length only need seconds or hours to be cracked. Well, the |
|
487 |
only defence we have against such brute force attacks is to make |
|
488 |
passwords longer and force users to use the whole spectrum of letters |
|
489 |
and keys for passwords. The hope is that this makes the search space too |
|
490 |
big for an effective brute force attack. |
|
182
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
491 |
|
565 | 492 |
Unfortunately, clever hackers have another ace up their sleeves. These |
493 |
are called \emph{dictionary attacks}. The idea behind dictionary attack |
|
494 |
is the observation that only few people are competent enough to use |
|
495 |
sufficiently strong passwords. Most users (at least too many) use |
|
496 |
passwords like |
|
182
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
497 |
|
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
498 |
\begin{center} |
565 | 499 |
\pcode{123456}, \pcode{password}, \pcode{qwerty}, \pcode{letmein}, |
182
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
500 |
\pcode{...} |
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
501 |
\end{center} |
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
502 |
|
565 | 503 |
\noindent So an attacker just needs to compile a list as large as |
504 |
possible of such likely candidates of passwords and also compute their |
|
505 |
hash-values. The difference between a brute force attack, where maybe |
|
506 |
$2^{80}$ many strings need to be considered, is that a dictionary attack |
|
507 |
might get away with checking only 10 Million words (remember the |
|
508 |
language English ``only'' contains 600,000 words). This is a drastic |
|
509 |
simplification for attackers. Now, if the attacker knows the hash-value |
|
510 |
of a password is |
|
182
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
511 |
|
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
512 |
\begin{center} |
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
513 |
\pcode{5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8} |
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
514 |
\end{center} |
179
1cacbe5c67cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
178
diff
changeset
|
515 |
|
565 | 516 |
\noindent then just a lookup in the dictionary will reveal that the |
517 |
plain-text password was \pcode{password}. What is good about this attack |
|
518 |
is that the dictionary can be precompiled in the ``comfort of the |
|
519 |
hacker's home'' before an actual attack is launched. It just needs |
|
520 |
sufficient storage space, which nowadays is pretty cheap. A hacker might |
|
521 |
in this way not be able to crack all passwords in our database, but even |
|
522 |
being able to crack 50\% can be serious damage for a large company |
|
523 |
(because then you have to think about how to make users to change their |
|
524 |
old passwords---a major hassle). And hackers are very industrious in |
|
525 |
compiling these dictionaries: for example they definitely include |
|
526 |
variations like \pcode{passw0rd} and also include rules that cover cases |
|
227
7807863c4196
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
186
diff
changeset
|
527 |
like \pcode{passwordpassword} or \pcode{drowssap} (password |
565 | 528 |
reversed).\footnote{Some entertaining rules for creating effective |
529 |
dictionaries are described in the book ``Applied Cryptography'' by Bruce |
|
530 |
Schneier (in case you can find it in the library), and also in the |
|
531 |
original research literature which can be accessed for free from |
|
227
7807863c4196
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
186
diff
changeset
|
532 |
\url{http://www.klein.com/dvk/publications/passwd.pdf}.} |
565 | 533 |
Historically, compiling a list for a dictionary attack is not as simple |
534 |
as it might seem. At the beginning only ``real'' dictionaries were |
|
535 |
available (like the Oxford English Dictionary), but such dictionaries |
|
536 |
are not optimised for the purpose of cracking passwords. The first real |
|
537 |
hard data about actually used passwords was obtained when a company |
|
538 |
called RockYou ``lost'' at the end of 2009 32 Million plain-text |
|
539 |
passwords. With this data of real-life passwords, dictionary attacks |
|
540 |
took off. Compiling such dictionaries is nowadays very easy with the |
|
541 |
help of off-the-shelf tools. |
|
182
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
542 |
|
565 | 543 |
These dictionary attacks can be prevented by using salts. Remember a |
544 |
hacker needs to use the most likely candidates of passwords and |
|
545 |
calculate their hash-value. If we add before hashing a password a random |
|
546 |
salt, like \pcode{mPX2aq}, then the string \pcode{passwordmPX2aq} will |
|
547 |
almost certainly not be in the dictionary. Like in the web-application |
|
548 |
in the previous section, a salt does not prevent us from verifying a |
|
549 |
password. We just need to add the salt whenever the password is typed in |
|
550 |
again. |
|
182
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
551 |
|
565 | 552 |
There is a question whether we should use a single random salt for every |
553 |
password in our database. A single salt would already make dictionary |
|
554 |
attacks considerably more difficult. It turns out, however, that in case |
|
555 |
of password databases every password should get their own salt. This |
|
556 |
salt is generated at the time when the password is first set. If you |
|
557 |
look at a Unix password file you will find entries like |
|
182
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
558 |
|
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
559 |
\begin{center} |
288
fd4bf1a2d38d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
263
diff
changeset
|
560 |
\pcode{urbanc:$6$3WWbKfr1$4vblknvGr6FcDeF92R5xFn3mskfdnEn...$...} |
182
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
561 |
\end{center} |
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
562 |
|
565 | 563 |
\noindent where the first part is the login-name, followed by a field |
564 |
\pcode{$6$} which specifies which hash-function is used. After that |
|
565 |
follows the salt \pcode{3WWbKfr1} and after that the hash-value that is |
|
566 |
stored for the password (which includes the salt). I leave it to you to |
|
567 |
figure out how the password verification would need to work based on |
|
568 |
this data. |
|
182
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
569 |
|
565 | 570 |
There is a non-obvious benefit of using a separate salt for each |
571 |
password. Recall that \pcode{123456} is a popular password that is most |
|
572 |
likely used by several of your users (especially if the database |
|
573 |
contains millions of entries). If we use no salt or one global salt, all |
|
574 |
hash-values will be the same for this password. So if a hacker is in the |
|
575 |
business of cracking as many passwords as possible, then it is a good |
|
576 |
idea to concentrate on those very popular passwords. This is not |
|
577 |
possible if each password gets its own salt: since we assume the salt is |
|
578 |
generated randomly, each version of \pcode{123456} will be associated |
|
579 |
with a different hash-value. This will make the life harder for an |
|
580 |
attacker. |
|
182
681e35f6b0e4
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
581 |
|
565 | 582 |
Note another interesting point. The web-application from the previous |
583 |
section was only secure when the salt was secret. In the password case, |
|
584 |
this is not needed. The salt can be public as shown above in the Unix |
|
585 |
password file where it is actually stored as part of the password entry. |
|
586 |
Knowing the salt does not give the attacker any advantage, but prevents |
|
587 |
that dictionaries can be precompiled. While salts do not solve every |
|
588 |
problem, they help with protecting against dictionary attacks on |
|
589 |
password files. It protects people who have the same passwords on |
|
590 |
multiple machines. But it does not protect against a focused attack |
|
591 |
against a single password and also does not make poorly chosen passwords |
|
592 |
any better. Still the moral is that you should never store passwords in |
|
593 |
plain text. Never ever. |
|
262
57269d9931da
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
227
diff
changeset
|
594 |
|
57269d9931da
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
227
diff
changeset
|
595 |
\subsubsection*{Further Reading} |
174
e2180cead443
updated handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
596 |
|
565 | 597 |
A readable article by Bruce Schneier on ``How Security Companies Sucker |
598 |
Us with Lemons'' |
|
312
c913fe9bfd59
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
291
diff
changeset
|
599 |
|
c913fe9bfd59
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
291
diff
changeset
|
600 |
\begin{center} |
c913fe9bfd59
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
291
diff
changeset
|
601 |
\url{http://archive.wired.com/politics/security/commentary/securitymatters/2007/04/securitymatters_0419} |
c913fe9bfd59
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
291
diff
changeset
|
602 |
\end{center} |
c913fe9bfd59
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
291
diff
changeset
|
603 |
|
c913fe9bfd59
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
291
diff
changeset
|
604 |
\noindent |
443
67d7d239c617
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
605 |
A recent research paper about surveillance using cookies is |
67d7d239c617
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
606 |
|
67d7d239c617
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
607 |
\begin{center} |
67d7d239c617
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
608 |
\url{http://randomwalker.info/publications/cookie-surveillance-v2.pdf} |
67d7d239c617
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
609 |
\end{center} |
67d7d239c617
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
610 |
|
67d7d239c617
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
431
diff
changeset
|
611 |
\noindent |
565 | 612 |
A slightly different point of view about the economies of password |
613 |
cracking: |
|
288
fd4bf1a2d38d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
263
diff
changeset
|
614 |
|
fd4bf1a2d38d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
263
diff
changeset
|
615 |
\begin{center} |
325
48c6751f2173
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
312
diff
changeset
|
616 |
\url{http://xkcd.com/538/} |
288
fd4bf1a2d38d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
263
diff
changeset
|
617 |
\end{center} |
fd4bf1a2d38d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
263
diff
changeset
|
618 |
|
565 | 619 |
\noindent If you want to know more about passwords, the book by Bruce |
620 |
Schneier about Applied Cryptography is recommendable, though quite |
|
621 |
expensive. There is also another expensive book about penetration |
|
622 |
testing, but the readable chapter about password attacks (Chapter 9) is |
|
623 |
free: |
|
262
57269d9931da
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
227
diff
changeset
|
624 |
|
57269d9931da
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
227
diff
changeset
|
625 |
\begin{center} |
57269d9931da
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
227
diff
changeset
|
626 |
\url{http://www.nostarch.com/pentesting} |
57269d9931da
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
227
diff
changeset
|
627 |
\end{center} |
57269d9931da
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
227
diff
changeset
|
628 |
|
565 | 629 |
\noindent Even the government recently handed out some advice about |
630 |
passwords |
|
379
11f5f86bf956
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
370
diff
changeset
|
631 |
|
11f5f86bf956
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
370
diff
changeset
|
632 |
\begin{center} |
11f5f86bf956
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
370
diff
changeset
|
633 |
\url{http://goo.gl/dIzqMg} |
11f5f86bf956
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
370
diff
changeset
|
634 |
\end{center} |
11f5f86bf956
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
370
diff
changeset
|
635 |
|
565 | 636 |
\noindent Here is an interesting blog-post about how a group ``cracked'' |
637 |
efficiently millions of bcrypt passwords from the Ashley Madison leak. |
|
381
036a762b02cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
379
diff
changeset
|
638 |
|
036a762b02cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
379
diff
changeset
|
639 |
\begin{center} |
036a762b02cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
379
diff
changeset
|
640 |
\url{http://goo.gl/83Ho0N} |
036a762b02cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
379
diff
changeset
|
641 |
\end{center} |
036a762b02cf
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
379
diff
changeset
|
642 |
|
459
514485146641
updated home works
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
457
diff
changeset
|
643 |
\noindent Or the passwords from eHarmony |
514485146641
updated home works
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
457
diff
changeset
|
644 |
|
514485146641
updated home works
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
457
diff
changeset
|
645 |
\begin{center} |
514485146641
updated home works
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
457
diff
changeset
|
646 |
\url{https://goo.gl/W63Xhw} |
514485146641
updated home works
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
457
diff
changeset
|
647 |
\end{center} |
514485146641
updated home works
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
457
diff
changeset
|
648 |
|
514485146641
updated home works
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
457
diff
changeset
|
649 |
\noindent The attack used dictionaries with up to 15 Billion |
565 | 650 |
entries.\footnote{Compare this with the full brute-force space of |
651 |
$62^8$} If eHarmony had properly salted their passwords, the attack |
|
652 |
would have taken 31 years. |
|
459
514485146641
updated home works
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
457
diff
changeset
|
653 |
|
514485146641
updated home works
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
457
diff
changeset
|
654 |
|
565 | 655 |
Clearly, passwords are a technology that comes to the end of its |
656 |
usefulness, because brute force attacks become more and more powerful |
|
657 |
and it is unlikely that humans get any better in remembering (securely) |
|
658 |
longer and longer passwords. The big question is which technology can |
|
659 |
replace passwords\ldots |
|
358
8787c16bc26e
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
355
diff
changeset
|
660 |
\medskip |
8787c16bc26e
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
355
diff
changeset
|
661 |
|
288
fd4bf1a2d38d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
263
diff
changeset
|
662 |
|
fd4bf1a2d38d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
263
diff
changeset
|
663 |
\end{document} |
fd4bf1a2d38d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
263
diff
changeset
|
664 |
|
370
ddac52c0014c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
366
diff
changeset
|
665 |
%%% fingerprints vs. passwords (what is better) |
ddac52c0014c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
366
diff
changeset
|
666 |
https://www.youtube.com/watch?v=VVxL9ymiyAU&feature=youtu.be |
ddac52c0014c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
366
diff
changeset
|
667 |
|
ddac52c0014c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
366
diff
changeset
|
668 |
%%% cookies |
ddac52c0014c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
366
diff
changeset
|
669 |
http://randomwalker.info/publications/cookie-surveillance-v2.pdf |
288
fd4bf1a2d38d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
263
diff
changeset
|
670 |
|
158
702fea7754eb
added handouts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
671 |
|
565 | 672 |
%%% Local Variables: %% mode: latex %% TeX-master: t %% End: |