Deian Stefan
Slides adopted from John Mitchell, Dan Boneh, and Stefan Savage
Least privilege and privilege separation Deian Stefan Slides - - PowerPoint PPT Presentation
CSE 127: Computer Security Least privilege and privilege separation Deian Stefan Slides adopted from John Mitchell, Dan Boneh, and Stefan Savage This week How to build secure systems Least privilege and privilege separation
Slides adopted from John Mitchell, Dan Boneh, and Stefan Savage
➤ Least privilege and privilege separation ➤ Sandboxing and isolation
➤ We’re going to look at systems techniques ➤ Other ways to achieve similar goals: language-based
➤ Use more than one security mechanism ➤ Fail securely/closed
➤ Use more than one security mechanism ➤ Fail securely/closed
➤ Ability to access (e.g., read or write) a resource
➤ Ability to access (e.g., read or write) a resource
➤ Ability to access (e.g., read or write) a resource
Network User input File system Network User device File system
➤ Separate the system into isolated compartments ➤ Limit interaction between compartments
Network User input File system Network User device File system
➤ A process may access files, network sockets, ….
➤ Grants permissions to users according to UIDs and
➤ Everything is a file!
➤ same as the user ID of parent (unless changed) ➤ used to determine which user started the process
➤ from setuid bit on the file being executed, or syscall ➤ determines the permissions for process
➤ Used to save and restore EUID
➤ same as the user ID of parent (unless changed) ➤ used to determine which user started the process
➤ from setuid bit on the file being executed, or syscall ➤ determines the permissions for process
➤ Used to save and restore EUID
➤ same as the user ID of parent (unless changed) ➤ used to determine which user started the process
➤ from setuid bit on the file being executed, or syscall ➤ determines the permissions for process
➤ Used to save and restore EUID
➤ same as the user ID of parent (unless changed) ➤ used to determine which user started the process
➤ from setuid bit on the file being executed, or syscall ➤ determines the permissions for process
➤ Used to save and restore EUID
➤ ID=0 for superuser root; can access any file
➤ Inherit three IDs, except exec of file with setuid bit
➤ seteuid(newid) can set EUID to
➤ Real ID or saved ID, regardless of current EUID ➤ Any ID, if EUID is root
➤ ID=0 for superuser root; can access any file
➤ Inherit three IDs, except exec of file with setuid bit
➤ seteuid(newid) can set EUID to
➤ Real ID or saved ID, regardless of current EUID ➤ Any ID, if EUID is root
➤ ID=0 for superuser root; can access any file
➤ Inherit three IDs, except exec of file with setuid bit
➤ seteuid(newid) can set EUID to
➤ Real ID or saved ID, regardless of current EUID ➤ Any ID, if EUID is root
➤ setuid - set EUID of process to ID of file owner ➤ setgid - set EGID of process to GID of file ➤ sticky bit
➤ on: only file owner, directory owner, and root can
➤ off: if user has write permission on directory, can
➤ setuid - set EUID of process to ID of file owner ➤ setgid - set EGID of process to GID of file ➤ sticky bit
➤ on: only file owner, directory owner, and root can
➤ off: if user has write permission on directory, can
drwxrwxrwt 16 root root 700 Feb 6 17:38 /tmp/
…; …; exec( ); RUID 25 SetUID program …; …; i=getruid() setuid(i); …; …;
RUID 25 EUID 18 RUID 25 EUID 25
file
file Owner 18 Owner 25
read/write read/write
Owner 18
…; …; exec( ); RUID 25 SetUID program …; …; i=getruid() setuid(i); …; …;
RUID 25 EUID 18 RUID 25 EUID 25
file
file Owner 18 Owner 25
read/write read/write
Owner 18
➤ Receive and send email over external network ➤ Place incoming email into local user inbox files
➤ Monolithic design ➤ Historical source of many vulnerabilities
➤ Compartmentalized design
➤ Separate modules run as separate “users” ➤ Each user only has access to specific resources
➤ Minimal privileges for each UID ➤ Only one “setuid” program ➤ Only one “root” program
qmail-smtpd qmail-local qmail-remote qmail-lspawn qmail-rspawn qmail-send qmail-inject qmail-queue
Incoming external mail Incoming internal mail
qmail-smtpd qmail-local qmail-remote qmail-lspawn qmail-rspawn qmail-send qmail-inject qmail-queue
Incoming external mail Incoming internal mail setuid
qmail-smtpd qmail-local qmail-remote qmail-lspawn qmail-rspawn qmail-send qmail-inject qmail-queue
Incoming external mail Incoming internal mail setuid root
qmail-smtpd qmail-local qmail-remote qmail-lspawn qmail-rspawn qmail-send qmail-inject qmail-queue qmaild user qmailq qmails qmailr qmailr root user setuid user
qmail-smtpd qmail-local qmail-remote qmail-lspawn qmail-rspawn qmail-send qmail-inject qmail-queue qmaild user qmailq qmails qmailr qmailr root user setuid user
Reads incoming mail directories Splits message into header, body Signals qmail-send
qmail-smtpd qmail-local qmail-remote qmail-lspawn qmail-rspawn qmail-send qmail-inject qmail-queue qmaild user qmailq qmails qmailr qmailr root user setuid user
qmail-send signals
qmail-smtpd qmail-local qmail-remote qmail-lspawn qmail-rspawn qmail-send qmail-inject qmail-queue qmaild user qmailq qmails qmailr qmailr root user setuid user
qmail-lspawn
qmail-smtpd qmail-local qmail-remote qmail-lspawn qmail-rspawn qmail-send qmail-inject qmail-queue qmaild user qmailq qmails qmailr qmailr root user setuid user
qmail-local
qmail-smtpd qmail-local qmail-remote qmail-lspawn qmail-rspawn qmail-send qmail-inject qmail-queue qmaild user qmailq qmails qmailr qmailr root user setuid user
qmail-remote
➤ Provides memory protection ➤ Communication limited to using UNIX domain
➤ Only ping and zygote run as root
➤ User grants access at install time + runtime
➤ Each service run in a chroot jail, restricted to ➤ Communication limited to structured RPC between
➤ Each UID is unique non privileged user ➤ Only okld (launcher daemon) runs as root
➤ Has access control policies similar to an OS
➤ Use least privilege to keep the browser code secure
Operating system
– Has User ID (UID, SID) – Discretionary access control
– File – Network – …
– Untrusted programs – Buffer overflow – …
Web browser
– Has “Origin” – Mandatory access control
– Document object model – Frames – Cookies / localStorage
– Cross-site scripting – Implementation bugs – …
➤ Full privileges (file system, networking)
➤ Can have multiple processes ➤ Sandboxed
➤ Full privileges of browser
➤ Restrict code from reading the filesystem, talking to
➤ seccomp - “secure computing mode”: no sys calls
➤ seccomp-bpf - syscall firewall filtering