lecture 2: operating system structureheechul/courses/eecs678/f16/slides/23.security.pdf10 owner...

24
Protection 1 Disclaimer: some slides are adopted from book authors’ slides with permission

Upload: others

Post on 03-Jun-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Protection

1

Disclaimer: some slides are adopted from book authors’ slides with permission

Page 2: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Recap

• Distributed computing

– Sharing, performance, reliability

• Terminology

– Network

– Packet

– Protocol

• DNS

– A distributed database of domain name, IP addr.

2

Page 3: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Recap: TCP/IP Protocol Layers

3

Ethernet

HTTP, DNS, SMTP, FTP,

Page 4: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Recap: Sending a Packet

4

Source: G. Herrin, Linux IP Networking: A Guide to the Implementation and Modification of the Linux Protocol Stack, 2000

Page 5: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Today

• Protection

• Security

5

Page 6: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Examples of OS Protection

• Memory protection

– Between user processes

– Between user and kernel

• File protection

– Prevent unauthorized accesses to files

• Privileged instructions

– Page table updates

– Cache/TLB updates

6

Page 7: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Principles of Protection

• Principle of least privilege

– Programs and users should be given just enough privileges to perform their tasks

– Limit the damage if the entity has a bug or abused

7

Page 8: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Protection Domains

• Let Di and Dj be any two domain rings

• If j < I Di Dj

• Kernel mode vs. user mode

8

Page 9: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Access Control Matrix

• Domains in rows

– Domain: a user or a group of users

• Resources in columns

– File, device, …

9

E.g., User D1 can read F1 or F3

Page 10: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Method 1: Access Control List

• Each object stores users and their permissions -rw-rw-r-- heechul heechul 38077 Apr 23 15:16 main.tex

10

owner

group

world

Page 11: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Method 2: Capability List

• Each domain tracks which objects can access

– Page table: each process (domain) tracks all pages (objects) it can access

11

Page 12: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Summary

• Protection

– Prevent unintended/unauthorized accesses

• Protection domains

– Class hierarchy: root can to everything a normal user can do + alpha

• Access control matrix

– Domains (Users) Resources (Objects)

– Resource oriented: Access control list

– Domain oriented: Capability list

12

Page 13: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Security

13

Page 14: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Outline

• Security basics

• Stack overflow

• Some recent security bugs

14

Page 15: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Security

• System secure if resources used and accessed as intended under all circumstances

– Unachievable

• Intruders (crackers) attempt to breach security

• Threat is potential security violation

• Attack is attempt to breach security

15

Page 16: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Program Threats

• Stack and Buffer Overflow

– Exploits a bug in a program (overflow either the stack or memory buffers)

– Failure to check bounds on inputs, arguments

– Write past arguments on the stack into the return address on stack

– When routine returns from call, returns to hacked address • Pointed to code loaded onto stack that executes malicious code

– Unauthorized user or privilege escalation

16

Page 17: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Stack Frame Layout

17

Stack pointer

Page 18: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Code with Buffer Overflow

• What is wrong in this code? 18

#define BUFFER_SIZE 256 int process_args(char *arg1) { char buffer[BUFFER SIZE]; strcpy(buffer,arg1); ... } int main(int argc, char *argv[]) { process_args(argv[1]); ... }

Page 19: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Code with Buffer Overflow

• Stack layout after calling process_arg() 19

#define BUFFER_SIZE 256 int process_args(char *arg1) { char buffer[BUFFER SIZE]; strcpy(buffer,arg1); ... } int main(int argc, char *argv[]) { process_args(argv[1]); ... }

arg1

Page 20: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Code with Buffer Overflow

• Do you remember strcpy() in C? 20

#define BUFFER_SIZE 256 int process_args(char *arg1) { char buffer[BUFFER SIZE]; strcpy(buffer,arg1); ... } int main(int argc, char *argv[]) { process_args(argv[1]); ... }

arg1

Page 21: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Let’s Get the Shell

• Steps

– Compile the code you want to illegitimately execute

– ‘Carefully’ modify the binary

– Pass the modified binary as string to the process_arg()

21

#include <stdio.h>

int main(int argc, char *argv[])

{

execvp(‘‘/bin/sh’’,‘‘/bin/sh’’, NULL); return 0;

}

Page 22: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

The Attack: Buffer Overflow

22

Before After executing strcpy(buffer, arg1)

the crafted string containing the illegitimate code

Page 23: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Linux Kernel Buffer Overflow Bugs

23

Source: http://www.cvedetails.com/vulnerability-list/vendor_id-33/product_id-47/cvssscoremin-9/cvssscoremax-/Linux-Linux-Kernel.html

212 reported buffer overflow bugs in Linux

Page 24: Lecture 2: Operating System Structureheechul/courses/eecs678/F16/slides/23.Security.pdf10 owner group world . Method 2: Capability List •Each domain tracks which objects can access

Linux Kernel Buffer Overflow Bugs

24