Computer Science CSC 405 LabBy Yuzheng Zhou1 CSC 405 Introduction to Computer Security Lab session.

Slides:



Advertisements
Similar presentations
Linux Users and Groups Management
Advertisements

1 Introduction to UNIX Ke Liu
1 The Attack and Defense of Computers Dr. 許 富 皓. 2 Passwords in Unix/Linux Systems.
Unix Security Issues Process Creation/Space Users and Groups File Permissions Relationship of Program and File Security.
Operating Systems Recitation 11, June 9-10, 2002.
Unix Systems Administration 1Y. K. Chang root: the super user 4 The UNIX semigod who can perform privileged tasks: controlling processes, adding devices,
UNIX Chapter 08 File Security Mr. Mohammad Smirat.
Getting Started with Linux Linux System Administration Permissions.
Linux Security.
File System Security 1. General Principles Files and folders are managed by the operating system Applications, including shells, access files through.
O.S security Ge Zhang Karlstad University. Outline Why O.S. security is important? Security schemes in Unix/Linux system Security schemes in windows system.
Help session: Unix basics Keith 9/9/2011. Login in Unix lab  User name: ug0xx Password: ece321 (initial)  The password will not be displayed on the.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
Managing User Accounts. Module 2 – Creating and Managing Users ♦ Overview ► One should log into a Linux system with a valid user name and password granted.
Chapter 5 Bourne Shells Scripts By C. Shing ITEC Dept Radford University.
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT File Security.
File Permissions. What are the three categories of users that apply to file permissions? Owner (or user) Group All others (public, world, others)
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.
File Permission and Access. Module 6 File Permission and Access ♦ Introduction Linux is a multi-user system where users can assign different access permission.
Shell Programming Any command or a sequence of UNIX commands stored in a text file is called a shell program. It is common to call this file a command.
ITI-481: Unix Administration Meeting 3 Christopher Uriarte, Instructor Rutgers University Center for Applied Computing Technologies.
Lesson 9-Setting and Using Permissions. Overview Describing file permissions. Using execute permissions with a file. Changing file permissions using mnemonics.
Users Greg Porter V1.0, 26 Jan 09. What is a user? Users “own” files and directories Permission based on “ownership” Every user has a User ID (UID) 
Managing Users  Each system has two kinds of users:  Superuser (root)  Regular user  Each user has his own username, password, and permissions that.
Hands On UNIX II Dorcas Muthoni. Processes A running instance of a program is called a "process" Identified by a numeric process id (pid)‏  unique while.
Chapter 3 & 6 Root Status and users File Ownership Every file has a owner and group –These give read,write, and execute priv’s to the owner, group, and.
Linux Security. Authors:- Advanced Linux Programming by Mark Mitchell, Jeffrey Oldham, and Alex Samuel, of CodeSourcery LLC published by New Riders Publishing.
Lecture 14 Page 1 CS 236 Online Race Conditions A common cause of security bugs Usually involve multiprogramming or multithreaded programs Caused by different.
1 LINUX SECURITY. 2 Outline Introduction Introduction - UNIX file permission - UNIX file permission - SUID / SGID - SUID / SGID - File attributes - File.
PacNOG 6: Nadi, Fiji UNIX ™/ /Linux Permissions Hervey Allen Network Startup Resource Center.
Privileges: who can control what Introduction to Unix June 16, 2009 Papeete, French Polynesia Hervey Allen.
What is a Process? u A process is an executable “cradle” in which a program may run u This “cradle” provides an environment in which the program can run,
Privileges: who can control what Introduction to Unix May 24, 2008 Rabat, Morocco Hervey Allen.
Chapter 8 File System Security. File Protection Schemes Login passwords Encryption File Access Privileges.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
SCSC 455 Computer Security Chapter 3 User Security.
Chapter 8 File System Security. File Protection Schemes Password-Based Protection Encryption-Based Protection Protection-Based on Access Permission.
UNIX File System By Vishal Desai. Introduction Basic purpose of file system: Represent and organize the system resources. But UNIX File System also maps.
Module 1 - Introduction to Linux. Users must log-in Linux is case sensitive File and Directories naming conventions (No spaces!) Files and Directories.
CSC414 “Introduction to UNIX/ Linux” Lecture 6. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
Jozef Goetz, expanded by Jozef Goetz, 2008 Credits: Parts of the slides are based on slides created by UNIX textbook authors, Syed M. Sarwar, Robert.
Access Control. Many models Traditional Unix model Windows model Role-based access control (SE Linux)‏ Access control for confidentiality (Bell-La Padula.
Karlstad University Operating System security Ge Zhang Karlstad University.
1 COMP 3500 Introduction to Operating Systems Project 4 – Processes and System Calls Overview Dr. Xiao Qin Auburn University
Company LOGO Security in Linux PhiHDN - VuongNQ. Contents Introduction 1 Fundamental Concepts 2 Security System Calls in Linux 3 Implementation of Security.
Privileges: who can control what
Permissions: who can control what Unix/IP Preparation Course July 19, 2009 Eugene, Oregon, USA
...looking a bit closer under the hood
Let’s look at an example
Development Environment Basics
Module X (Unix/Linux Password Security)
...looking a bit closer under the hood
System Programming and administration CS 308
Hands On UNIX AfNOG 2010 Kigali, Rwanda
Chapter 8 File Security.
Hands On UNIX AfNOG X Cairo, Egypt
Privileges: who can control what
Introduction to UNIX.
...looking a bit closer under the hood
Presented by, Mr. Satish Pise
Engineering Secure Software
The Attack and Defense of Computers
Rootly Powers Chapter 3.
Chapter 5 Bourne Shells Scripts
Environment Variables & Attacks
Set-UID Privileged Programs
Return-to-libc Attacks
Race Condition Vulnerability
Presentation transcript:

Computer Science CSC 405 LabBy Yuzheng Zhou1 CSC 405 Introduction to Computer Security Lab session

Computer Science CSC 405 LabBy Yuzheng Zhou2 Roadmap Lab 2 Set-UID –Why do we need set-uid program? (prob. 1) –Set-uid program –How is set-uid implemented in Minix (prob. 2) –When we run set-uid in Minix and Linux, why do we get different results ? (prob. 3 & 5) –Set-uid vulnerability: PATH environment variable (prob. 4) –Use setuid() carefully (Prob. 6) Lab 3 Set-RandomUID grading policy

Computer Science CSC 405 LabBy Yuzheng Zhou3 passwd, chsh, su passwd –Allow users to change their passwords –Users’ passwords are stored in /etc/shadow, which is neither readable nor writable to normal su –Allows user to become the super-user –User must pass super-user’s password as an argument. chsh –Allow users to change their login shells –Users’ login shell are stored in /etc/passwd, which is neither readable nor writable to normal

Computer Science CSC 405 LabBy Yuzheng Zhou4 passwd, chsh, su (Cont’d) passwd, chsh, su –Runnable by anybody –Need to access files (etc/shadow, etc/passwd) which are neither readable nor writable to normal user –How to achieve the goal? Need to be set-root-UID programs

Computer Science CSC 405 LabBy Yuzheng Zhou5 Set-UID Programs real user ID (real uid, or ruid): –identifies the owner of the process effective user ID (effective uid, or euid) –used in most access control decisions Set-UID program –at login time, real uid = effective uid = user login ID –when a Set-UID program is executed, real uid doesn’t change effective uid  owner of the set-uid program –Access control is based on effective uid

Computer Science CSC 405 LabBy Yuzheng Zhou6 How to turn on Set-UID bit The meaning of the permission bits in Unix. 9 normal bits: 755 : => -rwxr-xr-x –Owner (u), Group (g), and Others (o). –Readable (r), Writable (w), and Executable (x). 3 special bits (sticky key hasn’t been used): –bit 11: set UID; bit 10: set Group ID; bit 9: sticky key. Turn on the Set-UID bit –chmod 4755 [set bit 11]: => -rwSr-xr-x ^ the eXecute "x" is replaced by an "s"

Computer Science CSC 405 LabBy Yuzheng Zhou7 How is Set-UID implemented in Minix? Fproc structure /* Defined in /usr/src/fs/prot.h, this is the per-process information */ EXTERN struct fproc { …… uid_t fp_realuid; /* real user id */ uid_t fp_effuid; /* effective user id */ gid_t fp_realgid; /* real group id */ gid_t fp_effgid; /* effective group id */ Read source code for details –do_exec routine in /usr/src/mm/exec.c –forbidden routine in /usr/src/fs/protect.c

Computer Science CSC 405 LabBy Yuzheng Zhou8 Run Set-UID Programs In Minix Login as root. % cp /bin/sh /tmp/ % chmod 4755 /tmp/sh % exit Login as yuzheng (normal user) $ /tmp/sh $ id $ uid=10 (yuzheng) gid=3(other) euid=0(root) suid=10(yuzheng) $ vi /etc/passwd (can open it !!!)

Computer Science CSC 405 LabBy Yuzheng Zhou9 Run Set-UID Programs (cont.) But in Fedora 5 (No change!!!) $ uid=501 (yuzheng) gid=501(yuzheng) groups=501(yuzheng) Why? –In Fedora 5, /bin/sh (actually bash) ignores the Set-UID bit option. –Check shell.c in bash-*.tar.gz ( –The following code in bash drops the Set-UID bit if (running_setuid && privileged_mode == 0) disable_priv_mode (); …… void disable_priv_mode () { setuid (current_user.uid); setgid (current_user.gid); current_user.euid = current_user.uid; current_user.egid = current_user.gid;

Computer Science CSC 405 LabBy Yuzheng Zhou10 PATH Environment Variable system("ls") invoke the /bin/sh program, and then let the shell program to execute ls. the shell searches for ls using the PATH environment variable. The attacker can change PATH and cause ls in the current directory to be executed. $ export PATH =.:$PATH Do you get root privilege? In Minix: yes; In Fedora: No

Computer Science CSC 405 LabBy Yuzheng Zhou11 system() and execve() System() invokes /bin/sh first. –In Fedora, it execv /bin/sh with arguments"sh", "-c" and the user provided string. In Fedora 5, /bin/sh (actually bash) ignores the Set- UID bit option. –Why system() is more secure than execve in Linux –So, for problem 5 (a), we get “permission denied” message in Linux. Want to read source code ? –download glibc-*.tar.gz from –search system and execve

Computer Science CSC 405 LabBy Yuzheng Zhou12 Use setuid() carefully void main() { ….. /* check access permission here */ fd = open("/etc/zzz", O_RDWR | O_APPEND); setuid(500); if (fork()) { /* In the parent process */ ….. } else { /* in the child process */ /* The child process inherit opened file from its parent, and Linux will not check access permission again */ write (fd, "Malicious Data", 14); close (fd); }

Computer Science CSC 405 LabBy Yuzheng Zhou13 Lab3 Set-RandomUID Grading (I) Project Design (40 pts, due by Nov. 20) –Idea: your design idea, how you implement the system (15pts) Introduction of the project (what can your program do) (2 points) How do you design your program? (Show us the program modules) (8 points) Why does your program work? (5 points) –Knowledge: your understanding of each functions, components (15pts) List and explain all the related functions and files. (5 points) Comment all the related functions and files to let us understand your program. (bonus: 5 points) You need to attach your code, but you can still change and debug your code until the demo. Answer question 3 (5 points) Answer question 4 (5 points)

Computer Science CSC 405 LabBy Yuzheng Zhou14 Lab3 Set-RandomUID Grading (II) –Skill: your communication skills to convince us to buy it (10pts) Does our system more secure by using your program? Why or why not? (5 points) Any other reasons we will buy your program, Ex. is your program easy to install to current system? (5 points). Project Demo (1 or 2 days during Nov.27-30) –Check TA’s faq page around Nov. 20. –Everyone has minutes –Show your own test case –Run TA’s test case –Be ready for the questions about the project design and implementation. Bonus (submit online, due by Nov.26) –Award up to 50 bonus points to the identified loopholes, 10 points for each.