author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Sun, 19 Oct 2014 00:41:51 +0100 | |
changeset 248 | 51fa0549fc8f |
parent 247 | 95e14b2dbc94 |
child 249 | 31a749eba8c1 |
permissions | -rw-r--r-- |
245
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
\documentclass{article} |
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
\usepackage{../style} |
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
\usepackage{../langs} |
247
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
4 |
|
245
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
\usetikzlibrary{patterns,decorations.pathreplacing} |
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
|
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
7 |
\begin{document} |
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
|
247
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
9 |
\section*{Handout 4 (Access Control)} |
245
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
|
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
Access control is essentially about deciding whether to grant |
247
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
12 |
access to a resource or deny it. Sounds easy. No? Well it |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
13 |
turns out that things are not as simple as they seem at first |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
14 |
glance. Let us first look as a case-study at how access |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
15 |
control is organised in Unix-like systems (Windows systems |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
16 |
have similar access controls, although the details might be |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
17 |
quite different). |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
18 |
|
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
19 |
|
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
20 |
\subsubsection*{Unix-Style Access Control} |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
21 |
|
245
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
Following the Unix-philosophy that everything is considered as |
247
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
23 |
a file, even memory, ports and so on, access control in Unix |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
24 |
is organised around 11 Bits that specify how a file can be |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
25 |
accessed. These Bits are sometimes called the \emph{permission |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
26 |
attributes} of a file. There are typically three modes for |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
27 |
access: \textbf{r}ead, \textbf{w}rite and e\textbf{x}ecute. |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
28 |
Moreover there are three user groups to which the modes apply: |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
29 |
the owner of the file, the group the file is associated with |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
30 |
and everybody else. A typical example of some files with |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
31 |
permission attributes is as follows: |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
32 |
|
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
33 |
{\small\lstinputlisting[language={}]{../slides/lst}} |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
34 |
|
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
35 |
\noindent The leading \pcode{d} in Lines 2 and 6 indicate that |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
36 |
the file is a directory, whereby in the Unix-tradition the |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
37 |
\pcode{.} points to the directory itself. The \pcode{..} |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
38 |
points at the directory ``above'', or parent directory. The |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
39 |
second to fourth letter specify how the owner of the file can |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
40 |
access the file. For example Line 3 states that \pcode{ping} |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
41 |
can read and write the \pcode{manual.txt}, but cannot execute |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
42 |
it. The next three letters specify how the group members of |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
43 |
the file can access the file. In Line 4, for example, all |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
44 |
students can read and write the file \pcode{report.txt}. |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
45 |
Finally the last three letters specify how everybody else can |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
46 |
access a file. This should all be relatively familiar and |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
47 |
straightforward. No? |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
48 |
|
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
49 |
There are already some special rules for directories. If the |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
50 |
execute attribute of a directory is \emph{not} set, then one |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
51 |
cannot change into the directory and one cannot access any |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
52 |
file inside it. If the write attribute is not set, then one |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
53 |
can change existing files (provide they are changeable), but |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
54 |
one cannot create new files. If the read attribute is not set, |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
55 |
one cannot search inside the directory (\pcode{ls -la} does |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
56 |
not work) but one can access an existing file, provided one |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
57 |
knows its name. |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
58 |
|
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
59 |
While the above might sound moderately complicated, the real |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
60 |
complications with Unix-style file permissions involve the |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
61 |
setuid and setgid attributes. For example the file |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
62 |
\pcode{microedit} in Line 5 has the setuid attribute set |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
63 |
(indicated by the \pcode{s} in place of the usual \pcode{x}). |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
64 |
The purpose of setuid and setgid is to solve the following |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
65 |
puzzle: The program \pcode{passwd} allows users to change |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
66 |
their passwords. Therefore \pcode{passwd} needs to have write |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
67 |
access to the file \pcode{/etc/passwd}. But this file cannot |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
68 |
be writable for every user, otherwise anyone can set anyone |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
69 |
else's password. So changing securely passwords cannot be |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
70 |
achieved with the simple Unix access rights discussed so far. |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
71 |
While this situation might look like an anomaly, it is in fact |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
72 |
an often occurring problem. For example looking at current |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
73 |
active processes with \pcode{/bin/ps} requires access to |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
74 |
internal data structures of the operating system. In fact any |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
75 |
of the following actions cannot be configured for single |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
76 |
users, but need privileged root access |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
77 |
|
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
78 |
\begin{itemize} |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
79 |
\item changing system databases (users, groups, routing tables |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
80 |
and so on) |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
81 |
\item opening a network port below 1024 |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
82 |
\item interacting with peripheral hardware, such as printers, |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
83 |
harddisk etc |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
84 |
\item overwriting operating system facilities, like |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
85 |
process scheduling and memory management |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
86 |
\end{itemize} |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
87 |
|
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
88 |
\noindent This will typically involve quite a lot of |
248
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
89 |
programs on a Unix system. I counted 95 programs with the |
247
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
90 |
setuid attribute set on my bog-standard MacOSX system |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
91 |
(including the program \pcode{/usr/bin/login}). |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
92 |
The problem is that if there is a security problem with |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
93 |
one of them, then malicious users (or outside attackers) |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
94 |
can gain root access. |
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
95 |
|
248
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
96 |
The main rule for files that have the setuid attribute set is |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
97 |
that when running such files they will run not with the |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
98 |
callers access rights, but with the owner of the files rights. |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
99 |
So \pcode{/usr/bin/login} will always be running with root |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
100 |
access rights, no matter who invokes this program. |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
101 |
|
247
95e14b2dbc94
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
245
diff
changeset
|
102 |
\subsubsection*{Secrecy and Integrity} |
245
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
103 |
|
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
104 |
|
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
105 |
|
248
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
106 |
\subsubsection*{Further Information} |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
107 |
|
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
108 |
If you want to know more about the intricacies of the |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
109 |
``simple'' Unix access control system you might find the |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
110 |
relatively readable paper about ``Setuid Demystified'' |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
111 |
useful. |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
112 |
|
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
113 |
\begin{center}\small |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
114 |
\url{http://www.cs.umd.edu/~jkatz/TEACHING/comp_sec_F04/downloads/setuid.pdf} |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
115 |
\end{center} |
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
116 |
|
51fa0549fc8f
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
247
diff
changeset
|
117 |
|
245
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
118 |
\end{document} |
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
119 |
|
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
120 |
%%% Local Variables: |
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
121 |
%%% mode: latex |
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
122 |
%%% TeX-master: t |
630a3dd1efda
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
123 |
%%% End: |