Lecture 14 Page 1 CS 236 Online Race Conditions A common cause of security bugs Usually involve multiprogramming or multithreaded programs Caused by different.

Slides:



Advertisements
Similar presentations
TOCTTOU Attacks Don Porter CS 380S
Advertisements

Lecture 13 Page 1 CS 111 Online File Systems: Introduction CS 111 On-Line MS Program Operating Systems Peter Reiher.
Computer Science CSC 405 LabBy Yuzheng Zhou1 CSC 405 Introduction to Computer Security Lab session.
INSE - Lectures 19 & 20 SE for Real-Time & SE for Concurrency  Really these are two topics – but rather tangled together.
Lecture 19 Page 1 CS 111 Online Protecting Operating Systems Resources How do we use these various tools to protect actual OS resources? Memory? Files?
1 The Fortuna PRNG Niels Ferguson. 2 The problem We need to make “random” choices in cryptographic protocols. Computers are deterministic. Standard “random”
Lecture 2 Page 1 CS 236, Spring 2008 Security Principles and Policies CS 236 On-Line MS Program Networks and Systems Security Peter Reiher Spring, 2008.
© 2003 School of Computing, University of Leeds SY32 Secure Computing, Lecture 15 Implementation Flaws Part 3: Randomness and Timing Issues.
Building Secure Software Chapter 9 Race Conditions.
Cryptography and Network Security Chapter 11 Fifth Edition by William Stallings Lecture slides by Lawrie Brown.
Threats to I.T Internet security By Cameron Mundy.
Lecture 7 Page 1 CS 236 Online Password Management Limit login attempts Encrypt your passwords Protecting the password file Forgotten passwords Generating.
Lecture 18 Page 1 CS 111 Online Design Principles for Secure Systems Economy Complete mediation Open design Separation of privileges Least privilege Least.
Lecture 19 Page 1 CS 111 Online Symmetric Cryptosystems C = E(K,P) P = D(K,C) E() and D() are not necessarily the same operations.
Lecture 18 Page 1 CS 111 Online Access Control Security could be easy – If we didn’t want anyone to get access to anything The trick is giving access to.
Bill's Amazing Content Rotator jQuery Content Rotator.
Lecture 16 Page 1 CS 236 Online SQL Injection Attacks Many web servers have backing databases –Much of their information stored in a database Web pages.
CS 346 – Chapter 1 Operating system – definition Responsibilities What we find in computer systems Review of –Instruction execution –Compile – link – load.
Phishing scams Phishing is the fraudulent practice of sending s purporting to be from reputable companies in order to induce individuals to reveal.
Lecture 7 Page 1 CS 236 Online Challenge/Response Authentication Authentication by what questions you can answer correctly –Again, by what you know The.
Digital Citizenship Lesson 3. Does it Matter who has your Data What kinds of information about yourself do you share online? What else do you do online.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
Systems Life Cycle. Know why it is necessary to evaluate a new system Understand the need to evaluate in terms of ease-of- use, appropriateness and efficiency.
Lecture 19 Page 1 CS 236 Online 16. Account Monitoring and Control Why it’s important: –Inactive accounts are often attacker’s path into your system –Nobody’s.
Lecture 16 Page 1 CS 236 Online Secure Programming, Continued CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Understanding Computer Viruses: What They Can Do, Why People Write Them and How to Defend Against Them Computer Hardware and Software Maintenance.
Attacks on PRNGs - By Nupura Neurgaonkar CS-265 (Prof. Mark Stamp)
Linux Security. Authors:- Advanced Linux Programming by Mark Mitchell, Jeffrey Oldham, and Alex Samuel, of CodeSourcery LLC published by New Riders Publishing.
Security CS Introduction to Operating Systems.
1 Legacy Code From Feathers, Ch 2 Steve Chenoweth, RHIT Right – Your basic Legacy, from Subaru, starting at $ 20,295, 24 city, 32 highway.
Computer security By Isabelle Cooper.
Unix Commands PowerPoint Presentation developed for LS 560 Information Technology online class - University of Alabama by Debey Sklenar TENacious Cohort.
Chapter 5 Files and Exceptions I. "The Practice of Computing Using Python", Punch & Enbody, Copyright © 2013 Pearson Education, Inc. What is a file? A.
CS5103 Software Engineering Lecture 02 More on Software Process Models.
Lecture 7 Page 1 CS 236 Online Authentication CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Lecture 4 Page 1 CS 111 Online Modularity and Virtualization CS 111 On-Line MS Program Operating Systems Peter Reiher.
Operating Systems CSE 411 Revision and final thoughts Revision and final thoughts Dec Lecture 33 Instructor: Bhuvan Urgaonkar.
Lecture 14 Page 1 CS 136, Fall 2014 Secure Programming, Continued Computer Security Peter Reiher December 4, 2014.
Lecture 14 Page 1 CS 111 Summer 2013 Security in Operating Systems: Basics CS 111 Operating Systems Peter Reiher.
Lecture9 Page 1 CS 236 Online Operating System Security, Con’t CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Lecture 15 Page 1 CS 236 Online Evaluating Running Systems Evaluating system security requires knowing what’s going on Many steps are necessary for a full.
I/O Software CS 537 – Introduction to Operating Systems.
Lecture 8 Page 1 CS 236 Online Protecting Interprocess Communications Operating systems provide various kinds of interprocess communications –Messages.
Lecture 8 Page 1 CS 236 Online Prolog to Lecture 8 CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Lecture 3 Page 1 CS 236 Online Security Mechanisms CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Lecture 14 Page 1 CS 111 Online File Systems: Naming, Reliability, and Advanced Issues CS 111 On-Line MS Program Operating Systems Peter Reiher.
Lecture 4 Page 1 CS 111 Online Modularity and Memory Clearly, programs must have access to memory We need abstractions that give them the required access.
Key Wrap Algorithm.
Lecture 2 Page 1 CS 236 Online Security Policies Security policies describe how a secure system should behave Policy says what should happen, not how you.
Lecture 5 Page 1 CS 111 Summer 2013 Bounded Buffers A higher level abstraction than shared domains or simple messages But not quite as high level as RPC.
Lecture 14 Page 1 CS 136, Spring 2016 Secure Programming, Continued Computer Security Peter Reiher May 17, 2016.
Lecture 14 Page 1 CS 236 Online Secure Programming CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Lecture 17 Page 1 CS 136, Fall 2010 Secure Programming, Continued CS 136 Computer Security Peter Reiher November 30, 2010.
Outline Introduction Principles for secure software
Outline Introduction Principles for secure software
Outline Basic concepts in computer security
Protecting Memory What is there to protect in memory?
Security+ All-In-One Edition Chapter 1 – General Security Concepts
Protecting Memory What is there to protect in memory?
Protecting Memory What is there to protect in memory?
Multiple Writers and Races
Outline Introduction Principles for secure software
Outline Introduction Principles for secure software
CS510 Operating System Foundations
Outline Introduction Principles for secure software
CSE 153 Design of Operating Systems Winter 2019
Race Condition Vulnerability
Types of Software Testing Course. CONTENT  Black-box testing course  White-box software testing course  Automated software testing course  Regression.
Presentation transcript:

Lecture 14 Page 1 CS 236 Online Race Conditions A common cause of security bugs Usually involve multiprogramming or multithreaded programs Caused by different threads of control operating in unpredictable fashion –When programmer thought they’d work in a particular order

Lecture 14 Page 2 CS 236 Online What Is a Race Condition? A situation in which two (or more) threads of control are cooperating or sharing something If their events happen in one order, one thing happens If their events happen in another order, something else happens Often the results are unforeseen

Lecture 14 Page 3 CS 236 Online Security Implications of Race Conditions Usually you checked privileges at one point You thought the next lines of code would run next –So privileges still apply But multiprogramming allows things to happen in between

Lecture 14 Page 4 CS 236 Online The TOCTOU Issue Time of Check to Time of Use Have security conditions changed between when you checked? And when you used it? Multiprogramming issues can make that happen Sometimes under attacker control

Lecture 14 Page 5 CS 236 Online A Short Detour In Unix, processes can have two associated user IDs –Effective ID –Real ID Real ID is the ID of the user who actually ran it Effective ID is current ID for access control purposes Setuid programs run this way System calls allow you to manipulate it

Lecture 14 Page 6 CS 236 Online Effective UID and Access Permissions Unix checks accesses against effective UID, not real UID So setuid program uses permissions for the program’s owner –Unless relinquished Remember, root has universal access privileges

Lecture 14 Page 7 CS 236 Online An Example Code from Unix involving a temporary file Runs setuid root res = access(“/tmp/userfile”, R_OK); If (res != 0) die(“access”); fd = open(“/tmp/userfile”,O_RDONLY);

Lecture 14 Page 8 CS 236 Online What’s (Supposed to Be) Going on Here? Checked access on /tmp/userfile to make sure user was allowed to read it –User can use links to control what this file is access() checks real user ID, not effective one –So checks access permissions not as root, but as actual user So if user can read it, open file for read –Which root is definitely allowed to do Otherwise exit

Lecture 14 Page 9 CS 236 Online What’s Really Going On Here? This program might not run uninterrupted OS might schedule something else in the middle In particular, between those two lines of code

Lecture 14 Page 10 CS 236 Online How the Attack Works Attacker puts innocuous file in /tmp/userfile Calls the program Quickly deletes file and replaces it with link to sensitive file –One only readable by root If timing works, he gets secret contents

Lecture 14 Page 11 CS 236 Online The Dynamics of the Attack /tmp/userfile res = access(“/tmp/userfile”, R_OK); if (res != 0) die(“access”); fd = open(“/tmp/userfile”,O_RDONLY); /etc/secretfile 1.Run program 2.Change file Let’s try that again! One more time! Success!

Lecture 14 Page 12 CS 236 Online How Likely Was That? Not very –The timing had to be just right But the attacker can try it many times –And may be able to influence system to make it more likely And he only needs to get it right once Timing attacks of this kind can work The longer between check and use, the more dangerous

Lecture 14 Page 13 CS 236 Online Some Types of Race Conditions File races –Which file you access gets changed Permissions races –File permissions are changed Ownership races –Who owns a file changes Directory races –Directory hierarchy structure changes

Lecture 14 Page 14 CS 236 Online Preventing Race Conditions Minimize time between security checks and when action is taken Be especially careful with files that users can change Use locking and features that prevent interruption, when possible Avoid designs that require actions where races can occur

Lecture 14 Page 15 CS 236 Online Randomness and Determinism Many pieces of code require some randomness in behavior Where do they get it? As earlier key generation discussion showed, it’s not that easy to get

Lecture 14 Page 16 CS 236 Online Pseudorandom Number Generators PRNG Mathematical methods designed to produce strings of random-like numbers Actually deterministic –But share many properties with true random streams of numbers

Lecture 14 Page 17 CS 236 Online Attacks on PRNGs Cryptographic attacks –Observe stream of numbers and try to deduce the function State attacks –Attackers gain knowledge of or influence the internal state of the PRNG

Lecture 14 Page 18 CS 236 Online An Example ASF Software’s Texas Hold’Em Poker Flaw in PRNG allowed cheater to determine everyone’s cards –Flaw in card shuffling algorithm –Seeded with a clock value that can be easily obtained

Lecture 14 Page 19 CS 236 Online Another Example Netscape’s early SSL implementation Another guessable seed problem –Based on knowing time of day, process ID, and parent process ID –Process IDs readily available by other processes on same box Broke keys in 30 seconds

Lecture 14 Page 20 CS 236 Online A Recent Case The chip-and-pin system is used to secure smart ATM cards Uses cryptographic techniques that require pseudo-random numbers Cambridge found weaknesses in the PRNG Allows attackers to withdraw cash without your card Seems to be in real use in the wild

Lecture 14 Page 21 CS 236 Online How to Do Better? Use hardware randomness, where available Use high quality PRNGs –Preferably based on entropy collection methods Don’t use seed values obtainable outside the program