Lecture 21: OS Security 1

Previous lecture Next lecture

Exam

Security and its management in the OS

Important questions:

Overview

Security problems

Operating system security

Example: fake login screen

Malware example: viruses

Example: social engineering

Types of malware

Permission management: objectives

Permission management: requirements

Permission management: design principles

Access matrix

Basic model: file/process attributes

Access matrix variants

ACLs

File 0 (Jan, *, RWX)
File 1 (Jan, system, RWX)
File 2 (Jan, *, RW-), (Els, staff, R--), (Maike, _, RW-)
File 3 (_, student, R--)
File 4 (Jelle, _,---), (_, student, R--)

Unix access permissions

Problem: permission extensions

  1. all users have write permission to the high score list
    • too many permissions (does not work)
    • every user could arbitrarily manipulate the high score list
  2. SetUID: only "me" has write permissions
    • Tetris program has "setuid" permissions
    • as soon as the Tetris program is executed, the process is assigned the user ID of the owner of the executable program

Unix: users and processes

Unix solution: setuid mechanism

Example: high score list

Example: high score list (2)

Example: high score list (3)

setuid problems

Capabilities

Example

Rule-based access matrix

System software and security

Hardware-based protection: MMU

Protection rings

Software-based protection

Software-based protection (2)

Software-based protection (3)

root:4t6f4rt3423:0:0:System Administrator:/var/root:/bin/sh
daemon:ge53r3rfrg:1:1:System Services:/var/root:/usr/bin/false
me:1x3Fe5$gRd:1000:1000:Michael Engel:/home/me:/bin/bash
-rw-r--r-- 1 root root 1353 May 28 22:43 /etc/passwd
-rw-r----- 1 root shadow 901 May 28 22:43 /etc/shadow

Software bugs

Value ranges

char a = 127;
char b = 3;
char result = a + b;
 01111111 (a)
+00000011 (b)
 10000010 (result is negative!)

Value ranges (2)


char string[127] = "Hello World!\n"
char a = 127;
char b = 3;
...
char myfunc(char *string, char index) {
  return string[index];
}
...
printf("%x", myfunc(string, a+b));

Heap overflow

Heap overflow (2)

define BUFSIZE 16
define OVERSIZE 8 /* overflow buf2 by OVERSIZE bytes */

int main(void) {
	u_long diff;
	char *buf1 = malloc(BUFSIZE),
	     *buf2 = malloc(BUFSIZE);

	diff = (u_long)buf2- (u_long)buf1;
	printf("buf1 = %p, buf2 = %p, diff = 0x%x\n", buf1, buf2, diff);

	memset(buf2, 'A', BUFSIZE-1);
	buf2[BUFSIZE-1] = '\0';

	printf("before overflow: buf2 = %s\n", buf2);
	memset(buf1, 'B', (u_int)(diff + OVERSIZE));
	printf("after overflow: buf2 = %s\n", buf2);
	return 0;
}

Result…

Unix Morris worm (sendmail)

Michelangelo virus

Sony BMG root kit

Blue Pill – VM-based root kit

Conclusion