|
218 | 218 | \end{slide} |
219 | 219 |
|
220 | 220 | \begin{itemize} |
221 | | -\item procesy superu¾ivatele \texttt{root} mohou mìnit svoji u¾ivatelskou a |
222 | | -skupinovou identitu. Toho vyu¾ívá napø. proces \texttt{login}, který bì¾í jako |
223 | | -\texttt{root} a po zkontrolování jména a hesla spustí shell s u¾ivatelskou |
224 | | -identitou (pomocí volání \texttt{setuid} -- viz dal¹í slajdy). |
225 | | -\item z algoritmu plyne, ¾e pro \texttt{root}a není relevantní nastavení práv |
226 | | -(má v¾dy neomezený pøístup). Pokud se shoduje u¾ivatel, nepou¾ijí se nikdy práva |
227 | | -skupiny nebo ostatních, i kdy¾ povolují více ne¾ u¾ivatelská práva. Podobnì |
228 | | -práva ostatních se nepou¾ijí, jestli¾e se shoduje skupinová identita. \emsl{Tedy |
229 | | -pokud má mùj soubor nastaveny práva \texttt{---rwxrwx}, nemohu ho èíst, |
230 | | -zapisovat ani spustit, dokud nastavení práv nezmìním.} |
231 | | -\item èím dál víc systémù se odklání od klasického modelu, kdy mnoho procesù |
232 | | -bì¾elo pod u¾ivatelem s UID 0 a pøi bezpeènostní chybì v takové aplikaci èasto |
233 | | -útoèník získal vládu nad celým systémem a zavádìjí modely jako je \emph{least |
234 | | -privilege model} v Solarisu nebo \emph{privilege separation} a \emph{pledge} |
235 | | -v OpenBSD. |
236 | | -\item \label{FILEDELETE} opakování z prvního roèníku -- aby u¾ivatel mohl smazat |
237 | | -soubor, musí mít právo zápisu do daného \emsl{adresáøe}, proto¾e to je ten |
238 | | -``soubor'', co se mìní. \emsl{Práva k mazanému souboru nejsou podstatná}; to ¾e |
239 | | -vás shell upozorní, ¾e ma¾ete soubor, ke kterému nemáte právo zápisu, je pouze |
240 | | -vìc toho shellu. Je to logické -- pokud si nastavíte soubor jako read-only, |
241 | | -shell usuzuje, ¾e ho asi normálnì mazat nechcete. Viz pøíklad pod tímto |
242 | | -odstavcem. \emsl{Unixové systémy nemají delete-like operaci na soubor}, smazání |
243 | | -souboru nastane automaticky tehdy, kdy¾ na soubor není ¾ádný odkaz z adresáøové |
244 | | -struktury, a nikdo soubor ji¾ nemá otevøený. |
| 221 | +\item The processes of the \texttt{root} user can change its user and group |
| 222 | +identity. This is used by e.g. the \texttt{login} process, that runs as |
| 223 | +\texttt{root} and after performing authentication check successfully it runs |
| 224 | +shell process with identity of given user (using the \texttt{setuid} syscall |
| 225 | +-- see upcoming slides). |
| 226 | +\item The implication of the algorithm is that for the \texttt{root} user the |
| 227 | +access rights are not relevant (it has always unlimited access -- at least in |
| 228 | +classic UNIX without fine grained privileges). If the user is equal, the |
| 229 | +group/other rights are not used even though them permit more than what user |
| 230 | +rights do. Similarly the others rights are not used if the group is equal. |
| 231 | +\emsl{Therefore if a file owned by my user has the rights set to |
| 232 | +\texttt{---rwxrwx}, I cannot read/write/execute it until I change the rights.} |
| 233 | +\item More and more system diverge from the classic model where many processes |
| 234 | +were running under a user with UID 0. Security vulnerability in such application |
| 235 | +meant total control of the system. To thwart this, these systems employ models |
| 236 | +like \emph{least privilege} in Solarisu or \emph{privilege separation} and |
| 237 | +\emph{pledge} in OpenBSD. |
| 238 | +\item \label{FILEDELETE} In order to delete a file, the user has to have a right |
| 239 | +to write to the \emsl{directory} containing the file, because this is the |
| 240 | +``file'', that is being changed. \emsl{The rights of the file to be deleted are |
| 241 | +not relevant}; the shell might give you a warning that you are about to delete a |
| 242 | +file for which you do not have the right to write, however this is just |
| 243 | +informative. It is logical -- if you set a file as read-only, the shell will |
| 244 | +deduce that you do not normally want to delete such file. See the example below. |
| 245 | +\emsl{Unix systems do not have delete-like operation for a fike}, the file is |
| 246 | +deleted automatically once it is no longer referenced from directory structure |
| 247 | +and the file is not open by any process. |
245 | 248 |
|
246 | 249 | \begin{verbatim} |
247 | 250 | $ whoami |
|
256 | 259 | $ ls janp-dir/root_wuz_here.txt |
257 | 260 | janp-dir/root_wuz_here.txt: No such file or directory |
258 | 261 | \end{verbatim} |
259 | | -\item pokud ale \texttt{root} vytvoøí v adresáøi \texttt{janp-dir} svùj |
260 | | -podadresáø a tam vlo¾í svùj soubor, u¾ivatel \texttt{janp} u¾ nemù¾e |
261 | | -adresáø \texttt{janp-dir} a jeho obsah smazat, proto¾e: |
| 262 | +\item However if \texttt{root} creates its own sub-directory in the |
| 263 | +\texttt{janp-dir} directory and creates a new file there, the |
| 264 | +\texttt{janp} user can no longer delete the \texttt{janp-dir} directory and its |
| 265 | +contents because: |
262 | 266 | \begin{itemize} |
263 | | -\item podadresáø nelze smazat proto¾e není prázdný |
264 | | -\item a daný soubor nelze smazat z toho dùvodu, ¾e \texttt{janp} není vlastníkem |
265 | | -podadresáøe. |
| 267 | +\item sub-directory cannot be deleted if non-empty |
| 268 | +\item given file cannot be deleted because \texttt{janp} is not user of |
| 269 | +the sub-directory |
266 | 270 | \end{itemize} |
267 | | -\item Pokud odeberu adresáøi read bit, není mo¾né èíst jeho obsah, tedy |
268 | | -provádìt výpis souborù v nìm obsa¾ených. Pokud ale znám jméno souboru v |
269 | | -adresáøi a execute bit je nastaven, mohu soubor pøeèíst: |
| 271 | +\item If the read bit is removed from a directory rights, it is not possible to |
| 272 | +read its contents, therefore list files therein contained. However if I know |
| 273 | +the name of the file in the directory and the execute bit is set, I can read the |
| 274 | +file: |
270 | 275 | \begin{verbatim} |
271 | 276 | $ mkdir foo |
272 | 277 | $ ls -ald foo |
|
282 | 287 | $ file foo/bar |
283 | 288 | foo/bar: empty |
284 | 289 | \end{verbatim} |
285 | | -\item existuje situace, kdy ani právo zápisu (a execute) pro adresáø nestaèí. To |
286 | | -se pou¾ívá u \texttt{tmp} adresáøù, do kterých mù¾e ka¾dý psát, ale není ¾ádoucí |
287 | | -situace, kdy by si u¾ivatelé navzájem mazali soubory. K tomu se pou¾ívá tzv. |
288 | | -\emph{sticky bit} (01000). Systémy mají vet¹inou manuálovou stránku |
289 | | -\texttt{sticky}, kde je funkce sticky bitu popsaná. Na výpisu \texttt{ls} je |
290 | | -oznaèovaný jako \texttt{\emsl{t}}: |
| 290 | +\item There is a situation where even the execute bit for a directory is not |
| 291 | +sufficient. This is used for temporary directories, where anyone can write to |
| 292 | +however it is not desirable to permit users to delete each others files. |
| 293 | +To achieve that there is the \emph{sticky bit} (01000). There might be a |
| 294 | +\texttt{sticky} man page, where the sticky bit function is described. |
| 295 | +It is visible as \texttt{\emsl{t}} in the \texttt{ls} output: |
291 | 296 |
|
292 | 297 | \begin{verbatim} |
293 | 298 | $ ls -ld /tmp |
294 | 299 | drwxrwxrwt 7 root root 515 Mar 23 12:22 /tmp |
295 | 300 | \end{verbatim} |
296 | 301 | \end{itemize} |
297 | 302 |
|
298 | | - |
299 | 303 | %%%%% |
300 | 304 |
|
301 | 305 | \pdfbookmark[1]{ruid, euid, suid}{resugid} |
|
0 commit comments