Engineering Secure Software

Slides:



Advertisements
Similar presentations
Linux File & Folder permissions. File Permissions In Ubuntu, files and folders can be set up so that only specific users can view, modify, or run them.
Advertisements

Engineering Secure Software. Linux File Permissions  Each file and directory has bits for.. Read, Write, Execute: rwx Files: works as it sounds  Directories:
1 CSE 390a Lecture 4 Persistent shell settings; users/groups; permissions slides created by Marty Stepp, modified by Jessica Miller
1 CSE 303 Lecture 4 users/groups; permissions; intro to shell scripting read Linux Pocket Guide pp , 25-27, 61-65, , 176 slides created by.
File Security. Viewing Permissions ls –l Permission Values.
Linux+ Guide to Linux Certification, Second Edition
User Accounts and Permissions Chapter IV / Part II.
UNIX Chapter 08 File Security Mr. Mohammad Smirat.
Using Linux Commands Lab 4. Using the Shell in Linux Commands Syntax  Options: could be added to the commands to change their behavior (-a, -la, --help)
Getting Started with Linux Linux System Administration Permissions.
File System Security 1. General Principles Files and folders are managed by the operating system Applications, including shells, access files through.
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)
Linux+ Guide to Linux Certification, Second Edition
1Week 4 - Jan 31, 2005 Week 4 Agenda UNIX Directory Structure Absolute pathname Relative pathname Permissions chmod (symbolic/absolute)
Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted.
Module 4 - File Security. Security Overview File Ownership Access to Files and Dircetories Changing File and Directory Ownership Changing File and Directory.
File Permission and Access. Module 6 File Permission and Access ♦ Introduction Linux is a multi-user system where users can assign different access permission.
Lesson 9-Setting and Using Permissions. Overview Describing file permissions. Using execute permissions with a file. Changing file permissions using mnemonics.
File Security and Permissions. File Permissions (1) u With respect to a particular file, Unix divides the set of all users on a system into three categories:
Chapter 4: File Security & Permissions Also: Hard and Soft Links, see p77-80 &
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
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.
Privileges: who can control what Introduction to Unix May 24, 2008 Rabat, Morocco Hervey Allen.
Using Linux Commands Lab 4. Using the Shell in Linux Commands Syntax  Options: could be added to the commands to change their behavior (-a, -la, --help)
Chapter 8 File System Security. File Protection Schemes Login passwords Encryption File Access Privileges.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 5 File.
CSCI 330 The UNIX System Unit V Permissions. all access to directories and files is controlled UNIX uses discretionary access control (DAC) model each.
Chapter 8 File System Security. File Protection Schemes Password-Based Protection Encryption-Based Protection Protection-Based on Access Permission.
File System Security ls -l. First Columm d = directory l = symbolic link b = block special file c = character special file p = fifo (or named pipe) special.
Agenda The Linux File System (chapter 4 in text) Setting Access Permissions Directory vs File Permissions chmod Utility Symbolic Method Absolute Method.
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.
BIF703 File Permissions. As you recall from our previous notes, that Unix/Linux recognizes everything as a file: Regular files to store data, programs,
File System Security in Unix Annie Calpe. Overview Unix Basics File System Security: - Account Security: Passwords - File Permissions - Access Control.
Linux Filesystem Management
Privileges: who can control what
Permissions: who can control what Unix/IP Preparation Course July 19, 2009 Eugene, Oregon, USA
Agenda The Linux File System (chapter 4 in text)
File permissions Operating systems I800
Chapter 3 Maintaining Security
CS314 – Section 5 Recitation 1
Chapter 8 File Security.
BIF703 File Permissions.
UNIX Basics Internet Technology.
Privileges: who can control what
Using Linux Commands Lab 3.
Systems Administration CSCI Fall 2016
Permission and CHMOD.
Chapter 7 File and file System structure
Presented by, Mr. Satish Pise
Security and File Permission
Persistent shell settings; users/groups; permissions
Persistent shell settings; users/groups; permissions
The Linux Command Line Chapter 9
Persistent shell settings; users/groups; permissions
Persistent shell settings; users/groups; permissions
Persistent shell settings; users/groups; permissions
Agenda The Linux File System (chapter 4 in text)
Persistent shell settings; users/groups; permissions
Persistent shell settings; users/groups; permissions
Persistent shell settings; users/groups; permissions
In the last class,. ls –l command. seven fields
Engineering Secure Software
FILE SECURITY AND ACCESS CONTROL
Figure 6-13: Managing Permissions
In the last class, The concept of file system
BASIC FILE ATTRIBUTES.
Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
Presentation transcript:

Engineering Secure Software Linux Permissions

Linux File Permissions Each file and directory has bits for.. Read, Write, Execute: rwx Files: works as it sounds Directories: r  “can list files in a directory” (but not read a given file) w  “can create, change, delete files in directory” x  “cannot cd (change directory) to that directory” Thus, you may only read a file IFF you: Have read permissions to the file AND Have execute permissions to that file’s directory Files & Directories have 3 levels: Owner, Group, and Everyone Else aka. User, Group, Other: ugo

List permissions of a file: ls –l with some info removed from below in [...] drwxr-x--- […] pkm faculty […] . drwx------ […] pkm faculty […] .. -rwxrwxrwx […] pkm faculty […] allopen drwx------ […] pkm faculty […] mydir -rw------- […] pkm faculty […] myfile -rwx------ […] pkm faculty […] myprog drwxrwx--- […] pkm faculty […] ourdir -rwxrwx--- […] andy faculty […] ourprog Can andy execute myprog? No, because of file permissions. Can both pkm and andy execute ourprog? Yes. Everyone in faculty can read and execute ourprog Can andy read ourprog? Yes. Directory has group x, file has group r Can andy change directory (cd) to mydir? No. The directory’s execute permission is off.

chmod Command to change permissions Octal notation Set (=), Add (+), Remove (-) Set user to rw, not x: chmod u=rw . Set user, groups to only rw: chmod ug=rw . Set ug to only rx, recursively: chmod –R ug=rx . Add “groups can rw”: chmod g+rw . Add “others can rw”: chmod o+rw . Add “everyone can read”: chmod a+r . Remove write from group: chmod g-w . Octal notation e.g. chmod 755 file.txt Good for setting, not adding/removing 1,2,3 are never used rwx --- --x -w- -wx r-- r-x rw- Binary 000 001 010 011 100 101 110 111 Decimal 1 2 3 4 5 6 7

umask When a file is created… Programs can change their own umask User mask (umask) is consulted for permissions Owner = user who created the file The resulting default permission C = (P & ~Q), where Q is the mask, and P is 666 for files and 777 for directories e.g., if mask is 077, a file’s permission, C = 666 & ~(077) = 600 = rw------- Or, subtract octally, “digit by digit” (tricky when the mask has a 7 in it) from 666 for files or 777 for directories e.g. , if mask is 022, a directory’s permission, C = 777-022=755, or rwxr-xr-x nitron.se.rit.edu default: rw------- (or 077) Common default: rw-r--r– (or 022) Common umask shared group stuff: rw-rw--– (or 007) Programs can change their own umask Blessing for good developers but curse for system administrators

Executing as users When executing, ordinarily… OS ignores the owner of the program file Runs the program as you (assuming you have permissions, of course) e.g. prog.sh owned by root gets run as you This allows for root to have files that cannot be modified, but executed e.g. passwd (change the password) should not be tampered with sudo: execute this program as root user (“superuser do”) e.g. sudo /etc/init.d/apache2 start su: change the current user to someone else

setuid, setgid setuid and setgid bits on files chmod ug+s ./prog.sh “Execute as the owner’s rights, not as the executing user’s rights” (assuming you have permissions to execute it) Files owned by root with setuid are highly risky Arbitrary code execution vulnerability? Executing as root. App developers should almost never use this OS commands have a lot of these (e.g. passwd is owned root with setuid) Repudiation becomes a major threat with setuid and setgid setuid and setgid bits on directories setuid on directories is ignored in Linux setgid means new files inherit the group ID Sticky bit Only a file’s owner, the owner of the file’s directory, or root can delete the file

For Example larry$ umask 077 larry$ mkdir dir larry$ ls –l dir/ drwx------ … larry stooges … dir larry$ touch dir/file.sh larry$ ls –la dir/ -rwx------ … larry stooges … .  ./dir -rwx------ … larry stooges … ..  ./dir/.. -rw------- … larry stooges … file.sh larry$ ./dir/file.sh bash: ./dir/file.sh: Permission denied larry$ chmod –R ug+x . curly$ ./dir/file.sh [Success!] curly$ ls –l ./dir bash: ./dir/: Permission denied

Beware of sudo He sees you when you're sleeping, he knows when you're awake, he's copied on /var/spool/mail/root, so be good for goodness' sake. Source: http://xkcd.com/838