160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
164 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
161 |
165 |
162 |
166 |
163 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
164 \begin{frame}[c] |
168 \begin{frame}[c] |
165 \frametitle{\begin{tabular}{c}Network Applications:\\[-1mm] Privilege Separation\end{tabular}} |
|
166 |
|
167 \begin{center} |
|
168 \begin{tikzpicture}[scale=1] |
|
169 |
|
170 \draw[line width=1mm] (-.3, 0) rectangle (1.5,2); |
|
171 \draw (4.7,1) node {Internet}; |
|
172 \draw (-2.7,1.7) node {\footnotesize Application}; |
|
173 \draw (0.6,1.7) node {\footnotesize Interface}; |
|
174 \draw (0.6,-0.4) node {\footnotesize \begin{tabular}{c}unprivileged\\[-1mm] process\end{tabular}}; |
|
175 \draw (-2.7,-0.4) node {\footnotesize \begin{tabular}{c}privileged\\[-1mm] process\end{tabular}}; |
|
176 |
|
177 \draw[line width=1mm] (-1.8, 0) rectangle (-3.6,2); |
|
178 |
|
179 \draw[white] (1.7,1) node (X) {}; |
|
180 \draw[white] (3.7,1) node (Y) {}; |
|
181 \draw[red, <->, line width = 2mm] (X) -- (Y); |
|
182 |
|
183 \draw[red, <->, line width = 1mm] (-0.6,1) -- (-1.6,1); |
|
184 \end{tikzpicture} |
|
185 \end{center} |
|
186 |
|
187 \begin{itemize} |
|
188 \item the idea is make the attack surface smaller and |
|
189 mitigate the consequences of an attack |
|
190 \end{itemize} |
|
191 |
|
192 \end{frame} |
|
193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
194 |
|
195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
196 \mode<presentation>{ |
|
197 \begin{frame}[c] |
|
198 \frametitle{Access Control in Unix} |
|
199 |
|
200 \begin{itemize} |
|
201 \item access control provided by the OS |
|
202 \item authenticate principals (login) |
|
203 \item mediate access to files, ports, processes according to \alert{roles} (user ids)\\ |
|
204 \item roles get attached with privileges\bigskip\\% |
|
205 \hspace{8mm} |
|
206 \begin{tikzpicture} |
|
207 \draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
|
208 {\begin{minipage}{8cm} |
|
209 \alert{The principle of least privilege:}\\ |
|
210 programs should only have as much privilege as they need |
|
211 \end{minipage}}; |
|
212 \end{tikzpicture} |
|
213 \end{itemize} |
|
214 |
|
215 \end{frame}} |
|
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
217 |
|
218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
219 \mode<presentation>{ |
|
220 \begin{frame}[t] |
|
221 \frametitle{Process Ownership} |
|
222 |
|
223 \begin{itemize} |
|
224 \item access control in Unix is very coarse |
|
225 \end{itemize}\bigskip\bigskip\bigskip |
|
226 |
|
227 \begin{center} |
|
228 \begin{tabular}{c} |
|
229 root\\ |
|
230 \hline |
|
231 |
|
232 user$_1$ user$_2$ \ldots www, mail, lp |
|
233 \end{tabular} |
|
234 \end{center}\bigskip\bigskip\bigskip |
|
235 |
|
236 |
|
237 \textcolor{gray}{\small root has UID $=$ 0}\\\pause |
|
238 \textcolor{gray}{\small you also have groups that can share access to a file}\\ |
|
239 \textcolor{gray}{\small but it is difficult to exclude access selectively}\\ |
|
240 \end{frame}} |
|
241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
242 |
|
243 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
244 \mode<presentation>{ |
|
245 \begin{frame}[c] |
|
246 \frametitle{Access Control in Unix (2)} |
|
247 |
|
248 |
|
249 \begin{itemize} |
|
250 \item privileges are specified by file access permissions (``everything is a file'') |
|
251 \item there are 9 (plus 2) bits that specify the permissions of a file |
|
252 |
|
253 \begin{center} |
|
254 \begin{tabular}{l} |
|
255 \texttt{\$ ls - la}\\ |
|
256 \texttt{-rwxrw-r-{}- \hspace{3mm} foo\_file.txt} |
|
257 \end{tabular} |
|
258 \end{center} |
|
259 \end{itemize} |
|
260 |
|
261 \end{frame}} |
|
262 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
263 |
|
264 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
265 \mode<presentation>{ |
|
266 \begin{frame}[c] |
|
267 \frametitle{Login Process} |
|
268 |
|
269 |
|
270 \begin{itemize} |
|
271 \item login processes run under UID $=$ 0\medskip |
|
272 \begin{center} |
|
273 \texttt{ps -axl | grep login} |
|
274 \end{center}\medskip |
|
275 |
|
276 \item after login, shells run under UID $=$ user (e.g.~501)\medskip |
|
277 \begin{center} |
|
278 \texttt{id cu} |
|
279 \end{center}\medskip\pause |
|
280 |
|
281 \item non-root users are not allowed to change the UID --- would break |
|
282 access control |
|
283 \item but needed for example for \texttt{passwd} |
|
284 \end{itemize} |
|
285 |
|
286 \end{frame}} |
|
287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
288 |
|
289 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
290 \mode<presentation>{ |
|
291 \begin{frame}[c] |
|
292 \frametitle{Setuid and Setgid} |
|
293 |
|
294 The solution is that unix file permissions are 9 + \underline{2 Bits}: |
|
295 \alert{Setuid} and \alert{Setgid} Bits |
|
296 |
|
297 \begin{itemize} |
|
298 \item When a file with setuid is executed, the resulting process will assume the UID given to the owner of the file. |
|
299 \item This enables users to create processes as root (or another user).\bigskip |
|
300 |
|
301 \item Essential for changing passwords, for example. |
|
302 \end{itemize} |
|
303 |
|
304 \begin{center} |
|
305 \texttt{chmod 4755 fobar\_file} |
|
306 \end{center} |
|
307 |
|
308 \end{frame}} |
|
309 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
310 |
|
311 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
312 \mode<presentation>{ |
|
313 \begin{frame}[c] |
|
314 \frametitle{\begin{tabular}{c}Privilege Separation in\\ OpenSSH\end{tabular}} |
|
315 |
|
316 \begin{center} |
|
317 \begin{tikzpicture}[scale=1] |
|
318 |
|
319 \draw[line width=1mm] (0, 1.1) rectangle (1.2,2); |
|
320 \draw (4.7,1) node {Internet}; |
|
321 \draw (0.6,1.7) node {\footnotesize Slave}; |
|
322 \draw[line width=1mm] (0, 0) rectangle (1.2,0.9); |
|
323 \draw (0.6,1.7) node {\footnotesize Slave}; |
|
324 \draw (0.6,0.6) node {\footnotesize Slave}; |
|
325 \draw (0.6,-0.5) node {\footnotesize \begin{tabular}{c}unprivileged\\[-1mm] processes\end{tabular}}; |
|
326 \draw (-2.7,-0.4) node {\footnotesize \begin{tabular}{c}privileged\\[-1mm] process\end{tabular}}; |
|
327 |
|
328 \draw[line width=1mm] (-1.8, 0) rectangle (-3.6,2); |
|
329 \draw (-2.9,1.7) node {\footnotesize Monitor}; |
|
330 |
|
331 \draw[white] (1.7,1) node (X) {}; |
|
332 \draw[white] (3.7,1) node (Y) {}; |
|
333 \draw[red, <->, line width = 2mm] (X) -- (Y); |
|
334 |
|
335 \draw[red, <->, line width = 1mm] (-0.4,1.4) -- (-1.4,1.1); |
|
336 \draw[red, <->, line width = 1mm] (-0.4,0.6) -- (-1.4,0.9); |
|
337 |
|
338 \end{tikzpicture} |
|
339 \end{center} |
|
340 |
|
341 \begin{itemize} |
|
342 \item pre-authorisation slave |
|
343 \item post-authorisation\bigskip |
|
344 \item 25\% codebase is privileged, 75\% is unprivileged |
|
345 \end{itemize} |
|
346 \end{frame}} |
|
347 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
348 |
|
349 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
350 \mode<presentation>{ |
|
351 \begin{frame}[c] |
|
352 \frametitle{Network Applications} |
|
353 |
|
354 ideally network application in Unix should be designed as follows: |
|
355 |
|
356 \begin{itemize} |
|
357 \item need two distinct processes |
|
358 \begin{itemize} |
|
359 \item one that listens to the network; has no privilege |
|
360 \item one that is privileged and listens to the latter only (but does not trust it) |
|
361 |
|
362 \end{itemize} |
|
363 |
|
364 \item to implement this you need a parent process, which forks a child process |
|
365 \item this child process drops privileges and listens to hostile data\medskip |
|
366 |
|
367 \item after authentication the parent forks again and the new child becomes the user |
|
368 \end{itemize} |
|
369 |
|
370 |
|
371 \end{frame}} |
|
372 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
373 |
|
374 |
|
375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
376 \mode<presentation>{ |
|
377 \begin{frame}[c] |
|
378 \frametitle{\begin{tabular}{@ {}c@ {}}Famous Security Flaws\\[-1mm] in Unix\end{tabular}} |
|
379 |
|
380 |
|
381 \begin{itemize} |
|
382 \item \texttt{lpr} unfortunately runs with root privileges; you had the option to delete files after printing \ldots\pause\pause |
|
383 \item for debugging purposes (FreeBSD) Unix provides a ``core dump'', but allowed to follow links \ldots\pause |
|
384 \item \texttt{mkdir foo} is owned by root\medskip |
|
385 \begin{center} |
|
386 \texttt{-rwxr-xr-x 1 root wheel /bin/mkdir} |
|
387 \end{center}\medskip |
|
388 it first creates an i-node as root and then changes to ownership to the user's id\\ \textcolor{gray}{\small (race condition -- can be automated with a shell script)} |
|
389 \end{itemize} |
|
390 |
|
391 \only<5->{ |
|
392 \begin{textblock}{1}(3,7) |
|
393 \begin{tikzpicture} |
|
394 \draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
|
395 {\begin{minipage}{8cm} |
|
396 Only failure makes us experts. |
|
397 -- Theo de Raadt (OpenBSD, OpenSSH) |
|
398 \end{minipage}}; |
|
399 \end{tikzpicture} |
|
400 \end{textblock}} |
|
401 |
|
402 |
|
403 |
|
404 \end{frame}} |
|
405 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
406 |
|
407 |
|
408 |
|
409 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
410 \mode<presentation>{ |
|
411 \begin{frame}[c] |
|
412 \frametitle{\begin{tabular}{@ {}c@ {}}A ``Cron''-Attack\end{tabular}} |
|
413 |
|
414 \begin{enumerate} |
|
415 \item attacker \textcolor{gray}{(creates a fake passwd file)}\\ |
|
416 \texttt{mkdir /tmp/a; cat > /tmp/a/passwd}\medskip |
|
417 \item root \textcolor{gray}{(does the daily cleaning)}\\ |
|
418 \texttt{rm /tmp/*/*}\medskip\\ |
|
419 \hspace{2cm}\textcolor{gray}{\small records that \texttt{/tmp/a/passwd}}\\ |
|
420 \hspace{2cm}\textcolor{gray}{\small should be deleted, but does not do it yet}\medskip\\ |
|
421 |
|
422 \item attacker \textcolor{gray}{(meanwhile deletes the fake passwd file, and establishes a link to |
|
423 the real passwd file)}\\ |
|
424 \texttt{rm /tmp/a/passwd; rmdir /tmp/a;}\\\texttt{ln -s /etc /tmp/a}\\ |
|
425 \item root now deletes the real passwd file |
|
426 \end{enumerate} |
|
427 |
|
428 \only<2>{ |
|
429 \begin{textblock}{11}(2,5) |
|
430 \begin{tikzpicture} |
|
431 \draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
|
432 {\normalsize\color{darkgray} |
|
433 \begin{minipage}{9cm}\raggedright |
|
434 To prevent this kind of attack, you need additional |
|
435 policies (don't do such operations as root). |
|
436 \end{minipage}}; |
|
437 \end{tikzpicture} |
|
438 \end{textblock}} |
|
439 |
|
440 \end{frame}} |
|
441 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
442 |
|
443 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
444 \mode<presentation>{ |
|
445 \begin{frame}[c] |
|
446 |
|
447 \begin{center} |
|
448 \includegraphics[scale=0.45]{../pics/trainwreck.jpg}\\ |
|
449 one general defence mechanism is\\\alert{\bf defence in depth} |
|
450 \end{center} |
|
451 |
|
452 |
|
453 \end{frame}} |
|
454 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
455 |
|
456 |
|
457 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
458 \begin{frame}[c] |
|
459 \frametitle{Smash the Stack for Fun\ldots} |
169 \frametitle{Smash the Stack for Fun\ldots} |
460 |
170 |
461 \begin{itemize} |
171 \begin{itemize} |
462 \item ``smashing the stack attacks'' or\\ ``buffer overflow attacks''\medskip |
172 \item {\bf Buffer Overflow Attacks} or\\ {\bf Smashing the Stack Attacks}\medskip |
463 \item one of the most popular attacks\\ ($>$ 50\% of security incidents reported at CERT are related to buffer overflows) |
173 |
464 \begin{flushright}\small |
174 \item one of the most popular attacks, unfortunately\\ |
465 \textcolor{gray}{\url{http://www.kb.cert.org/vuls}} |
175 ($>$ 50\% of security incidents reported at CERT are related |
|
176 to buffer overflows) |
|
177 \begin{flushright} |
|
178 \small\url{http://www.kb.cert.org/vuls} |
466 \end{flushright} |
179 \end{flushright} |
467 \medskip |
180 \medskip |
468 \item made popular in an article by Elias Levy\\ (also known as Aleph One):\\ |
181 \item made popular in an article from 1996 by Elias Levy |
|
182 (also known as Aleph One):\\ |
469 \begin{center} |
183 \begin{center} |
470 {\bf ``Smashing The Stack For Fun and Profit''} |
184 {\bf ``Smashing The Stack For Fun and Profit''} |
471 \end{center}\medskip |
185 \end{center}\medskip |
472 |
186 |
473 \begin{flushright} |
187 \begin{flushright} |
474 \small\textcolor{gray}{Issue 49, Article 14} |
188 \small\url{http://phrack.org/issues/49/14.html} |
475 \end{flushright} |
189 \end{flushright} |
476 |
190 |
477 \end{itemize} |
191 \end{itemize} |
478 |
192 |
479 \end{frame} |
193 \end{frame} |
480 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
481 |
195 |
482 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
483 \begin{frame}[c] |
197 \begin{frame}[c] |
484 \frametitle{A Float Printed ``Twice''} |
198 \frametitle{A Long Printed ``Twice''} |
|
199 \mbox{}\\[-10mm] |
485 |
200 |
486 \footnotesize |
201 \footnotesize |
487 \lstinputlisting[language=C]{../progs/C1.c} |
202 \lstinputlisting[language=C,xleftmargin=4mm]{../progs/C0.c} |
488 |
203 |
489 \end{frame} |
204 \end{frame} |
490 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
206 |
|
207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
208 \begin{frame}[c] |
|
209 \frametitle{``A Login Function'' (1)} |
|
210 \mbox{}\\[-10mm] |
|
211 |
|
212 \footnotesize |
|
213 \lstinputlisting[language=C,xleftmargin=4mm]{../progs/C2a.c} |
|
214 |
|
215 \end{frame} |
|
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
217 |
|
218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
219 \begin{frame}[c] |
|
220 \frametitle{``A Login Function'' (2)} |
|
221 \mbox{}\\[-10mm] |
|
222 |
|
223 \footnotesize |
|
224 \lstinputlisting[language=C,xleftmargin=-3mm]{../progs/C2b.c} |
|
225 |
|
226 \end{frame} |
|
227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
228 |
|
229 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
230 \begin{frame}[c] |
|
231 \frametitle{What the Hell Is Going On?} |
|
232 |
|
233 \lstinputlisting[language=C,xleftmargin=4mm]{../progs/example1.c} |
|
234 |
|
235 \end{frame} |
|
236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
491 |
237 |
492 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
493 \begin{frame}[c] |
239 \begin{frame}[c] |
494 \frametitle{Memory} |
240 \frametitle{Memory} |
495 |
241 |
564 \footnotesize |
310 \footnotesize |
565 \lstinputlisting[language=C,xleftmargin=5mm]{../progs/example1.c} |
311 \lstinputlisting[language=C,xleftmargin=5mm]{../progs/example1.c} |
566 \end{bubble} |
312 \end{bubble} |
567 \end{textblock} |
313 \end{textblock} |
568 |
314 |
569 |
|
570 \end{frame} |
315 \end{frame} |
571 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
316 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
317 |
|
318 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
319 \begin{frame}[c] |
|
320 \frametitle{Behind the Scenes} |
|
321 |
|
322 machine code |
|
323 |
|
324 \end{frame} |
|
325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
326 |
|
327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
328 \begin{frame}[c] |
|
329 \frametitle{\begin{tabular}{c}Network Applications:\\[-1mm] Privilege Separation\end{tabular}} |
|
330 |
|
331 |
|
332 \begin{center} |
|
333 \begin{tikzpicture}[scale=1] |
|
334 |
|
335 \draw[line width=1mm] (-.3, 0) rectangle (1.5,2); |
|
336 \draw (4.7,1) node {Internet}; |
|
337 \draw (-2.7,1.7) node {\footnotesize Application}; |
|
338 \draw (0.6,1.7) node {\footnotesize Interface}; |
|
339 \draw (0.6,-0.4) node {\footnotesize \begin{tabular}{c}unprivileged\\[-1mm] process\end{tabular}}; |
|
340 \draw (-2.7,-0.4) node {\footnotesize \begin{tabular}{c}privileged\\[-1mm] process\end{tabular}}; |
|
341 |
|
342 \draw[line width=1mm] (-1.8, 0) rectangle (-3.6,2); |
|
343 |
|
344 \draw[white] (1.7,1) node (X) {}; |
|
345 \draw[white] (3.7,1) node (Y) {}; |
|
346 \draw[red, <->, line width = 2mm] (X) -- (Y); |
|
347 |
|
348 \draw[red, <->, line width = 1mm] (-0.6,1) -- (-1.6,1); |
|
349 \end{tikzpicture} |
|
350 \end{center} |
|
351 |
|
352 \begin{itemize} |
|
353 \item the idea is make the attack surface smaller and mitigate the |
|
354 consequences of an attack |
|
355 \item you need an OS that supports different roles (root vs.~users) |
|
356 \end{itemize} |
|
357 |
|
358 \end{frame} |
|
359 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
360 |
|
361 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
362 \begin{frame}[c] |
|
363 \frametitle{Weaknesses of Unix AC} |
|
364 |
|
365 Not just restricted to Unix: |
|
366 |
|
367 \begin{itemize} |
|
368 \item if you have too many roles (i.e.~too finegrained AC), then |
|
369 hierarchy is too complex\\ \textcolor{gray}{you invite situations |
|
370 like\ldots let's be root}\bigskip |
|
371 |
|
372 \item you can still abuse the system\ldots |
|
373 \end{itemize} |
|
374 |
|
375 \end{frame} |
|
376 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
377 |
|
378 |
|
379 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
380 \begin{frame}[c] |
|
381 \frametitle{A ``Cron''-Attack} |
|
382 |
|
383 \begin{enumerate} |
|
384 \item attacker \textcolor{gray}{(creates a fake passwd file)}\\ |
|
385 \texttt{mkdir /tmp/a; cat > /tmp/a/passwd}\medskip |
|
386 \item root \textcolor{gray}{(does the daily cleaning)}\\ |
|
387 \texttt{rm /tmp/*/*}\medskip\\ |
|
388 \hspace{2cm}\textcolor{gray}{\small records that \texttt{/tmp/a/passwd}}\\ |
|
389 \hspace{2cm}\textcolor{gray}{\small should be deleted, but does not do it yet}\medskip\\ |
|
390 |
|
391 \item attacker \textcolor{gray}{(meanwhile deletes the fake passwd file, and establishes a link to |
|
392 the real passwd file)}\\ |
|
393 \texttt{rm /tmp/a/passwd; rmdir /tmp/a;}\\\texttt{ln -s /etc /tmp/a}\\ |
|
394 \item root now deletes the real passwd file |
|
395 \end{enumerate} |
|
396 |
|
397 \only<2>{ |
|
398 \begin{textblock}{11}(2,5) |
|
399 \begin{bubble}[8cm] |
|
400 \normalsize To prevent this kind of attack, you need additional |
|
401 policies (don't do such operations as root). |
|
402 \end{bubble} |
|
403 \end{textblock}} |
|
404 |
|
405 \end{frame} |
|
406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
572 |
407 |
573 |
408 |
574 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
409 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
575 \begin{frame}[c] |
410 \begin{frame}[c] |
576 \frametitle{The Problem} |
411 \frametitle{The Problem} |
730 \end{itemize} |
553 \end{itemize} |
731 |
554 |
732 \end{frame} |
555 \end{frame} |
733 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
556 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
734 |
557 |
|
558 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
559 \mode<presentation>{ |
|
560 \begin{frame}[c] |
|
561 \frametitle{Access Control in Unix} |
|
562 |
|
563 \begin{itemize} |
|
564 \item access control provided by the OS |
|
565 \item authenticate principals (login) |
|
566 \item mediate access to files, ports, processes according to \alert{roles} (user ids)\\ |
|
567 \item roles get attached with privileges\bigskip\\% |
|
568 \hspace{8mm} |
|
569 \begin{tikzpicture} |
|
570 \draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
|
571 {\begin{minipage}{8cm} |
|
572 \alert{The principle of least privilege:}\\ |
|
573 programs should only have as much privilege as they need |
|
574 \end{minipage}}; |
|
575 \end{tikzpicture} |
|
576 \end{itemize} |
|
577 |
|
578 \end{frame}} |
|
579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
580 |
|
581 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
582 \mode<presentation>{ |
|
583 \begin{frame}[t] |
|
584 \frametitle{Process Ownership} |
|
585 |
|
586 \begin{itemize} |
|
587 \item access control in Unix is very coarse |
|
588 \end{itemize}\bigskip\bigskip\bigskip |
|
589 |
|
590 \begin{center} |
|
591 \begin{tabular}{c} |
|
592 root\\ |
|
593 \hline |
|
594 |
|
595 user$_1$ user$_2$ \ldots www, mail, lp |
|
596 \end{tabular} |
|
597 \end{center}\bigskip\bigskip\bigskip |
|
598 |
|
599 |
|
600 \textcolor{gray}{\small root has UID $=$ 0}\\\pause |
|
601 \textcolor{gray}{\small you also have groups that can share access to a file}\\ |
|
602 \textcolor{gray}{\small but it is difficult to exclude access selectively}\\ |
|
603 \end{frame}} |
|
604 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
605 |
|
606 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
607 \mode<presentation>{ |
|
608 \begin{frame}[c] |
|
609 \frametitle{Access Control in Unix (2)} |
|
610 |
|
611 |
|
612 \begin{itemize} |
|
613 \item privileges are specified by file access permissions (``everything is a file'') |
|
614 \item there are 9 (plus 2) bits that specify the permissions of a file |
|
615 |
|
616 \begin{center} |
|
617 \begin{tabular}{l} |
|
618 \texttt{\$ ls - la}\\ |
|
619 \texttt{-rwxrw-r-{}- \hspace{3mm} foo\_file.txt} |
|
620 \end{tabular} |
|
621 \end{center} |
|
622 \end{itemize} |
|
623 |
|
624 \end{frame}} |
|
625 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
626 |
|
627 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
628 \mode<presentation>{ |
|
629 \begin{frame}[c] |
|
630 \frametitle{Login Process} |
|
631 |
|
632 |
|
633 \begin{itemize} |
|
634 \item login processes run under UID $=$ 0\medskip |
|
635 \begin{center} |
|
636 \texttt{ps -axl | grep login} |
|
637 \end{center}\medskip |
|
638 |
|
639 \item after login, shells run under UID $=$ user (e.g.~501)\medskip |
|
640 \begin{center} |
|
641 \texttt{id cu} |
|
642 \end{center}\medskip\pause |
|
643 |
|
644 \item non-root users are not allowed to change the UID --- would break |
|
645 access control |
|
646 \item but needed for example for \texttt{passwd} |
|
647 \end{itemize} |
|
648 |
|
649 \end{frame}} |
|
650 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
651 |
|
652 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
653 \mode<presentation>{ |
|
654 \begin{frame}[c] |
|
655 \frametitle{Setuid and Setgid} |
|
656 |
|
657 The solution is that unix file permissions are 9 + \underline{2 Bits}: |
|
658 \alert{Setuid} and \alert{Setgid} Bits |
|
659 |
|
660 \begin{itemize} |
|
661 \item When a file with setuid is executed, the resulting process will assume the UID given to the owner of the file. |
|
662 \item This enables users to create processes as root (or another user).\bigskip |
|
663 |
|
664 \item Essential for changing passwords, for example. |
|
665 \end{itemize} |
|
666 |
|
667 \begin{center} |
|
668 \texttt{chmod 4755 fobar\_file} |
|
669 \end{center} |
|
670 |
|
671 \end{frame}} |
|
672 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
673 |
|
674 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
675 \mode<presentation>{ |
|
676 \begin{frame}[c] |
|
677 \frametitle{\begin{tabular}{c}Privilege Separation in\\ OpenSSH\end{tabular}} |
|
678 |
|
679 \begin{center} |
|
680 \begin{tikzpicture}[scale=1] |
|
681 |
|
682 \draw[line width=1mm] (0, 1.1) rectangle (1.2,2); |
|
683 \draw (4.7,1) node {Internet}; |
|
684 \draw (0.6,1.7) node {\footnotesize Slave}; |
|
685 \draw[line width=1mm] (0, 0) rectangle (1.2,0.9); |
|
686 \draw (0.6,1.7) node {\footnotesize Slave}; |
|
687 \draw (0.6,0.6) node {\footnotesize Slave}; |
|
688 \draw (0.6,-0.5) node {\footnotesize \begin{tabular}{c}unprivileged\\[-1mm] processes\end{tabular}}; |
|
689 \draw (-2.7,-0.4) node {\footnotesize \begin{tabular}{c}privileged\\[-1mm] process\end{tabular}}; |
|
690 |
|
691 \draw[line width=1mm] (-1.8, 0) rectangle (-3.6,2); |
|
692 \draw (-2.9,1.7) node {\footnotesize Monitor}; |
|
693 |
|
694 \draw[white] (1.7,1) node (X) {}; |
|
695 \draw[white] (3.7,1) node (Y) {}; |
|
696 \draw[red, <->, line width = 2mm] (X) -- (Y); |
|
697 |
|
698 \draw[red, <->, line width = 1mm] (-0.4,1.4) -- (-1.4,1.1); |
|
699 \draw[red, <->, line width = 1mm] (-0.4,0.6) -- (-1.4,0.9); |
|
700 |
|
701 \end{tikzpicture} |
|
702 \end{center} |
|
703 |
|
704 \begin{itemize} |
|
705 \item pre-authorisation slave |
|
706 \item post-authorisation\bigskip |
|
707 \item 25\% codebase is privileged, 75\% is unprivileged |
|
708 \end{itemize} |
|
709 \end{frame}} |
|
710 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
711 |
|
712 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
713 \mode<presentation>{ |
|
714 \begin{frame}[c] |
|
715 \frametitle{Network Applications} |
|
716 |
|
717 ideally network application in Unix should be designed as follows: |
|
718 |
|
719 \begin{itemize} |
|
720 \item need two distinct processes |
|
721 \begin{itemize} |
|
722 \item one that listens to the network; has no privilege |
|
723 \item one that is privileged and listens to the latter only (but does not trust it) |
|
724 |
|
725 \end{itemize} |
|
726 |
|
727 \item to implement this you need a parent process, which forks a child process |
|
728 \item this child process drops privileges and listens to hostile data\medskip |
|
729 |
|
730 \item after authentication the parent forks again and the new child becomes the user |
|
731 \end{itemize} |
|
732 |
|
733 |
|
734 \end{frame}} |
|
735 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
736 |
|
737 |
|
738 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
739 \mode<presentation>{ |
|
740 \begin{frame}[c] |
|
741 \frametitle{\begin{tabular}{@ {}c@ {}}Famous Security Flaws\\[-1mm] in Unix\end{tabular}} |
|
742 |
|
743 |
|
744 \begin{itemize} |
|
745 \item \texttt{lpr} unfortunately runs with root privileges; you had the option to delete files after printing \ldots\pause\pause |
|
746 \item for debugging purposes (FreeBSD) Unix provides a ``core dump'', but allowed to follow links \ldots\pause |
|
747 \item \texttt{mkdir foo} is owned by root\medskip |
|
748 \begin{center} |
|
749 \texttt{-rwxr-xr-x 1 root wheel /bin/mkdir} |
|
750 \end{center}\medskip |
|
751 it first creates an i-node as root and then changes to ownership to the user's id\\ \textcolor{gray}{\small (race condition -- can be automated with a shell script)} |
|
752 \end{itemize} |
|
753 |
|
754 \only<5->{ |
|
755 \begin{textblock}{1}(3,7) |
|
756 \begin{tikzpicture} |
|
757 \draw (0,0) node[inner sep=2mm,fill=cream, ultra thick, draw=red, rounded corners=2mm] |
|
758 {\begin{minipage}{8cm} |
|
759 Only failure makes us experts. |
|
760 -- Theo de Raadt (OpenBSD, OpenSSH) |
|
761 \end{minipage}}; |
|
762 \end{tikzpicture} |
|
763 \end{textblock}} |
|
764 |
|
765 |
|
766 |
|
767 \end{frame}} |
|
768 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
769 |
|
770 |
735 |
771 |
736 \end{document} |
772 \end{document} |
737 |
773 |
738 %%% Local Variables: |
774 %%% Local Variables: |
739 %%% mode: latex |
775 %%% mode: latex |