network fs access control
play

Network FS / Access Control 1 last time two-phase commit - PowerPoint PPT Presentation

Network FS / Access Control 1 last time two-phase commit consensus: workers + coordinator agree to commit no take-backs via redo-logging at each node blocking on failure idea of majority-vote consensus 2 logistics note last weeks


  1. still allows stateless server updating cached copies? client A does B get updated version from A? how? read NOTES.txt? when does A tell server about update? write to NOTES.txt? did NOTES.txt change? one solution: A checks on every read how does A’s copy get updated? write to NOTES.txt? can A actually use its cached copy? how does A’s copy get updated? write to NOTES.txt? server client B of NOTES.txt cached copy 21 update

  2. still allows stateless server updating cached copies? client A does B get updated version from A? how? read NOTES.txt? when does A tell server about update? write to NOTES.txt? did NOTES.txt change? one solution: A checks on every read how does A’s copy get updated? write to NOTES.txt? can A actually use its cached copy? how does A’s copy get updated? write to NOTES.txt? server client B of NOTES.txt cached copy 21 update

  3. NFSv3’s solution: allow some inconsistency consistency with stateless server always check server before using cached version write through all updates to server allows server to not remember clients no extra code for server/client failures, etc. …but kinda destroys benefjt of caching many milliseconds to contact server, even if not transferring data update server on close; check cache on open alternate solution: give up on stateless server 22

  4. NFSv3’s solution: allow some inconsistency consistency with stateless server always check server before using cached version write through all updates to server allows server to not remember clients no extra code for server/client failures, etc. …but kinda destroys benefjt of caching many milliseconds to contact server, even if not transferring data update server on close; check cache on open alternate solution: give up on stateless server 22

  5. NFSv3’s solution: allow some inconsistency consistency with stateless server always check server before using cached version write through all updates to server allows server to not remember clients no extra code for server/client failures, etc. …but kinda destroys benefjt of caching many milliseconds to contact server, even if not transferring data update server on close; check cache on open alternate solution: give up on stateless server 22

  6. consistency with stateless server always check server before using cached version write through all updates to server allows server to not remember clients no extra code for server/client failures, etc. …but kinda destroys benefjt of caching many milliseconds to contact server, even if not transferring data update server on close; check cache on open alternate solution: give up on stateless server 22 NFSv3’s solution: allow some inconsistency

  7. typical text editor/word processor typical word processor: opening a fjle: open fjle, read it, load into memory, close it saving a fjle: open fjle, write it from memory, close it 23

  8. two people saving a fjle? have a word processor document on shared fjlesystem Q: if you open the fjle while someone else is saving, what do you expect? Q: if you save the fjle while someone else is saving, what do you expect? observation: not things we really expect to work anyways most applications don’t care about accessing fjle while someone has it open 24

  9. two people saving a fjle? have a word processor document on shared fjlesystem Q: if you open the fjle while someone else is saving, what do you expect? Q: if you save the fjle while someone else is saving, what do you expect? observation: not things we really expect to work anyways most applications don’t care about accessing fjle while someone has it open 24

  10. open to close consistency a compromise: opening a fjle checks for updated version otherwise, use latest cache version closing a fjle writes updates from the cache otherwise, may not be immediately written idea: as long as one user loads/saves fjle at a time, great! 25

  11. open to close consistency a compromise: opening a fjle checks for updated version otherwise, use latest cache version closing a fjle writes updates from the cache otherwise, may not be immediately written idea: as long as one user loads/saves fjle at a time, great! 25

  12. protection/security protection: mechanisms for controlling access to resources page tables, preemptive scheduling, encryption, … security: using protection to prevent misuse misuse represented by policy e.g. “don’t expose sensitive info to bad people” this class: about mechanisms more than policies goal: provide enough fmexibility for many policies 26

  13. adversaries security is about adversaries do the worst possible thing challenge: adversary can be clever… 27

  14. authorization v authentication authentication — who is who authorization — who can do what probably need authentication fjrst… 28

  15. authorization v authentication authentication — who is who authorization — who can do what probably need authentication fjrst… 28

  16. authentication password hardware token … this class: mostly won’t deal with how just tracking afterwards 29

  17. authentication password hardware token … this class: mostly won’t deal with how just tracking afterwards 29

  18. access control matrix: who does what? read objects (whatever type) with restrictions … “group csfaculty” “user cr4bd” to 1+ protection domains : each process belongs kill write domain 3 fjle 1 wakeup write read domain 2 read/write domain 1 process 1 fjle 2 30

  19. access control matrix: who does what? read objects (whatever type) with restrictions … “group csfaculty” “user cr4bd” to 1+ protection domains : each process belongs kill write domain 3 fjle 1 wakeup write read domain 2 read/write domain 1 process 1 fjle 2 30

  20. access control matrix: who does what? read objects (whatever type) with restrictions … “group csfaculty” “user cr4bd” to 1+ protection domains : each process belongs kill write domain 3 fjle 1 wakeup write read domain 2 read/write domain 1 process 1 fjle 2 30

  21. access control matrix: who does what? read objects (whatever type) with restrictions … “group csfaculty” “user cr4bd” to 1+ protection domains : each process belongs kill write domain 3 fjle 1 wakeup write read domain 2 read/write domain 1 process 1 fjle 2 30

  22. access control matrix: who does what? read objects (whatever type) with restrictions … “group csfaculty” “user cr4bd” to 1+ protection domains : each process belongs kill write domain 3 fjle 1 wakeup write read domain 2 read/write domain 1 process 1 fjle 2 31

  23. user IDs most common way OSes identify what domain process belongs to: (unspecifjed for now) procedure sets user IDs every process has a user ID user ID used to decide what process is authorized to do 32

  24. POSIX user IDs uid_t geteuid(); // get current process's "effective" user ID process’s user identifjed with unique number kernel typically only knows about number efgective user ID is used for all permission checks also some other user IDs — we’ll talk later standard programs/library maintain number to name mapping /etc/passwd on typical single-user systems network database on department machines 33

  25. POSIX user IDs uid_t geteuid(); // get current process's "effective" user ID process’s user identifjed with unique number kernel typically only knows about number efgective user ID is used for all permission checks also some other user IDs — we’ll talk later standard programs/library maintain number to name mapping /etc/passwd on typical single-user systems network database on department machines 33

  26. POSIX groups gid_t getegid( void ); // process's"effective" group ID int getgroups( int size, gid_t list[]); // process's extra group IDs POSIX also has group IDs like user IDs: kernel only knows numbers standard library+databases for mapping to names also process has some other group IDs — we’ll talk later 34

  27. id cr4bd@power4 : /net/zf14/cr4bd ; id uid=858182(cr4bd) gid=21(csfaculty) groups=21(csfaculty),325(instructors),90027(cs4414) id command displays uid, gid, group list names looked up in database kernel doesn’t know about this database code in the C standard library 35

  28. groups that don’t correspond to users example: video group for access to monitor put process in video group when logged in directly don’t do it when SSH’d in …but: user can keep program running with video group in the background after logout? 36

  29. groups that don’t correspond to users example: video group for access to monitor put process in video group when logged in directly don’t do it when SSH’d in …but: user can keep program running with video group in the background after logout? 36

  30. access control matrix: who does what? read objects (whatever type) with restrictions … “group csfaculty” “user cr4bd” to 1+ protection domains : each process belongs kill write domain 3 fjle 1 wakeup write read domain 2 read/write domain 1 process 1 fjle 2 37

  31. representing access control matrix with objects (fjles, etc.): access control list list of protection domains (users, groups, processes, etc.) allowed to use each item list of (domain, object, permissions) stored “on the side” example: AppArmor on Linux confjguration fjle with list of program + what it is allowed to access prevent, e.g., print server from writing fjles it shouldn’t 38

  32. POSIX fjle permissions POSIX fjles have a very restricted access control list one user ID + read/write/execute bits for user “owner” — also can change permissions one group ID + read/write/execute bits for group default setting — read/write/execute (see docs for chmod command) 39

  33. POSIX/NTFS ACLs more fmexible access control lists list of (user or group, read or write or execute or …) supported by NTFS (Windows) a version standardized by POSIX, but usually not supported 40

  34. POSIX ACL syntax # group students have read+execute permissions # group faculty has read/write/execute permissions group:faculty:rwx # user mst3k has read/write/execute permissions user:mst3k:rwx # user tj1a has no permissions # POSIX acl rule: # user take precedence over group entries 41 group:students:r − x user:tj1a: −−−

  35. authorization checking on Unix checked on system call entry no relying on libraries, etc. to do checks fjles (open, rename, …) — fjle/directory permissions processes (kill, …) — process UID = user UID … 42

  36. superuser user ID 0 is special superuser or root some system calls: only work for uid 0 shutdown, mount new fjle systems, etc. automatically passes all (or almost all) permission checks 43

  37. how does login work? somemachine login: jo jo@somemachine$ l s ... this is a program which… checks if the password is correct, and changes user IDs, and runs a shell 44 password: ********

  38. how does login work? somemachine login: jo jo@somemachine$ l s ... this is a program which… checks if the password is correct, and changes user IDs, and runs a shell 45 password: ********

  39. Unix password storage typical single-user system: /etc/shadow only readable by root/superuser department machines: network service Kerberos / Active Directory: server takes (encrypted) passwords server gives tokens: “yes, really this user” can cryptographically verify tokens come from server 46

  40. aside: beyond passwords /bin/login entirely user-space code only thing special about it: when it’s run could use any criteria to decide, not just passwords physical tokens biometrics … 47

  41. how does login work? somemachine login: jo jo@somemachine$ l s ... this is a program which… checks if the password is correct, and changes user IDs, and runs a shell 48 password: ********

  42. changing user IDs int setuid(uid_t uid); if superuser: sets efgective user ID to arbitrary value and a “real user ID” and a “saved set-user-ID” (we’ll talk later) system starts in/login programs run as superuser voluntarily restrict own access before running shell, etc. 49

  43. sudo tj1a@somemachine$ sudo restart sudo: run command with superuser permissions started by non-superuser recall: inherits non-superuser UID can’t just call setuid(0) 50 Password: *********

  44. set-user-ID sudo extra metadata bit on executables : set-user-ID if set: exec() syscall changes efgective user ID to owner’s ID sudo program: owned by root, marked set-user-ID marking setuid: chmod u+s 51

  45. set-user ID gates set-user ID program: gate to higher privilege controlled access to extra functionality make authorization/authentication decisions outside the kernel way to allow normal users to do one thing that needs privileges write program that does that one thing — nothing else! make it owned by user that can do it (e.g. root) mark it set-user-ID want to allow only some user to do the thing make program check which user ran it 52

  46. uses for setuid programs mount USB stick setuid program controls option to kernel mount syscall make sure user can’t replace sensitive directories make sure user can’t mess up fjlesystems on normal hard disks make sure user can’t mount new setuid root fjles control access to device — printer, monitor, etc. setuid program talks to device + decides who can write to secure log fjle setuid program ensures that log is append-only for normal users setuid program creates socket, then becomes not root 53 bind to a particular port number < 1024

  47. set-user-ID program v syscalls hardware decision: some things only for kernel system calls: controlled access to things kernel can do decision about how can do it: in the kernel kernel decision: some things only for root (or other user) set-user-ID programs: controlled access to things root/… can do decision about how can do it: made by root/… 54

  48. a broken setuid program: setup suppose I have a directory all-grades on shared server in it I have a folder for each assignment and within that a text fjle for each user’s grade + other info say I don’t have fmexible ACLs and want to give each user access one (bad?) idea: setuid program to read grade for assignment ./print_grade assignment outputs grade from all-grades/assignment/USER.txt 55

  49. a broken setuid program: setup suppose I have a directory all-grades on shared server in it I have a folder for each assignment and within that a text fjle for each user’s grade + other info say I don’t have fmexible ACLs and want to give each user access one (bad?) idea: setuid program to read grade for assignment ./print_grade assignment outputs grade from all-grades/assignment/USER.txt 55

  50. a very broken setuid program print_grade.c: char filename[500]; sprintf(filename, "all-grades/%s/%s.txt", argv[1], getenv("USER")); int fd = open(filename, O_RDWR); char buffer[1024]; read(fd, buffer, 1024); printf("%s: %s\n", argv[1], buffer); } HUGE amount of stufg can go wrong examples? 56 int main( int argc, char **argv) { ␣

  51. set-user ID programs are very hard to write what if stdin, stdout, stderr start closed? what if the PATH env. var. set to directory of malicious programs? what if argc == 0 ? what if dynamic linker env. vars are set? what if some bug allows memory corruption? … 57

  52. a delegation problem consider printing program marked setuid to access printer decision: no accessing printer directly printing program enforces page limits, etc. command line: fjle to print can printing program just call open()? 58

  53. a broken solution if (original user can read file from argument) { open(file from argument); read contents of file; write contents of file to printer close(file from argument); } hope: this prevents users from printing fjles than can’t read problem: race condition! 59

  54. a broken solution / why read … time-to-check-to-time-of-use vulnerability (e.g. temporary fjle used by password-changing program) another possibility: run a program that creates secret fjle fjle/directory) another option: rename, symlink (“symbolic link” — alias for link: create new directory entry for fjle — — setuid program open("toprint.txt") link("/secret", "toprint.txt") unlink("toprint.txt") — check: can user access? (yes) create normal fjle toprint.txt other user program 60

  55. TOCTTOU solution temporarily ‘become’ original user then open then turn back into set-uid user this is why POSIX processes have multiple user IDs can swap out efgective user ID temporarily 61

  56. practical TOCTTOU races? can use symlinks maze to make check slower … lots of time spent following symbolic links when program opening toprint.txt gives more time to sneak in unlink/link or (more likely) rename 62 symlink toprint.txt → a/b/c/d/e/f/g/normal.txt symlink a/b → ../a symlink a/c → ../a

  57. exercise which (if any) of the following would fjx for a TOCTTOU vulnerability in our setuid printing application? (assume the Unix-permissions without ACLs are in use) [A] both before and after opening the path passed in for reading, check that the path is accessible to the user who ran our application [B] after opening the path passed in for reading, using fstat with the fjle descriptor opened to check the permissions on the fjle [C] before opening the path, verify that the user controls the fjle referred to by the path and the directory containing it 63

  58. some security tasks (1) helping students collaborate in ad-hoc small groups on shared server? Q1: what to allow/prevent? Q2: how to use POSIX mechanisms to do this? 64

  59. some security tasks (2) letting students assignment fjles to faculty on shared server? Q1: what to allow/prevent? Q2: how to use POSIX mechanisms to do this? 65

  60. some security tasks (3) running untrusted game program from Internet? Q1: what to allow/prevent? Q2: how to use POSIX mechanisms to do this? 66

  61. backup slides 67

  62. sandboxing sandbox — restricted environment for program idea: dangerous code can play in the sandbox as much as it wants can’t do anything harmful 68

  63. sandbox use cases buggy video parsing code that has bufger overfmows browser running scripts in webpage autograder running student submissions … (parts of) program that don’t need to have user’s full permissions no reason video parsing code should be able open() my taxes can we have a way to ask OS for this? 69

  64. sandbox use cases buggy video parsing code that has bufger overfmows browser running scripts in webpage autograder running student submissions … (parts of) program that don’t need to have user’s full permissions no reason video parsing code should be able open() my taxes can we have a way to ask OS for this? 69

  65. Google Chrome architecture 70

  66. sandboxing mechanisms create a new user with few privileged, switch to user problem: creating new users usually requires sysadmin access problem: every user can do too much e.g. everyone can open network connection? with capabilities, just discard most capabilities just close capabilities you don’t need run rendering engine with only pipes to talk to browser kernel otherwise: system call fjltering disallow all ‘dangerous’ system calls 71

  67. Linux system call fjltering seccomp() system call “strict mode”: only allow read/write/_exit/sigreturn current thread gives up all other privileges usage: setup pipes, then communicate with rest of process via pipes alternately: setting a whitelist of allowed system calls + arguments little programming language (!) for supported operations browsers use this to protect from bugs in their scripting implementations hope: fjnd a way to execute arbitrary code? — not actually useful 72

  68. sandbox browser setup create pipe spawn subprocess (“rendering engine”) put subproces in strict system call fjlter mode send subprocesses webpages + events subprocess sends images to render back on pipe 73

  69. aside: real/efgective/saved POSIX processes have three user IDs efgective — determines permission — geteuid() jo running sudo: geteuid = superuser’s ID real — the user who started the program — getuid() jo running sudo: getuid = jo’s ID saved set-user-ID — user ID from before last exec efgective user ID saved when a set-user-ID program starts jo running sudo: = jo’s ID no standard get function, but see Linux’s getresuid process can swap or set efgective UID with real/saved UID idea: become other user for one operation, then switch back 74

  70. aside: real/efgective/saved POSIX processes have three user IDs efgective — determines permission — geteuid() jo running sudo: geteuid = superuser’s ID real — the user who started the program — getuid() jo running sudo: getuid = jo’s ID saved set-user-ID — user ID from before last exec efgective user ID saved when a set-user-ID program starts jo running sudo: = jo’s ID no standard get function, but see Linux’s getresuid process can swap or set efgective UID with real/saved UID idea: become other user for one operation, then switch back 74

  71. why so many? two versions of Unix: System V — used efgective user ID + saved set-user-ID BSD — used efgective user ID + real user ID POSIX commitee solution: keep both 75

  72. aside: confusing setuid functions setuid — if root, change all uids; otherwise, only efgective uid seteuid — change efgective uid if not root, only to real or saved-set-user ID setreuid — change real+efgective; sometimes saved, too if not root, only to real or efgective or saved-set-user ID … more info: Chen et al, “Setuid Demystifjed” https://www.usenix.org/conference/ 11th-usenix-security-symposium/setuid-demystified 76

  73. also group-IDs processes also have a real/efgective/saved-set group-ID can also have set-group-ID executables same as set-user-ID, but only changes group 77

  74. sandboxing use case: buggy video decoder for (;;) { } displayImage(image); fread(image, sizeof (image), 1, fh); fwrite(getNextVideoData(), SIZE, 1, fh); } } doDangerousVideoDecoding(videoData, imageData); while (fread(videoData, sizeof (videoData), 1, stdin) > 0) { EnterSandbox(); int main() { 78 /* dangerous video decoder to isolate */ fwrite(imageData, sizeof (imageData), 1, stdout); /* code that uses it */ FILE *fh = RunProgramAndGetFileHandle("./video-decoder");

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend