CMSC 414 Computer and Network Security Lecture 25 Jonathan Katz.

Slides:



Advertisements
Similar presentations
Buffer Overflows Nick Feamster CS 6262 Spring 2009 (credit to Vitaly S. from UT for slides)
Advertisements

Mobile Code Security Yurii Kuzmin. What is Mobile Code? Term used to describe general-purpose executables that run in remote locations. Web browsers come.
Defenses. Preventing hijacking attacks 1. Fix bugs: – Audit software Automated tools: Coverity, Prefast/Prefix. – Rewrite software in a type safe languange.
Communications of the ACM (CACM), Vol. 32, No. 6, June 1989
Computer Security: Principles and Practice EECS710: Information Security Professor Hossein Saiedian Fall 2014 Chapter 10: Buffer Overflow.
Computer Security: Principles and Practice First Edition by William Stallings and Lawrie Brown Lecture slides by Lawrie Brown Chapter 11 – Buffer Overflow.
CSE331: Introduction to Networks and Security Lecture 32 Fall 2002.
Mobile Code Security Aviel D. Rubin, Daniel E. Geer, Jr. MOBILE CODE SECURITY, IEEE Internet Computing, 1998 Minkyu Lee
CMSC 414 Computer and Network Security Lecture 22 Jonathan Katz.
Chapter 3 (Part 1) Network Security
1 Topic 1 – Lesson 3 Network Attacks Summary. 2 Questions ► Compare passive attacks and active attacks ► How do packet sniffers work? How to mitigate?
Silberschatz, Galvin and Gagne  Operating System Concepts The Security Problem A system is secure iff its resources are used and accessed as.
1 Protection Protection = access control Goals of protection Protecting general objects Example: file protection in Linux.
Attacking Malicious Code: A Report to the Infosec Research Council Kim Sung-Moo.
19.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 19: Security The Security Problem Authentication Program Threats.
________________ CS3235, Nov 2002 Viruses Adapted from Pfleeger[Chap 5]. A virus is a program [fragment] that can pass on malicious code [usually itself]
CMSC 414 Computer and Network Security Lecture 24 Jonathan Katz.
Preventing Buffer Overflow Attacks. Some unsafe C lib functions strcpy (char *dest, const char *src) strcat (char *dest, const char *src) gets (char *s)
1 Pertemuan 05 Malicious Software Matakuliah: H0242 / Keamanan Jaringan Tahun: 2006 Versi: 1.
Copyright © Clifford Neuman - UNIVERSITY OF SOUTHERN CALIFORNIA - INFORMATION SCIENCES INSTITUTE USC CSci530 Computer Security Systems Lecture.
1 Malicious Logic CSSE 490 Computer Security Mark Ardis, Rose-Hulman Institute March 25, 2004.
CMSC 414 Computer and Network Security Lecture 18 Jonathan Katz.
Guide to Operating System Security Chapter 2 Viruses, Worms, and Malicious Software.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow II: Defense Techniques Cliff Zou Spring 2012.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow II: Defense Techniques Cliff Zou Spring 2013.
Page 1 Sandboxing & Signed Software Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
Java Security Updated May Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security.
University of Washington CSE 351 : The Hardware/Software Interface Section 5 Structs as parameters, buffer overflows, and lab 3.
Henric Johnson1 Chapter 10 Malicious Software Henric Johnson Blekinge Institute of Technology, Sweden
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
1 Chap 10 Malicious Software. 2 Viruses and ”Malicious Programs ” Computer “Viruses” and related programs have the ability to replicate themselves on.
Chapter 15: Security (Part 1). The Security Problem Security must consider external environment of the system, and protect the system resources Intruders.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
Web Application Access to Databases. Logistics Test 2: May 1 st (24 hours) Extra office hours: Friday 2:30 – 4:00 pm Tuesday May 5 th – you can review.
CMSC 414 Computer (and Network) Security Lecture 14 Jonathan Katz.
Virus and Antivirus Team members: - Muzaffar Malik - Kiran Karki.
Computer Security and Penetration Testing
BLENDED ATTACKS EXPLOITS, VULNERABILITIES AND BUFFER-OVERFLOW TECHNIQUES IN COMPUTER VIRUSES By: Eric Chien and Peter Szor Presented by: Jesus Morales.
3-Protecting Systems Dr. John P. Abraham Professor UTPA.
Cosc 4010 Sandboxing. Last lecture Last time, we covered chroot, which is a method to "sandbox" a problem. –Not full proof by any means. Many simple mistakes.
1 Higher Computing Topic 8: Supporting Software Updated
1 Chap 10 Virus. 2 Viruses and ”Malicious Programs ” Computer “Viruses” and related programs have the ability to replicate themselves on an ever increasing.
Administrative: Objective: –Tutorial on Risks –Phoenix recovery Outline for today.
Chapter 10 Malicious software. Viruses and ” Malicious Programs Computer “ Viruses ” and related programs have the ability to replicate themselves on.
Malicious Logic and Defenses. Malicious Logic Trojan Horse – A Trojan horse is a program with an overt (documented or known) effect and covert (undocumented.
Buffer Overflow Group 7Group 8 Nathaniel CrowellDerek Edwards Punna ChalasaniAxel Abellard Steven Studniarz.
Operating Systems Security
Computer Systems Viruses. Virus A virus is a program which can destroy or cause damage to data stored on a computer. It’s a program that must be run in.
Computer virus Speaker : 蔡尚倫.  Introduction  Infection target  Infection techniques Outline.
W elcome to our Presentation. Presentation Topic Virus.
Security Attacks Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Slides by Kent Seamons and Tim van der Horst Last Updated: Nov 11, 2011.
VM: Chapter 7 Buffer Overflows. csci5233 computer security & integrity (VM: Ch. 7) 2 Outline Impact of buffer overflows What is a buffer overflow? Types.
Page 1 Viruses. Page 2 What Is a Virus A virus is basically a computer program that has been written to perform a specific set of tasks. Unfortunately,
Software Security. Bugs Most software has bugs Some bugs cause security vulnerabilities Incorrect processing of security related data Incorrect processing.
1 Introduction to Information Security , Spring 2016 Lecture 2: Control Hijacking (2/2) Avishai Wool.
CS703 - Advanced Operating Systems By Mr. Farhan Zaidi.
@Yuan Xue Worm Attack Yuan Xue Fall 2012.
Security on the Internet Norman White ©2001. Security What is it? Confidentiality – Can my information be stolen? Integrity – Can it be changed? Availability.
Protecting Memory What is there to protect in memory?
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow II: Defense Techniques Cliff Zou Spring 2016.
CMSC 414 Computer and Network Security Lecture 21
Chap 10 Malicious Software.
Preventing Buffer Overflow Attacks
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow II: Defense Techniques Cliff Zou Spring 2011.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow II: Defense Techniques Cliff Zou Spring 2009.
Security.
Chap 10 Malicious Software.
Operating System Concepts
CNT4704: Analysis of Computer Communication Network Special Topic: Buffer Overflow II: Defense Techniques Cliff Zou Fall 2011.
Presentation transcript:

CMSC 414 Computer and Network Security Lecture 25 Jonathan Katz

Secure programming techniques (Based on: “Programming Secure Applications for Unix-Like Systems,” David Wheeler)

Overview  Validate all input  Avoid buffer overflows  Program internals…  Careful calls to other resources  Send info back intelligently

Validating input  Determine acceptable input, check for match --- don’t just check against list of “non-matches” –Limit maximum length –Watch out for special characters, escape chars.  Check bounds on integer values –E.g., sendmail bug…

Validating input  Filenames –Disallow *,.., etc.  Html, URLs, cookies –Cf. cross-site scripting attacks  Command-line arguments –Even argv[0]…  Config files

Avoiding buffer overflows  Use arrays instead of pointers (cf. Java)  Avoid strcpy(), strcat(), etc. –Use strncpy(), strncat(), instead –Even these are not perfect… (e.g., no null termination)  Make buffers (slightly) longer than necessary to avoid “off-by-one” errors

Program internals…  Avoid race conditions –E.g., authorizing file access, then opening file  Watch out for temporary files in shared directories (e.g., /tmp)  Watch out for “spoofed” IP addresses/ addresses  Simple, open design; fail-safe defaults; completge mediation; etc.  Don’t write your own crypto algorithms –Use crypto appropriately

Calling other resources  Use only “safe” library routines  Limit call parameters to valid values –Avoid metacharacters  Avoid calling the shell

User output  Minimize feedback –Don’t explain failures to untrusted users –Don’t release version numbers… –Don’t offer “too much” help (suggested filenames, etc.)  Don’t use printf(userInput) –Use printf(“%s”, userInput) instead…

Source code scanners  Used to check source code –E.g., flawfinder, cqual  “Static” analysis vs. “dynamic” analysis –Not perfect –Dynamic analysis can slow down execution, lead to bloated code –Will see examples of dynamic analysis later…

“Higher-level” techniques

Addressing buffer overflows  Basic stack exploit can be prevented by marking stack segment as non-executable, or randomizing stack location. –Code patches exist for Linux and Solaris. –Some complications on x86.  Problems: –Does not defend against `return-to-libc’ exploit. Overflow sets ret-addr to address of libc function. –Some apps need executable stack (e.g. LISP interpreters). –Does not block more general overflow exploits: Overflow on heap: overflow buffer next to func pointer.  Patch not shipped by default for Linux and Solaris

Run-time checking: StackGuard  Embed “canaries” in stack frames and verify their integrity prior to function return strretsfplocal top of stack canarystrretsfp local canary Frame 1Frame 2

Canary types  Random canary: (used in Visual Studio 2003 ) –Choose random string at program startup. –Insert canary string into every stack frame. –Verify canary before returning from function. –To corrupt random canary, attacker must learn current random string.  Terminator canary: Canary = 0, newline, linefeed, EOF –String functions will not copy beyond terminator. –Attacker cannot use string functions to corrupt stack

Canaries, continued…  StackGuard implemented as a GCC patch –Program must be recompiled  Minimal performance effects:  Not foolproof…

Run-time checking: Libsafe  Intercepts calls to strcpy (dest, src) –Validates sufficient space in current stack frame: |frame-pointer – dest| > strlen(src) –If so, does strcpy. Otherwise, terminates application destret-addrsfp top of stack srcbufret-addrsfp libsafe main

More methods …  Address obfuscation –Encrypt return address on stack by XORing with random string. Decrypt just before returning from function. –Attacker needs decryption key to set return address to desired value.  PaX ASLR : Randomize location of libc –Attacker cannot jump directly to exec function

Software fault isolation  Partition code into data and code segments  Code inserted before each load/store/jump –Verify that target address is safe  Can be done at compiler, link, or run time –Increases program size, slows down execution

Security for mobile code  Mobile code is particularly dangerous!  Sandboxing –Limit the ability of code to do harmful things  Code-signing –Mechanism to decide whether code should be trusted or not  ActiveX uses code-signing, Java uses sandboxing (plus code-signing)

Code signing  Code producer signs code  Binary notion of trust  What if code producer compromised?  Lack of PKI => non-scalable approach

“Proof-carrying code”  Input: code, safety policy of client  Output: safety proof for code  Proof generation expensive –Proof verification cheaper –Prove once, use everywhere (with same policy)  Prover/compiler need not be trusted –Only need to trust the verifier

Sandboxing in Java  Focus on preventing system modification and violations of user privacy –Denial of service attacks much harder to prevent, and not handled all that well  We will discuss some of the basics, but not all the most up-to-date variants of the Java security model

Sandboxing  A default sandbox applied to untrusted code  Users can change the defaults… –Can also define “larger” sandboxes for “partially trusted” code –Trust in code determined using code-signing…

Some examples…  Default sandbox prevents: –Reading/writing/deleting files on client system –Listing directory contents –Creating new network connections to other hosts (other than originating host) –Etc.

Sandbox components  Verifier, Class loader, and Security Manager  If any of these fail, security may be compromised

Verifier  Java program is compiled to platform- independent Java byte code  This code is verified before it is run –Prevents, for example, malicious “hand- written” byte code  Efficiency gains by checking code before it is run, rather than constantly checking it while running

Verifier…  Checks: – Byte code is well-formatted –No forged pointers –No violation of access restrictions –No incorrect typing  Of course, cannot be perfect…

Class loader  Helps prevent “spoofed” classes from being loaded –E.g., external class claiming to be the security manager  Whenever a class needs to be loaded, this is done by a class loader –The class loader decides where to obtain the code for the class

Security manager  Restricts the way an applet uses Java API calls –All calls to the OS are mediated by the security manager  Security managers are browser-dependent!

System call monitoring  Monitor all system calls –Enforce particular policy –Policy may be loaded in kernel  Hand-tune policy for individual applications  Similar to Java security manager –Difference in where implemented

Viruses/malicious code

 Virus – passes malicious code to other non- malicious programs –Or documents with “executable” components  Trojan horse – software with unintended side effects  Worm – propagates via network –Typically stand-alone software, in contrast to viruses which are attached to other programs

Viruses  Can insert themselves before program, can surround program, or can be interspersed throughout program –In the last case, virus writer needs to know about the specifics of the other program  Two ways to “insert” virus: –Insert virus in memory at (old) location of original program –Change pointer structure…

Viruses…  Boot sector viruses –If a virus is loaded early in the boot process, can be very difficult (impossible?) to detect  Memory-resident viruses –Note that virus might complicate its own detection –E.g., removing virus name from list of active programs, or list of files on disk

Some examples  BRAIN virus –Locates itself in upper memory; resets the upper memory bound below itself –Traps “disk reads” so that it can handle any requests to read from the boot sector –Not inherently malicious, although some variants were

Morris worm (1988)  Resource exhaustion (unintended) –Was supposed to have only one copy running, but did not work correctly…  Spread in three ways –Exploited buffer overflow flaw in fingerd –Exploited flaw in sendmail debug mode –Guessing user passwords(!) on current network  Bootstrap loader would be used to obtain the rest of the worm

Chernobyl virus (1998)  When infected program run, virus becomes resident in memory of machine –Rebooting does not help  Virus writes random garbage to hard drive  Attempts to trash FLASH BIOS –Physically destroys the hardware…

Melissa virus/worm (1999)  Word macro… –When file opened, would create and send infected document to names in user’s Outlook Express mailbox –Recipient would be asked whether to disable macros(!) If macros enabled, virus would launch

Code red (2001)  Propagated itself on web server running Microsoft’s Internet Information Server –Infection using buffer overflow… –Propagation by checking IP addresses on port 80 of the PC to see if they are vulnerable

Detecting viruses  Can try to look for “signatures” –Unreliable unless up-to-date –Encrypted viruses –Polymorphic viruses  Examine storage –Sizes of files, “jump” instruction at beginning of code –Can be hard to distinguish from normal software  Check for (unusual) execution patterns –Hard to distinguish from normal software…