Docsity

Notes on Program Security - Introduction to Computer Security | CSC 405, Study notes of Computer Science

Partial preview of the text

Download Notes on Program Security - Introduction to Computer Security | CSC 405 and more Study notes Computer Science in PDF only on Docsity!

CSC 405 Dr. Peng Ning 1 Computer Science

CSC 405

Introduction to Computer Security

Topic 3. Program Security -- Part I

Program Security

  • What is exactly a secure program?
    • Different people may give different answers
    • In general, a secure program should behave as their

designers intended or uses expected

  • Program security flaws
    • Unexpected program behavior
    • Two classes
      • Inadvertent human errors
      • Intentionally induced flaws
      • Both types can cause serious damages

Buffer Overflows

  • A buffer is a space in which data can be held
    • A buffer is finite
  • Buffer overflow
    • Out of bound use of the buffer
  • Example

char sample[10];

for (int i=0; i<=9; i++)

sample[i]=‘A’;

sample[10]=‘B’;

An Example of Stack Buffer Overflow service(){ get_msg(); A:send_msg(); } get_msg(...){ char buf[96]; ... gets(buf); ... B:return; } get_msg buf[96] RA = A saved FP RA = Y saved FP service RA = Z saved FP main get_msg malcode malcode RA = m m m service main

Time-of-Check to Time-of-Use Errors

  • Access control is often required, but access privileges are not checked universally

Example

  • binmail vulnerability
    • On Sun OS 4.1.x
    • Permission of /var/spool/mail is rwxrwxrwt
    • Before it opens the mail file, binmail does an lstat() to check that it is not about to write to a linked file
    • It then use open() to access that file
    • If a link is created after lstat(), open() will then follow the link
    • Exploit
      • Create/append to root’s .rhost file
      • Note that binmail can write to anybody’s mailbox

Virus

  • A virus is a program that attaches itself into one or

more files and then performs some (possibly null)

action

  • Transient virus
    • A transient virus has a life that depends on the life of its host - Runs when the attached program runs - Terminates when that program terminates
  • Resident virus
    • Locates itself in memory
      • Remain active even when the attached program ends

Trojan Horses

  • A Trojan horse is malicious code that, in addition to its primary effect, has a second, non-obvious malicious effect File F A:r A:w File G B:r A:w ACL User A Program Goodies Trojan Horse executes read write

Trapdoor (Backdoor)

  • A feature in a program by which someone can access the program other than by the obvious way, perhaps with special privilege - Example - An ATM allows anyone entering 990099 on the keypad to get all the transactions

Worm

  • A worm is a program that spreads copies of itself through a network
  • Different from viruses
    • Viruses depend on other programs
    • Worms are usually standalone applications
    • Viruses usually trick people into propagating them
    • Worms can hack into vulnerable systems and

spread without depending on others

How does Virus Work

  • Two phases
    • Insertion phase
      • The virus inserts itself into a file (or files)
    • Execution phase
      • The virus executes
  • Usually trick human users to execute the virus
    • This is necessary for the virus to take control
    • Examples
      • Email attachments
      • Hide in boot sector of bootable medium

Places to Insert Virus Code

  • Virus appended to a program
    • Virus instruction first executed
    • Original program executed after the last virus instruction

Places to Insert Virus Code (Cont’d)

  • Virus integrated in the original program
    • The virus writer has to know the exact structure of the original program
    • Targeted infection; Rare

How Virus Gain Control

  • Boot sector infectors
    • The boot sector is the part of a disk used to bootstrap the system.
    • Code in a boot sector is executed when the system “sees” the disk for the first time.
  1. Move the disk interrupt vector 13H to 6DH
  2. Set 13H to invoke Brian virus
  3. Load the original boot sector Brian Virus