System Security Fundamentals



Similar documents
CIS 551 / TCOM 401 Computer and Network Security. Spring 2005 Lecture 4

CSE331: Introduction to Networks and Security. Lecture 34 Fall 2006

CIS 551 / TCOM 401 Computer and Network Security

Capability-Based Access Control

Programmation Systèmes Cours 4 Runtime user management

1. Introduction to the UNIX File System: logical vision

TEL2821/IS2150: INTRODUCTION TO SECURITY Lab: Operating Systems and Access Control

Chapter 7: Unix Security. Chapter 7: 1

Using Network Attached Storage with Linux. by Andy Pepperdine

Basic Unix/Linux 1. Software Testing Interview Prep

1 Posix API vs Windows API

Allion Ingrasys Europe. NAStorage. Security policy under a UNIX/LINUX environment. Version 2.01

Sophos Anti-Virus for Linux user manual

Unit objectives IBM Power Systems

CEN 559 Selected Topics in Computer Engineering. Dr. Mostafa H. Dahshan KSU CCIS

Set-UID Privileged Programs

This presentation will discuss how to troubleshoot different types of project creation issues with Information Server DataStage version 8.

CSI 402 Lecture 13 (Unix Process Related System Calls) 13 1 / 17

Filesystem Security. General Principles

NAStorage. Administrator Guide. Security Policy Of NAStorage Under UNIX/LINUX Environment

Using LDAP Authentication in a PowerCenter Domain

Access Control and Audit Trail Software

Case Study: Access control 1 / 39

Secure Shell Demon setup under Windows XP / Windows Server 2003

Example of Standard API

Introduction to Linux (Authentication Systems, User Accounts, LDAP and NIS) Süha TUNA Res. Assist.

Practical Mac OS X Insecurity. Security Concepts, Problems and Exploits on your Mac

Case Studies. Joint software development Mail 1 / 38. Case Studies Joint Software Development. Mailers

SAS 9.4 Intelligence Platform

Scheduling in SAS 9.3

Scheduling in SAS 9.4 Second Edition

EMC Celerra Network Server

Plan 9 Authentication in Linux

TELE 301 Lecture 7: Linux/Unix file

SSL Tunnels. Introduction

Application Security Policy

Sophos Anti-Virus for Linux configuration guide. Product version: 9

CIS433/533 - Computer and Network Security Operating System Security

IBM Campaign and IBM Silverpop Engage Version 1 Release 2 August 31, Integration Guide IBM

User Migration Tool. Note. Staging Guide for Cisco Unified ICM/Contact Center Enterprise & Hosted Release 9.0(1) 1

Backing Up and Restoring Data

PATROL Console Server and RTserver Getting Started

Unix Scripts and Job Scheduling

Job Reference Guide. SLAMD Distributed Load Generation Engine. Version 1.8.2

RECOVER ( 8 ) Maintenance Procedures RECOVER ( 8 )

Sophos Anti-Virus for Linux configuration guide. Product version: 9

Linux Driver Devices. Why, When, Which, How?

As a CIFEX user, we suggest you have a look at Use Cases. As a CIFEX administrator, we suggest you have at least a look at

SMTP-32 Library. Simple Mail Transfer Protocol Dynamic Link Library for Microsoft Windows. Version 5.2

CS 103 Lab Linux and Virtual Machines

Security in Android apps

IBM Campaign Version-independent Integration with IBM Engage Version 1 Release 3 April 8, Integration Guide IBM

Tab 3: STEM Alignment * Identifies connections between recognized STEM Career Cluster standards and NDG Linux Essentials curriculum.

Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION

Permissions Mapping in the Isilon OneFS File System

IPPBX FAQ. For Firmware Version: V2.0/V

Introduction to Operating Systems

See the installation page

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)

Safety measures in Linux

Hands-On UNIX Exercise:

Network Administration and Monitoring

docs.hortonworks.com

IT6204 Systems & Network Administration. (Optional)

Using Dedicated Servers from the game

White Paper BMC Remedy Action Request System Security

Cryptography and Network Security Prof. D. Mukhopadhyay Department of Computer Science and Engineering

UNIX Remote Job Entry User s Guide A. L. Sabsevitz K. A. Kelleman

µtasker Document FTP Client

EMC Data Protection Search

SQL Server Hardening

Partek Flow Installation Guide

Quick Start - NetApp File Archiver

CS420: Operating Systems OS Services & System Calls

SOA Software API Gateway Appliance 7.1.x Administration Guide

Encrypt-FS: A Versatile Cryptographic File System for Linux

Git - Working with Remote Repositories

Testing Web Applications for SQL Injection Sam Shober

CS3600 SYSTEMS AND NETWORKS

IBM SmartCloud Workload Automation - Software as a Service. Agent Installation and Uninstallation Messages

What is Auditing? IT 4823 Information Security Administration. Problems. Uses. Logger. Audit System Structure. Logging. Auditing. Auditing November 7

BF2CC Daemon Linux Installation Guide

Cisco Setting Up PIX Syslog

Gladinet Cloud Backup V3.0 User Guide

CS 290 Host-based Security and Malware. Christopher Kruegel

File System Encryption with Integrated User Management

Installing an open source version of MateCat

How To Understand How A Process Works In Unix (Shell) (Shell Shell) (Program) (Unix) (For A Non-Program) And (Shell).Orgode) (Powerpoint) (Permanent) (Processes

Syslog (Centralized Logging and Analysis) Jason Healy, Director of Networks and Systems

Software security. Buffer overflow attacks SQL injections. Lecture 11 EIT060 Computer Security

SoftNAS Application Guide: In-Flight Encryption 12/7/2015 SOFTNAS LLC

SQL Injection January 23, 2013

Command Line Interface User Guide for Intel Server Management Software

An macro: Exploring metadata EG and user credentials in Linux to automate notifications Jason Baucom, Ateb Inc.

Linux Security Ideas and Tips

The System Monitor Handbook. Chris Schlaeger John Tapsell Chris Schlaeger Tobias Koenig

Transcription:

System Security Fundamentals Alessandro Barenghi Dipartimento di Elettronica, Informazione e Bioingegneria Politecnico di Milano alessandro.barenghi - at - polimi.it April 28, 2015

Lesson contents Overview The *nix user control and file permission model Linux Capabilites based permission control Secure programming practices

How to train your users Overview Linux a are natively conceived as a multi-user operating system Multiple users will naturally perform different task, and have different needs on the machine To avoid abuses, the user access to the hardware should be somehow restricted It should also be possible to cluster users in groups, in order to ease the issuing of permissions a and more in general all the Unices

Access to the system Login and credential storage The basic Linux authentication and user control method relies on assigning a unique numeric User IDentifier to every user The UIDs, together with some information about the users are stored in /etc/passwd For safety reasons, the actual user passwords, processed through a one way function a are preserved in /etc/shadow At login, the system checks if the user exists, hashes the passwords and matches it against the correct hash and executes the preferred command interpreter for the user For large system it is possible to use a database backend to store the credentials together with a centralized login a as noone, in his sane mind should store cleartext passwords

Processes Overview Every process in modern Unices has three UID identifying on behalf of whom it acts: Real UID: the UID of the user who launched the program Effective UID: the UID which is used by the kernel for access control Saved UID: an extra stored UID which can be swapped with the current Effective UID Every process in Linux also has an FSUID, which acts as a separate UID for file access Usually the FSUID follows the EUID, unless explicitly set Analogously to UIDs, 4 group IDs are attached to each process

File permissions Overview As we recall from the basic system administration lessons, under Unix everything is a file It is thus natural to have the access permissions set on every file Every file has both an owner and a group to which it belongs The basic permissions to act on a file are stored for both the owner and the group

File permissions the User-Group-Other model Three access check are made under Unix : the permission to read (r), write (w) and execute a file (x) The permission bits are usually represented visually by 9 characters rwxrwxrwx a The first 3 (rwxrwxrwx) are the permissions for the owner The second 3 (rwxrwxrwx) are the permissions for the members of the same group which owns the file The last 3 (rwxrwxrwx) are the permissions for the others There are 3 extra permission bits, which are needed to mark the set-user ID, set-group ID and stickyness a The extra character at the beginning of the line ls provides is a marker for the file type

File permissions Changing permissions and ownerships File Permissions can be changed via the chmod command chmod accepts either a 4-digit octal representation of the permissions or a list of the permissions to be added-revoked Revoking the execute permission on a directory forbids its traversal The chown command allows to change the user/group owning a file: syntax chmod <user>:<group> filename A special permission, the sticky bit allows only the owner of a file to remove it (even if others have full access)

Saved IDs Set user ID and set group ID Executable programs are started with RUID and EUID equal to the user who launched them If the set user ID / set group ID permission bits are set on the executable file, the EUID/EGID will be equal to the owner of the file and not the caller This allows to execute programs as someone else, even without logging in as him/her Suid and sgid bits can be changed via chmod: they are the first two bits of an extra digit in octal You can find all of them via find / -perm +6000 -type f -user <username>

The administrator Got root? Among all the users, one is special: the system administrator The system administrator, by default named root, has UID 0 Any permission check will be skipped if the issuer of an action has UID 0: security checks are enclosed in an if(uid){...} This implies that any process with EUID 0 can read/write/run anything Having an EUID of 0 allows a process to modify any access credentials without knowing the previous ones

A programmer point of view Linux API for UNIX permissions The getuid and geteuid function return respectively the RUID and EUID setuid tries to set all the UIDs seteuid only the EUID The chmod and chown functions act exactly as the commands For chmod to work, either the EUID matches the owner of the file, or the program runs as root (i.e., EUID=0) The same concept applies to the chown function

Dropping privileges Typical suid privilege dropping The correct practice if you have a suid root program to be run is to drop the privileges as soon as you do not need them anymore: State Action EUID Real UID Saved UID Startup 0 user 0 temp. drop seteuid(getuid()) user user 0 restore seteuid(0) 0 user 0 Perm. drop setuid(getuid()) user user user restore seteuid(0) user user user

Linux Capabilities When root is too much The power held by the administrator in UNIX is absolute, yielding it in a single block may be too much Typical example : why must my web server run as root when it just needs to open a privileged port? Solution : POSIX Capabilities : partition the administrative rights in a set of capabilities Affix some of the capabilites to an executable file, instead of setting it suid root

Linux Capabilities Common capabilities The list of all system capabilities is available with man capability Useful capabilities are : CAP NET RAW : allows to use raw sockets CAP NET ADMIN : allows to change routing tables CAP KILL : unlocks signal sending to everyone CAP SYS NICE : allows to renice with negative values You can retrieve the list of capabilities of a file with getcap <filename> Symmetrically, you can set the capabilities setcap <capability>[+ - =]ep <filename>

Dropping privileges Typical cap privilege dropping Active capabilities can be checked via the cap get flag function (returning true or false) Capabilities can be dropped easily via the cap set flag function Capability dropping is permanent for the current run of the program (no mechanism as saved caps) the whole capability set can be retrieved via a call to the cap get proc function

Key Ideas Do not take anything for granted Secure programming implies checking that the inputs and the environment of a program are safe Capabilities or extra privileges granted should be discarded when not needed Error messages should be explanatory, but not too much Memory management errors are a possible source of endless issues The printf case

Hostile Environments Mind user input User input may not just be rotten, but actually intentionally poisoned It is possible to deviate the common behaviour of a program if it does not take any care in verifying that the input matches a sane format We will see two examples : the system call which runs a command in a new instance of the command interpreter the exec call family, which runs a command directly, replacing the code of the running process Remember that, when a call to fork or exec is issued, the value of EUID and EGID is preserved

Hostile Environments Error notifications Our good nature pushes us towards using meaningful error messages to help the user However, the error messages have historically been a source of information leakage Every time an error message is displayed, some information about the state of the program leaks Sample issue: what if I help the user outputting the wrong line of a config file? Best practice : employ verbose error messages only enclosed in DEBUG macros and remove them afterwards

Hostile Environments What s in a SEGFAULT? Wouldn t it be as dangerous as... Bad memory management and boundary checking looks as just a safety issue It turns out that performing memory copy operations without checking boundaries may allow the attacker to write anywhere in the memory segment of the program Since the stack is a commonly writeable area, it may happen that a part of the stack is overwritten during a strcpy operation... but on the stack there s the return pointer of the actual call!

Hostile Environments Proper memory management Arbitrary memory rewriting allows control flow hijacking: it s feasible and it s being done since 1996 Always allocate enough space when you are copying strings (#char+1) Use only boundary checking copy functions (strncpy) Always check if memory allocations succeed, copying into a NULL pointer is also dangerous a a NULL is defined as (void*) 0, so if someone mmaps things to 0...

Hostile Environments Format string issues At a first glance, the printf function looks mostly harmless However, the number of arguments it treats is implicitly indicated in the format string What if a printf does not have any parameters, and the user can specify a part of the string being printed? Reminder: among the format options allowed by C there is %n, which writes the number of printed character in a variable...