handouts/ho04.tex
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sat, 18 Oct 2014 23:07:50 +0100
changeset 247 95e14b2dbc94
parent 245 630a3dd1efda
child 248 51fa0549fc8f
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
95e14b2dbc94 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 245
diff changeset
    89
programs on a Unix system. I counted 87 programs with the
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
95e14b2dbc94 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 245
diff changeset
    96
\subsubsection*{Secrecy and Integrity}
245
630a3dd1efda updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    97
630a3dd1efda updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
630a3dd1efda updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    99
630a3dd1efda updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   100
\end{document}
630a3dd1efda updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   101
630a3dd1efda updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
%%% Local Variables: 
630a3dd1efda updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
%%% mode: latex
630a3dd1efda updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   104
%%% TeX-master: t
630a3dd1efda updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   105
%%% End: