1 Setuid Demystified Hao Chen David Wagner UC Berkeley Drew Dean SRI International Proceedings of the 11th USENIX Security Symposium San Francisco, California,

Slides:



Advertisements
Similar presentations
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Advertisements

P5, M1, D1.
Using Programmer-Written Compiler Extensions to Catch Security Holes Authors: Ken Ashcraft and Dawson Engler Presented by : Hong Chen CS590F 2/7/2007.
API Design CPSC 315 – Programming Studio Fall 2008 Follows Kernighan and Pike, The Practice of Programming and Joshua Bloch’s Library-Centric Software.
CS5261 Information Security CS 526 Topic 8: Operating Systems Security Basics & Unix Access Control Topic 8: Operating System Security Basics.
CS252: Systems Programming Ninghui Li Based on Slides by Prof. Gustavo Rodriguez-Rivera Topic 17: Signals, Process Credentials.
Chapter 6: Design of Expert Systems
© 2003 School of Computing, University of Leeds SY32 Secure Computing, Lecture 15 Implementation Flaws Part 3: Randomness and Timing Issues.
1 Property 3: standard file descriptors vulnerability attack.c at.c Standard File Descriptors 0:stdin 1:stdout 2:stderr close(1); close(2); execl(“at”,
Setuid Demystified (and how it may relate to stored procedure authorizations) Mahesh.
MOPS MOdelchecking Security Properties David Wagner U.C. Berkeley.
Software Security David Wagner University of California at Berkeley.
SE 555 Software Requirements & Specification Requirements Validation.
1 Model Checking One Million Lines of C Code Hao Chen Drew Dean (SRI International) David Wagner with David Schultz, Geoff Morrison, Ben Schwarz Jacob.
1 setuid Demystified -- Examining the API of Security Operation in OS using Formal Models Hao Chen, David Wagner UC Berkeley Drew Dean SRI International.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
Formal verification Marco A. Peña Universitat Politècnica de Catalunya.
C. Edward Chow Presented by Mousa Alhazzazi C. Edward Chow Presented by Mousa Alhazzazi Design Principles for Secure.
CMSC 414 Computer and Network Security Lecture 18 Jonathan Katz.
The Impact of Programming Language Theory on Computer Security Drew Dean Computer Science Laboratory SRI International.
Lecture 18 Page 1 CS 111 Online Design Principles for Secure Systems Economy Complete mediation Open design Separation of privileges Least privilege Least.
1 Setuid Demystified Hao Chen David Wagner UC Berkeley Drew Dean SRI International.
VM Algorithm Improvement Student’s Name: Kamlesh Patel Date: Oct 13, 2008 Advisor’s Name: Dr. Chung-E-Wang Prof. Dick Smith Department of Computer Science.
Let’s look at an example I want to write an application that reports the course scores to you. Requirements: –Every student can only get his/her score.
1 Security Chapter The security environment 9.2 Basics of cryptography 9.3 User authentication 9.4 Attacks from inside the system 9.5 Attacks from.
Announcements Assignment 3 due. Invite friends, co-workers to your presentations. Course evaluations on Friday.
August 18, 2005 Jim Nindel-Edwards How Early, Proactive Test Planning Contributes to Project Success Based on a paper to be presented at the International.
CS426Fall 2010/Lecture 91 Computer Security CS 426 Lecture 9 Unix Access Control.
Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M th November, 2008.
Continuous Backup for Business CrashPlan PRO offers a paradigm of backup that includes a single solution for on-site and off-site backups that is more.
CE Operating Systems Lecture 21 Operating Systems Protection with examples from Linux & Windows.
Writing Systems Software in a Functional Language An Experience Report Iavor Diatchki, Thomas Hallgren, Mark Jones, Rebekah Leslie, Andrew Tolmach.
Linux Security. Authors:- Advanced Linux Programming by Mark Mitchell, Jeffrey Oldham, and Alex Samuel, of CodeSourcery LLC published by New Riders Publishing.
1 Test Selection for Result Inspection via Mining Predicate Rules Wujie Zheng
UNIX System Protection. Unix History Developed by Dennis Ritchie and Ken Thompson at AT&T Bell Labs Adapted some ideas from the Multics project in 1969.
Chapter 4 – Threads (Pgs 153 – 174). Threads  A "Basic Unit of CPU Utilization"  A technique that assists in performing parallel computation by setting.
Lecture 18 Page 1 CS 111 Online OS Use of Access Control Operating systems often use both ACLs and capabilities – Sometimes for the same resource E.g.,
A Tool for Pro-active Defense Against the Buffer Overrun Attack D. Bruschi, E. Rosti, R. Banfi Presented By: Warshavsky Alex.
HACNet Simulation-based Validation of Security Protocols Vinay Venkataraghavan Advisors: S.Nair, P.-M. Seidel HACNet Lab Computer Science and Engineering.
Basic UNIX Concepts. Why We Need an Operating System (OS) OS interacts with hardware and manages programs. A safe environment for programs to run is required.
Speaker: Xiaojiang Du Authors: Xiali Hei, Xiaojiang Du and Shan Lin Temple University.
Android Permissions Demystified
Information Security CS 526
1 The Requirements Problem Chapter 1. 2 Standish Group Research Research paper at:  php (1994)
Privilege Escalation Two case studies. Privilege Escalation To better understand how privilege escalation can work, we will look at two relatively recent.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Race conditions and synchronization issues Exploiting UNIX.
1 Model Checking One Million Lines of C Code Hao Chen, UC Berkeley Drew Dean, SRI International David Wagner, UC Berkeley.
Lecture9 Page 1 CS 236 Online Operating System Security, Con’t CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
MOPS: an Infrastructure for Examining Security Properties of Software Authors Hao Chen and David Wagner Appears in ACM Conference on Computer and Communications.
Secure System Development Mechanisms CS460 Cyber Security Lab Spring 2010.
Company LOGO Security in Linux PhiHDN - VuongNQ. Contents Introduction 1 Fundamental Concepts 2 Security System Calls in Linux 3 Implementation of Security.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
Antonio Hansford ITEC 400 Berkeley Software Design April 14, 2016.
Jeremy Nimmer, page 1 Automatic Generation of Program Specifications Jeremy Nimmer MIT Lab for Computer Science Joint work with.
Computer System Structures
Let’s look at an example
CS703 - Advanced Operating Systems
SYSTEM ADMINISTRATION PART I by İlker Korkmaz and Kaya Oğuz
Generating Automated Tests from Behavior Models
Chapter 8 – Software Testing
LEVEL OF TESTING J.ALFRED DANIEL, AP/CSE.
Chapter 2: System Structures
Verification of Software Security Properties
UNIX System Protection
All You Ever Wanted to Know About Dynamic Taint Analysis & Forward Symbolic Execution (but might have been afraid to ask) Edward J. Schwartz, Thanassis.
MOPS: an Infrastructure for Examining Security Properties of Software
Set-UID Privileged Programs
Race Condition Vulnerability
Presentation transcript:

1 Setuid Demystified Hao Chen David Wagner UC Berkeley Drew Dean SRI International Proceedings of the 11th USENIX Security Symposium San Francisco, California, USA August 5-9, 2002

2 Outline Identified problems of SETUID –What is SETUID –SETUID mystery and problems Provided solution –Use a formal model –Build the model automatically by state space exploration Demonstrated Applications of FSA –Understanding semantics of security operation API precisely –Verifying Documentation –Detecting Inconsistency in OS kernels –Checking Proper use of API calls in programs Proposed guidelines

3 What is setuid Access control in Unix is based the User ID model Each process has 3 user Ids: –Real uid (ruid) –Effective uid (euid) –Saved uid (suid) Uid-setting system calls –setuid() seteuid() setreuid() setresuid()

4 Historical Artifacts Early Unix Two user IDs: ruid and euid. Only one system call : setuid Rules: System V Three user IDs: ruid, euid and suid Two system call: setuid and seteuid Rules: BSD Three user IDs: ruid, euid and suid System call: setuid, seteuid, and setreuid Rules: Modern Unix Three user IDs: ruid, euid and suid System call: setuid, seteuid, setreuid and setresuid Rules: Different system had different semantics !!!

5 The Problems Semantic mess –Design: confusing, surprising –Portability: semantic differences among OSs (e.g. Linux, Solaris, FreeBSD) –Documentation: incomplete, inaccurate, or incorrect

6 Objective Understanding the semantics of security operation API in OS precisely Verifying their documentations Detecting inconsistency in OS kernels Building security properties and checking them in programs automatically

7 Formal Model of the Setuid API Finite State Automaton (FSA) model –States: describing the user IDs of a process –Transitions: describing the semantics of the setuid API calls ruid=1 euid=0 suid=0 ruid=1 euid=1 suid=1 ruid=1 euid=1 suid=0 setuid(1) seteuid(1) seteuid(0) Abstraction 0: root uid 1: a non-root uid

8 Construct the FSA Challenge –Large number of transitions –Manual construction is laborious, error-prone Solution –Automatic construction by a state space explorer: Exhaustively makes all setuid API calls at each state of the FSA Observes the resulting transitions

9 Determine Transitions Automatically by Simulation Idea: Exhaustively make all system calls at each state For each state s=(ruid, euid, suid) where ruid, euid, suid  {0, uid 1, uid 2, …} For each system call c  {setuid(e), seteuid(e), setreuid(r,e), setresuid(r,e,s)} { Make the system call c in the state s Observe the ensuing state s’ Add the transition }

10 Linux FreeBSD FSAs for setuid transitions

11 FSA for setresuid in Linux

12 Benefits of Using Formal Model Correctness –Intuition: the transitions in the FSA are observed from running programs Efficiency –The FSA is constructed automatically by the explorer Portability: the explorer is portable to –Different Unix systems –Different versions of kernels Lots of applications!

13 Applications : Find Documentation Errors Incomplete man page –setuid(2) in Redhat Linux 7.2: fails to mention the Linux capabilities which affect how setuid() behaves Wrong man pages –FreeBSD 4.4 Unprivileged users may change the ruid to the euid and vice versa –Redhat Linux 7.2 The setgid function checks the egid of the caller and if it is the superuser, … suid euid

14 Applications : Detect Inconsistencies in OS Kernel File system uid (fsuid) in Linux –Is used for filesystem permission checking –Normally follows euid An invariant in Linux ( kernel/sys.c ) –fsuid is 0 only if at least one of ruid, euid, suid is 0 Security motivation –Root privilege in fsuid is automatically dropped when it is dropped from ruid, euid, suid –Ensures that an fsuid-unware application can safely drop root privilege in fsuid

15 Applications : Detect Inconsistencies in OS Kernel (contd.) A bug in Linux kernels <= breaks the invariant –The invariant is satisfied in setuid(), seteuid(), setreuid() –But it is broken in setresuid() – fsuid = 0 and ruid != 0, euid != 0, suid != 0 is reachable (figure2) The bug has been confirmed by Linux community

16 Check Proper Usage of the Setuid API in Programs Questions –Can a setuid API call fail in this program? –Can this program fail to drop privilege? –Which part of this program run with privilege? Approach –Model checking security properties in programs using the FSA of the setuid API Results –Found known setuid bugs in sendmail and

17 A Vulnerability in Sendmail Due to A Misuse of setuid.

18 General Guidelines (1) Selecting an Appropriate System Call setresuid has a clear semantics and is able to set each user ID individually, it should always be used if available. Otherwise, to set only the effective uid, seteuid(new euid) should be used; to set all three user IDs, setreuid(new uid, new uid) should be used. setuid should be avoided because its overloaded semantics and inconsistent implementation in different Unix systems may cause confusion and security vulnerabilities for the unwary programmer.

19 General Guidelines (2) Obey the proper order of API calls –Drop group privileges before user privileges

20 General Guidelines (3) Verifying Proper Execution of System Calls Checking Return Codes Verifying User IDs Verifying Failures

21 An Improved API for Privilege Management – The API contains three functions: Drop_priv_temp(new uid): Drop privilege temporarily. Move the privileged user ID from the effective uid to the saved uid. Assign new uid to the effective uid. Drop_priv_perm(new uid): Drop privilege permanently. Restore_priv: Restore privilege. –Beneficial properties It does not affect the real uid. It guarantees that all transitions in Figure 13 succeed. It verifies that the user IDs are as expected after each uid-setting system call.

22 Conclusion Identified the precise semantics –Use an FSA model –Built the model automatically by state space exploration Formal models revealed pitfalls and bugs –Discovered semantic pitfalls –Found new documentation errors –Detected the fsuid bug in the Linux kernel –Verified the proper use of setuid API in some programs ( sendmail and ) Proposed guidelines for the setuid API