Where do security bugs come from? Any how do you find them in the real world? Stanford CS 155 Spring 2014 Alex Stamos CISO, Yahoo.

Slides:



Advertisements
Similar presentations
This course is designed for system managers/administrators to better understand the SAAZ Desktop and Server Management components Students will learn.
Advertisements

Nick Feamster CS 6262 Spring 2009
Leonardo de Moura Microsoft Research. Z3 is a new solver developed at Microsoft Research. Development/Research driven by internal customers. Free for.
Introducing JavaScript
Network Security Attack Analysis. cs490ns - cotter2 Outline Types of Attacks Vulnerabilities Exploited Network Attack Phases Attack Detection Tools.
WebGoat & WebScarab “What is computer security for $1000 Alex?”
Introduction to InfoSec – Recitation 6 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
CMSC 414 Computer and Network Security Lecture 24 Jonathan Katz.
Fuzzing Dan Fleck CS 469: Security Engineering Sources:
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
16/27/2015 3:38 AM6/27/2015 3:38 AM6/27/2015 3:38 AMTesting and Debugging Testing The process of verifying the software performs to the specifications.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
JavaScript, Fourth Edition
Computer Security and Penetration Testing
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
. Memory Management. Memory Organization u During run time, variables can be stored in one of three “pools”  Stack  Static heap  Dynamic heap.
Designing Security In Web Applications Andrew Tomkowiak 10/8/2013 UW-Platteville Software Engineering Department
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
Microsoft ® Official Course Monitoring and Troubleshooting Custom SharePoint Solutions SharePoint Practice Microsoft SharePoint 2013.
Tim Newsham and Alex Stamos Stanford CS155 April 6, 2010 Bug Finding Techniques.
Chapter-4 Windows 2000 Professional Win2K Professional provides a very usable interface and was designed for use in the desktop PC. Microsoft server system.
Testing Tools. Categories of testing tools Black box testing, or functional testing Testing performed via GUI. The tool helps in emulating end-user actions.
Drupal Security Securing your Configuration Justin C. Klein Keane University of Pennsylvania School of Arts and Sciences Information Security and Unix.
WorkPlace Pro Utilities.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
Prevent Cross-Site Scripting (XSS) attack
The OWASP Top 10 and Buffer Overflow Attacks
CSCI 6962: Server-side Design and Programming Secure Web Programming.
A Security Review Process for Existing Software Applications
Introduction Telerik Software Academy Software Quality Assurance.
BLENDED ATTACKS EXPLOITS, VULNERABILITIES AND BUFFER-OVERFLOW TECHNIQUES IN COMPUTER VIRUSES By: Eric Chien and Peter Szor Presented by: Jesus Morales.
Attacking Applications: SQL Injection & Buffer Overflows.
1 JavaScript in Context. Server-Side Programming.
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
COMPUTER SECURITY MIDTERM REVIEW CS161 University of California BerkeleyApril 4, 2012.
Security - Why Bother? Your projects in this class are not likely to be used for some critical infrastructure or real-world sensitive data. Why should.
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.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
Stealing Passwords Remotely & Malware Analysis PacITPros May 8, 2012.
Operating Systems Security
Lecture 14 Page 1 CS 236 Online Variable Initialization Some languages let you declare variables without specifying their initial values And let you use.
1 JavaScript in Context. Server-Side Programming.
Lecture 4 Page 1 CS 111 Online Modularity and Virtualization CS 111 On-Line MS Program Operating Systems Peter Reiher.
Sairajiv Burugapalli. This chapter covers three main categories of classic software vulnerability: Buffer overflows Integer vulnerabilities Format string.
Security Attacks Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
T EST T OOLS U NIT VI This unit contains the overview of the test tools. Also prerequisites for applying these tools, tools selection and implementation.
Software Security. Bugs Most software has bugs Some bugs cause security vulnerabilities Incorrect processing of security related data Incorrect processing.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
@Yuan Xue Worm Attack Yuan Xue Fall 2012.
Vulnerability / Cybersecurity Research Discussion Dwayne Melancon, CISA Chief Technology Officer and VP of Research & Development.
Introduction SQL Injection is a very old security attack. It first came into existence in the early 1990's ex: ”Hackers” movie hero does SQL Injection.
Lecture 19 Page 1 CS 236 Online 6. Application Software Security Why it’s important: –Security flaws in applications are increasingly the attacker’s entry.
Defining your requirements for a successful security (and compliance
Content Coverity Static Analysis Use cases of Coverity Examples
SQL Server Security & Intrusion Prevention
# 66.
Protecting Memory What is there to protect in memory?
K. K. Mookhey Network Intelligence India Pvt. Ltd.
Protecting Memory What is there to protect in memory?
Module 30 (Unix/Linux Security Issues II)
Protecting Memory What is there to protect in memory?
A Security Review Process for Existing Software Applications
Secure Software Development: Theory and Practice
Introduction to Information Security
Where do security bugs come from?
Introduction to Static Analyzer
Engineering Secure Software
Outline Introduction Memory protection Buffer overflows
Presentation transcript:

Where do security bugs come from? Any how do you find them in the real world? Stanford CS 155 Spring 2014 Alex Stamos CISO, Yahoo

CISO at Yahoo! founded Artemis Internet (.secure and.trust) 2004 – co-founded iSEC Partners Berkeley BS EECS ‘01 Your humble narrator

Who is looking for security bugs? Bug Finding Techniques Sample of real bugs found in the wild Bug Finding as Warfare I’m in love with security; whatever shall I do? Agenda

Who looks for security bugs? Engineers Criminals Security Researchers Pen Testers Governments Hacktivists Academics

Goals: Find as many flaws as possible Reduce incidence of exploitation Thoroughness: Need coverage metrics At least find low-hanging fruit Access: Source code, debug environments, engineers Money for tools and staff Engineers (create and find bugs)

People care about features, not security (until something goes wrong) Engineers typically only see a small piece of the puzzle “OMG PDF WTF” (Julia Wolf, 2010) How many lines of code in Linux ? How many lines in Windows NT 4? How many in Adobe Acrobat? Engineering challenges

People care about features, not security (until something goes wrong) Engineers typically only see a small piece of the puzzle “OMG PDF WTF” (Julia Wolf, 2010) How many lines of code in Linux ? 8 – 12.6 million How many lines in Windows NT 4? million How many in Adobe Acrobat? 15 million Engineering challenges

Goals: Money (botnets, CC#s, blackmail) Stay out of jail Thoroughness: Reliable exploits Don’t need 0-days (but they sure are nice) Access: Money Blackbox testing Criminals

Goals: Column inches from press, props from friends Preferably in a trendy platform Thoroughness: Don’t need to be perfect, don’t want to be embarrassed Access: Casual access to engineers Source == Lawyers Security Researchers

Goals: Making clients and users safer Finding vulns criminals would use Thoroughness: Need coverage Find low-hanging fruit Find high impact vulnerabilities Don’t fix or fully exploit Access: Access to Engineers Access to Source Permission Pen Testers

Goals: Attack/espionage Defend Thoroughness: Reliable exploits Access: Money Talent Time Governments

Goals: Doing something “good” Stay out of jail Thoroughness: Reliable exploits Don’t need 0-days Access: Talent Plentiful targets Hacktivists

Goals: Finding common flaws and other general problems Developing new crypto Make something cool and useful Make everyone safer Thoroughness: Depth in area of research Access: Creating new things Blackbox Academics

Bug Finding Techniques

Black Box Bug Finding Exercise Manual manipulation Fuzzing Process hooking Watch for response Process stalking Debugging Emulation Determine exploitability Disassembly Debugging Basic goal is to exercise all states of software while watching for a response that indicates vulnerability

Fuzzing

“Smarter Fuzzing” Record or implement path through gating functions Utilize knowledge of protocol or file format Use process hooking

Debugging

Reverse Engineering Decompilation Often used for semi-compiled code.Net CLR Java Flash Can work with C++ w/ symbols Disassembly 1:1 matching with machine code Modern disassemblers allow for highly automated analysis process Protocol Reverse Engineering

Disassembly - IDA Pro

Reversing Patches - BinDiff

Defeating Black Box Bug Analysis Many programs include anti-debug functionality Check PDB System calls, monitor process space Throw INTs, test for catch Timing tests Anti-Reversing Dynamic Unpacking Pointer Arithmetic Encrypted and obfuscated function calls

Anti-Anti-Debug - Snitch

Snitch Output on WMP Potential break-point debugger check at 0x4bf9f889 (blackbox.dll) Exception handler 1 is at 0x4bf9fe71 (blackbox.dll) Exception handler 2 is at 0x7c839ac0 (kernel32.dll) Potential break-point debugger check at 0x4bf9f9fc (blackbox.dll) Exception handler 1 is at 0x4bf9fe71 (blackbox.dll) Exception handler 2 is at 0x7c839ac0 (kernel32.dll) Potential break-point debugger check at 0x4bf9f889 (blackbox.dll) Exception handler 1 is at 0x4bf9fe71 (blackbox.dll) Exception handler 2 is at 0x7c839ac0 (kernel32.dll) Potential break-point debugger check at 0x4bf9f889 (blackbox.dll) Exception handler 1 is at 0x4bf9fe71 (blackbox.dll) Exception handler 2 is at 0x7c839ac0 (kernel32.dll) Potential break-point debugger check at 0x4bf9f889 (blackbox.dll) Exception handler 1 is at 0x4bf9fe71 (blackbox.dll) Exception handler 2 is at 0x7c839ac0 (kernel32.dll) Potential OutputDebugString debugger check at 0x7c812aeb Module: \Device\HarddiskVolume1\WINDOWS\system32\kernel32.dll Potential break-point debugger check at 0x4df75f36 (drmv2clt.dll) Exception handler 1 is at 0x4dfda68e (drmv2clt.dll) Exception handler 2 is at 0x7c839ac0 (kernel32.dll)

White Box Bug Finding Black Box techniques always work better with more context More quickly triage flaws Patch flaws much faster Analysis can start with source code Look at sensitive areas Use lexical analysis to give pointers Flawfinder RATS Use semantic analysis Coverity Fortify Most White Box techniques also increase false positive count

All are looking for the similar things: vulnerable systems Let’s dive in and look at vulns that we all look for Overall Goals

Sample of bugs found in the wild by us

Wild bug 1: (session management)

Sellers can post/modify goods PostItem(description, price): sellers post items ModifyPrice(itemID, newPrice): used by sellers to modify item prices Buyers can purchase goods ViewItem(itemID): used by the web app when potential buyers click on an item PurchaseItem(itemID): used during purchase flow What’s a good place to look for a vuln? Wild bug 2: (commerce)

Flaw: Access controls didn’t verify itemID is tied to the authenticated user (only enforced by UI) Impact: Shop for free Wild bug 2: (commerce)

Administrative page (internal) could monitor usage statistics through a web application Heaviest users (username and actual name) Load of services Wild bug 3: (server monitor)

Flaw 1: Actual name wasn’t sanitized when gathering statistics (only the username is sanitized) Actual name reappeared on the monitor page Try to inject code on the admin page Wild bug 3: (server monitor)

Challenge 1: must create a valid JSON object (a quoted string name/value pair object) Challenge 2: can’t use capitalized characters Challenge 3: do something awesome Wild bug 3: (server monitor)

Challenge 1: must create a valid JSON object (a quoted string name/value pair object) Challenge 2: can’t use capitalized characters Challenge 3: do something awesome Flaw 2: CSRF (doing an action as the logged in admin) Actual Name: \" onmouseover=\"$.get(‘ ')\" Wild bug 3: (server monitor)

Flaws: Tried to ignore actual name, but added it back in Relied on insufficient input filtering and output encoding Exploited the application’s vulnerability to CSRF Impact: bridging the gap into the intranet Vulnerabilities often need to be combined before exploit Wild bug 3: (server monitor)

void attachSuffix(char *userinputprefix, size_t inputSize) { char *withSuffix; withSuffix = malloc(inputSize + 2); if (withSuffix == NULL) { //meh, don’t care that much return; } memcpy(withSuffix, userinputprefix, inputSize); withSuffix[inputSize] = ‘.’; withSuffix[inputSize + 1] = ‘\n’; … } Wild bug 4: (operating system)

Flaw: Integer overflow into heap overflow Impact: memory corruption or potential code execution Wild bug 4: (operating system)

Some crazy person decided there should be double spaces after periods*. Pseudo-Code: Loop through the text byte by byte. If a period and a single space (followed by a non-space character) is encountered in an text, do the following: 1. Allocate a larger buffer if there isn’t room in the existing one (custom memory management) 2. memmove() the buffer following the “. “ one byte over 3. Write an additional space character in the vacated spot 4. Loop back to #1 until entire text is processed * That person is terrible and enforcing “grammar rules” from the age of typewriters. Wild bug 5: (forum text parser)

What’s the worst case runtime for parsing a text? Wild bug 5: (forum text parser)

What’s the worst case runtime for parsing a text? O(n^2) What happens if you send in a text of only “. “? Wild bug 5: (forum text parser)

What’s the worst case runtime for parsing a text? O(n^2) What happens if you send in a text of only “. “? DoS (asymmetric effort between attacker and server) Wild bug 5: (forum text parser)

Bug Finding as Warfare

Innovations in warfare always decrease the cost for later adopters. The Trickle Down Effect

How about with cyber warfare? Mid-2000’s Nation State APT: Spear-phish Exploit tied to intelligence on AV Active Directory attacks to spread horizontally Access production data via internal interfaces The Trickle Down Effect

Well, maybe not that scary…

Most public example of an “Advanced Persistent Threat” Advanced = 0-day custom malware Persistent = Slow and careful, non-financially motivated Hit at least 35 US companies in , five are clients Operation Aurora

Aurora Attack Code function window :: onload () { var SourceElement = document.createElement ("div"); document.body.appendChild (SourceElement); var SavedEvent = null; SourceElement.onclick = function () { SavedEvent = document.createEventObject (event); document.body.removeChild (event.srcElement); } SourceElement.fireEvent ("onclick"); SourceElement = SavedEvent.srcElement; }

Use after free vulnerability (MS – Remote Code Execution in IE 5-8) Memory typically has a reference counter (how many people have a handle to me?) Improper reference counter allowed Javascript to still reference a function in a freed block of memory Free memory Heap spray attack code (likely it gets written to the freed block because of how IE memory management works) Call function Fairly reliable code execution Operation Aurora

Heap block function window :: onload () { var SourceElement = document.createElement ("div"); document.body.appendChild (SourceElement); var SavedEvent = null; SourceElement.onclick = function () { SavedEvent = document.createEventObject (event); document.body.removeChild (event.srcElement); } SourceElement.fireEvent ("onclick"); SourceElement = SavedEvent.srcElement; }

Operation Aurora Heap block function window :: onload () { var SourceElement = document.createElement ("div"); document.body.appendChild (SourceElement); var SavedEvent = null; SourceElement.onclick = function () { SavedEvent = document.createEventObject (event); document.body.removeChild (event.srcElement); } SourceElement.fireEvent ("onclick"); SourceElement = SavedEvent.srcElement; }

Heap Spray! Create a bunch of elements with attack code and then free them (attack code gets written to lots of heap blocks) IE Small Block Manager Reuses memory pages Call the event pointing to freed memory Code execution! Operation Aurora Attack code

Valuable exploit! How was it used? Social Engineering (get someone to click a link), almost always the weakest link Escalate privileges (cached credentials) Spread (Active Directory, brute force attack) Gather (source code, financial data) Exfiltration (to China, out of intranet on Christmas) Operation Aurora

Advanced Persistent Threat Advanced attackers with talent (zero days) and time (months or years) Targeted attacks (not just going after the vulnerable) Non-traditional attacks, likely hard to monetize Whodunit? Operation Aurora

[ worm [ rootkit [ rootkit [ sabotage ] ] ] ] Five zero-day vulnerabilities Two stolen certificates Almost surgically targeted Eight propagation methods Partridge in a malware pear tree Stuxnet

Mixed MS Windows environment = Redundant Not exploiting memory corruption = Reliable Target: Iranian air-gapped networks operating centrifuges to enrich nuclear material (Natanz) How can you get a foot in the door? USB keys The Target

Zero-Day* Vulnerabilities: MS (Shell LNK / Shortcut) MS (Print Spooler Service) MS (Win32K Keyboard Layout) MS (NetPathCanonicalize()), (Patched) MS (Task Scheduler) CVE (Siemens SIMATIC Static Password) USB Vulnerability

You know, shortcuts and such Where does the icon come from? Loaded from a CPL (Control Panel File) specified by the user A CPL is just a DLL USB keys have attack DLL and a shortcut referencing the DLL Plugging in the USB stick leads to arbitrary code execution MS (Shell LNK/Shortcut)

Flaw: we should run a user-specified DLL to display an icon for a shortcut?! Pop Quiz: Which techniques that we have discussed could lead to discovery of this flaw? A) Fuzzing B) Disassembly C) Debugging D) BinDiff MS (Shell LNK/Shortcut)

I Love Security, What’s Next? Ethics in security Possible Careers

Ethics in Security Big ethical debates used to be: Responsible vs Full Disclosure

Ethics in Security Big ethical debates used to be: Responsible vs Full Disclosure Debate has shifted to: Disclosure vs Selling Weapons

Careers in Security Shape your job around your ethical standpoint, not vice versa

Careers in Security Shape your job around your ethical standpoint, not vice versa Write security relevant software

Careers in Security Shape your job around your ethical standpoint, not vice versa Write security relevant software Write (more) secure software

Careers in Security Shape your job around your ethical standpoint, not vice versa Write security relevant software Write (more) secure software Be a criminal

Careers in Security Shape your job around your ethical standpoint, not vice versa Write security relevant software Write (more) secure software Be a criminal Academia

Careers in Security Shape your job around your ethical standpoint, not vice versa Write security relevant software Write (more) secure software Be a criminal Academia Pen testing!

Go into a big company blindly Start your own company and think this is going to happen What not to do…

Always go into a meeting knowing what you want the outcome to be Ask for a small raise after an offer Common Stock is for Commoners Be part of the product, not the plumbing Career Tips

@alexstamos Questions?