Bug hunting. Vulnerability finding methods in Windows 32 environments compared. FX of Phenoelit



Similar documents
Peach Fuzzer Platform

The Hacker Strategy. Dave Aitel Security Research

DISCOVERY OF WEB-APPLICATION VULNERABILITIES USING FUZZING TECHNIQUES

Fuzzing in Microsoft and FuzzGuru framework

The Advantages of Block-Based Protocol Analysis for Security Testing

Custom Penetration Testing

ASL IT SECURITY XTREME XPLOIT DEVELOPMENT

Automating Security Testing. Mark Fallon Senior Release Manager Oracle

Tools and Techniques to automate the discovery of Zero Day Vulnerabilities. A.K.A Fuzzing 101

Testing for Security

Exploiting nginx chunked overflow bug, the undisclosed attack vector

Web Application Threats and Vulnerabilities Web Server Hacking and Web Application Vulnerability

Chapter 1 Web Application (In)security 1

*[Bug hunting ] Jose Miguel Esparza 7th November 2007 Pamplona S21sec

Building Applications Using Micro Focus COBOL

Basic Unix/Linux 1. Software Testing Interview Prep

Application Code Development Standards

Introduction to Automated Testing

Format string exploitation on windows Using Immunity Debugger / Python. By Abysssec Inc

The Value of Physical Memory for Incident Response

What is Web Security? Motivation

Out of the Fire - Adding Layers of Protection When Deploying Oracle EBS to the Internet

Web Application Security

Introduction. Figure 1 Schema of DarunGrim2

Using fuzzing to detect security vulnerabilities

Integrating Tools Into the SDLC

Attacking Obfuscated Code with IDA Pro. Chris Eagle

Web Application Penetration Testing

Between Mutual Trust and Mutual Distrust: Practical Fine-grained Privilege Separation in Multithreaded Applications

Job Reference Guide. SLAMD Distributed Load Generation Engine. Version 1.8.2

Bypassing Browser Memory Protections in Windows Vista

Business Application Services Testing

Application Security Policy

3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

Application Security Testing. Erez Metula (CISSP), Founder Application Security Expert

Dongwoo Kim : Hyeon-jeong Lee s Husband

esrever gnireenigne tfosorcim seiranib

What s Cool in the SAP JVM (CON3243)

BlackBerry Enterprise Service 10. Secure Work Space for ios and Android Version: Security Note

Java Program Vulnerabilities

Web App Security Audit Services

Passing PCI Compliance How to Address the Application Security Mandates

The Security Development Lifecycle. OWASP 24 June The OWASP Foundation

Compute Cluster Server Lab 3: Debugging the parallel MPI programs in Microsoft Visual Studio 2005

CS 665: Computer System Security. Network Security. Usage environment. Sources of vulnerabilities. Information Assurance Module

Ivan Medvedev Principal Security Development Lead Microsoft Corporation

To install Multifront you need to have familiarity with Internet Information Services (IIS), Microsoft.NET Framework and SQL Server 2008.

SMTP-32 Library. Simple Mail Transfer Protocol Dynamic Link Library for Microsoft Windows. Version 5.2

Troubleshooting.NET Applications - Knowing Which Tools to Use and When

Using Nessus In Web Application Vulnerability Assessments

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

Skeletons in Microsoft s Closet - Silently Fixed Vulnerabilities. Andre Protas Steve Manzuik

WHITEPAPER. Nessus Exploit Integration

What Happens In Windows 7 Stays In Windows 7

Penetration Testing with Kali Linux

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

Release Notes for Epilog for Windows Release Notes for Epilog for Windows v1.7/v1.8

Web Applications Testing

Tuning WebSphere Application Server ND 7.0. Royal Cyber Inc.

KEN VAN WYK. Fundamentals of Secure Coding and how to break Software MARCH 19-23, 2007 RESIDENZA DI RIPETTA - VIA DI RIPETTA, 231 ROME (ITALY)

Hotpatching and the Rise of Third-Party Patches

Setting up PostgreSQL

SOFTWARE TESTING TRAINING COURSES CONTENTS

Levels of Software Testing. Functional Testing

EVALUATION. WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration COPY. Developer

Application Denial of Service Is it Really That Easy?

FINAL DoIT v.4 PAYMENT CARD INDUSTRY DATA SECURITY STANDARDS APPLICATION DEVELOPMENT AND MAINTENANCE PROCEDURES

Web Application Security

DiskPulse DISK CHANGE MONITOR

11.1 inspectit inspectit

Detecting rogue systems

MatrixSSL Developer s Guide

Software Engineering for LabVIEW Applications. Elijah Kerry LabVIEW Product Manager

Error Codes for F-Secure Anti-Virus for Firewalls, Windows 6.20

Internet Information TE Services 5.0. Training Division, NIC New Delhi

AXL Troubleshooting. Overview. Architecture

How to test and debug an ASP.NET application

Programming Flaws and How to Fix Them

Introduction to Synoptic

I Control Your Code Attack Vectors Through the Eyes of Software-based Fault Isolation. Mathias Payer, ETH Zurich

HP WebInspect Tutorial

Check list for web developers

Java Web Application Security

Defense in Depth: Protecting Against Zero-Day Attacks

Introduction. How does FTP work?

ABSTRACT' INTRODUCTION' COMMON'SECURITY'MISTAKES'' Reverse Engineering ios Applications

A Link Layer Discovery Protocol Fuzzer

IBM Tivoli Composite Application Manager for Microsoft Applications: Microsoft Internet Information Services Agent Version Fix Pack 2.

Secure Software Programming and Vulnerability Analysis

1 Documentation Accessibility

Features Overview Guide About new features in WhatsUp Gold v12

GUI and Web Programming

Put a Firewall in Your JVM Securing Java Applications!

Security Tools - Hands On

Transcription:

Bug hunting Vulnerability finding methods in Windows 32 environments compared FX of Phenoelit

The goal: 0day What we are looking for: Handles network side input Runs on a remote system Is complex enough to potentially contain a significant number of vulnerabilities

The environment Windows NT / 2k / ((2k++)++)++ Closed source binaries NT services Often large binaries Some times forking Application frameworks IIS ISAPIs Large scale frameworks (eg. SAP) Widely used clients

Obstacles Extremely large Win32 API Large, dynamically linked binaries Compiler specifics and optimization Use of library functions in-code Function inlining Vendor specific libraries replacing standard calls Unknown protocols Vendor specific obscurities

Testing methods Manual testing Fuzzing Static analysis Diff and BinDiff Runtime analysis

Manual Testing Using the standard client (or other counterpart) to access the target service Observing the behavior: Valid input Invalid input Timing Network communication Pre-authentication handshakes Common configuration tasks and failures Target administration specifics

Manual Testing [2] What you try to determine: States in the target Reaction to valid input Reaction to invalid input Reaction to changes in timing Information transmitted before and after authentication Runtime environment requirements of the target Default configuration and misconfiguration issues Logging capabilities

Manual Testing [3] Things to look for: Input validation on client side Input in client rejected Input in client accepted but modified before transmission Pre-Authentication client data Hostname Username Certificate content Date/Time strings Version information (Application, OS)

Manual Testing [4] More things to look for: Network protocol structure Dynamic or static field sizes Field size determination Information grouping Numeric 32bit fields Timing Concurent connections Fast sequential connections Length 1 00 00 00 08 41 42 43 44 45 46 47 00 Length 2

Manual Testing [5] - Pros No need for additional tools Becoming familiar with the target Un-intrusive Uncovers client side security quickly Easy correlation between user action and network traffic Takes configuration into account High abstraction level, no need to understand all the internals of the target

Manual Testing [6] - Cons Slow Potentially high learning effort Incomplete coverage only functionality configured and used is tested Often provides only clues where vulnerabilities might be found Proving a vulnerability often requires additional efforts (such as code) High dependence on the tester

Manual Testing [7] Usual findings: Cross Site Scripting / Code & SQL injections Protocol based overflows and integer issues Application logic failures Best suited for: Web applications Java application frameworks Proprietary clients Internet Explorer (and other browsers)

Fuzzing Creating rough clients (or counterparts) to generate a wide range of invalid input Attempts to find vulnerabilities by exceeding the possible combinations of malformed input beyond the boundaries of the original client Observing the behavior: Not as closely as with manual testing Responses are some times inspected Often only crashes are considered

Fuzzing [2] Semi-Manual fuzzing Writing scripts or short programs acting as rough clients Manually changing the code for each test Running the code and evaluating the response Automated fuzzing Writing scripts or programs to itterate through a high number of invalid input Running the code and letting it itterate until the target crashes

Fuzzing [3] What you try to determine Semi-Manual fuzzing Unexpected responses Modified data in the response Changed timing behavior Target crashes Automated fuzzing Target crashes

Fuzzing [4] Semi-Manual fuzzing procedure Get your script to work normally Change fields one at the time Generate output (send data, create file,...) Inspect results Change fields again, depending on results Generate output Repeat last two steps

Example: Symantec PC AnyWhere 10.5 Timing issue with frequent reconnects and initial handshake Fails to synchronize load and unload of a DLL for the tray bar icon DoS: connect, handshake and disconnect about 10 times

Fuzzing [5] Automated fuzzing procedure Define what vulnerabilities you want to look for Create iterator script/program using a fuzzer framework Output data for every vulnerability type you want to test Output data for multiple/combined vulnerabilities Iterate through all combinations Wait until your target crashes Needs a debugger attached to the target in case the vulnerability is hidden by a SEH handling it Issues with forking processes under Win32

Fuzzing [6] - Frameworks SPIKE By Dave Aitel, Immunity Inc Currently version 2.9 Block based fuzzer Written in C Fuzzing programs need to be in C too Rudimentary functions for sending and receiving data, strings and iterations Almost no documentation Comes with a number of demo fuzzing programs

Fuzzing [7] - Frameworks Peach By Michael Eddington, IOActive Currently pre-release state Written in Python (object oriented) Consists of: Generators for static elements or protocol messages Transformers for all kinds of en/decoding Protocols for managing state over multiple messages Publishers for data output to files, protocols, etc. Groups for incrementing and changing Generators Scripts for absctraction of the per-packet operations Documented fully, including examples

Fuzzing [8] - Pros Semi-Manual fuzzing Try-Inspect Process leads to fast findings Same advantages as manual testing Ability to prove the vulnerability Fuzzing script can be promoted to exploit Automated fuzzing Process guarantees known level of coverage Quickly uncovers a wide range of overflow and format string vulnerabilities Effective when many combinations are possible Code reuse for known protocols

Fuzzing [9] - Cons Understanding of the underlying protocol required Incomplete coverage only functionality configured and used is tested Automated Fuzzing Test scripts need to be developed Test scripts need to take potential target specifics into account Tester has to rely on fuzzer Debugger on the target system often required Can hide a bug behind another bug

Fuzzing [10] Usual findings: Application level overflows Format string vulnerabilities Path traversal Best suited for: Services using documented protocols Standard servers: Web, FTP, LDAP, RPC,... Web applications (semi-manual fuzzing) Protocols with many field combinations

Static analysis Disassembly of the target binary in order to find vulnerabilities. Identification of vulnerable code sequences independent of their location In some cases back-translation of the disassembly into a higher level language such as C. Often paired with automatic analysis of calls to known library functions with vulnerability potential

Static analysis [2] Always a manual procedure with aid of several tools Requirements: Binaries of the target Interactive Disassembler (IDA) Library reference for the target Fluent assembly

Static analysis [3] Identification of vulnerable code Find references to functions with vulnerability potential: strcpy(), sprintf(),... Check the call arguments for each reference if they suggest a vulnerability sprintf( buffer, %s,... Check if the data can be influenced sprintf( buffer, %s, user_input ); Find potential limiting factors sprintf( buffer, %s, strlen(user_input)>(sizeof(buffer)-1)? big :user_input);

Static analysis [4] Reverse engineering of lower level protocol handlers Find calls to recv(), recvfrom(), WSArecv(), WSArecvfrom(),... Determine the buffer holding the data Follow the program flow to eventually find the parsing functions Reverse engineer the parsing functions Identify potential for parsing mistakes

Automated Static analysis [5] Code flow analysis Following branches and calls Building a flow graph of the binary or subsections Identifies functions, stack variables Improves reverse engineering Automated library call identification Finds calls to unsafe library functions Output needs to be inspected by reverse engineer Can automatically identify format string vulnerabilities

Static analysis [6] - Pros In depth analysis Finds vulnerabilities in code normally not executed Quickly uncovers most format string vulnerabilities Advanced vulnerability identification Integer overflows and wraps Off-by-one errors Complex combined vulnerabilities Complete coverage of the code inspected

Static analysis [7] - Cons Extremely time consuming Experience and skill required Disassembly is almost never complete Library call and inlinded function identification fails Packed or protected binaries Multiple level indirect calls to dynamic data (especially in C++ or Delphi code) Code flow analysis fails Structures and other advanced data structures hard to handle Not usable for higher level languages (Visual Basic)

Static analysis [8] Usual findings: Protocol level overflows Complex vulnerabilities Integer vulnerabilities Best suited for: Protocol parsers Unknown protocols Code using unsafe functions In depth analysis of critical code sections

Example: Orenosv 0.6.0 HTTP server Combined logging buffer overflow Classic case of multiple sprintf() calls going wrong Remote NT Authority/SYSTEM

Diffing Identification of a vulnerability after it has been found and fixed. The goal here is to identify the fix, in order to find the vulnerability. Reasons: Vendors do not notify the public of an identified vulnerability but fix it silently. Silent vendor fixes don t guarantee security, since the fix itself could be flawed. For various reasons, some still want an exploit for vulnerabilities that are already fixed

Diffing [2] In patches, one needs to first find out what files are modified Single file patches are easily identified Higher number file replacements like in Microsoft hotfixes and Service Packs need to be monitored. Filemon from Sysinternals Killing the update after the unpacking procedure but before the copy Static analysis of the patch

Diffing [3] Comparing two versions of a binary by hand takes very long Find functions that are at the same address Compare the number of functions Compare the size of functions Automated binary diffing is far superior Graph based fingerprinting of functions Automated comparsion Can also be used to port function names Check http://www.sabre-security.com/ for magic

Runtime analysis Running the target in a debugging environment and inspecting the code during execution. Identification of vulnerable code sequences using disassembly, much like static analysis. Observation of the target code rather than completely reverse engineering it.

Runtime analysis [2] Manual process with the aid of debugging tools Requirements: Functioning version of the target Debugger Fluent assembly Library reference for the target system

Phenoelit (dum(b)ug) core Complete and fully open source Win32 debugger core C++ class architecture PE parsing, disassembly, thread handling, breakpoints Instant debugger creation using a few lines of code http://www.phenoelit.de/dumbbug/

Runtime analysis [3] Data follow procedure Identify functions that produce incoming data, such as recv() and break there Follow the data through the program flow to identify parsing functions Following the data can be supported by memory breakpoints Reverse engineer the parsing function, looking for mistakes in the programming Craft data to trigger the suspected vulnerability and inspect the results

Runtime analysis [4] Code follow procedure Identify functions with vulnerability potential Break every time such a function is executed and inspect the arguments Check the arguments if they suggest a vulnerability in this case Check the arguments if they are user supplied data or derived from it For most functions, this is impractical because of the high number of calls to them Often, only one in 100 calls is relevant

Runtime analysis [5] - Pros Just in time disassembly Correct information at the time of execution Known state of registers Quickly uncovers format string vulnerabilities Advanced vulnerability identification Integer overflows and wraps Off-by-one errors Slightly faster than static analysis, due to skipping of uninteresting code Exception catching

Runtime analysis [6] - Cons Time consuming Skill and experience still required Break-and-Inspect not well suited for frequently called functions Requirements (CPU power, binaries, etc) Timing issues Connection timeout during code inspection Other timing related stuff breaking Detaching of a debugger only in Win2003

Runtime analysis [7] Usual findings: Application level overflows Complex vulnerabilities Integer vulnerabilities Best suited for: All kinds protocol parsers Logging and data processing Code using unsafe functions

Phenoelit (dum(b)ug) ltrace Ltrace for Windows Log calls to any function Before and after states Call conventions Follows forks Stack analysis Format string analysis http://www.phenoelit.de/dumbbug/

Trace defs Trace definitions used to identify arguments of traced functions Native C notation Argument directions Return value or output buffer matching int int cdecl recv( recv( [in] [in] int int socket, [both] char char * buf, buf, [in] [in] int int len, len, [in] [in] int int flags flags ); ); haxor == == int intsprintf( [out] [out] char char * buf, buf, [in] [in] fmtchar * format ); );

Function call tracing Pros: Extremely fast No disassembly Recognition of user supplied data Automagic format string vulnerability detection Cons: Incomplete: only called functions traced Covers only unsafe functions Does not (yet) identify compiled in incarnations of library functions

Example: Orenosv 0.6.0 FTP server Logging buffer overflow sprintf(buffer, %02X,...) calls in a loop going wrong Very hard to identify with static analysis Ignore previous statement if using Halvar s tools Remote NT Authority/SYSTEM

Combining forces Team 1 Fuzzing using Peach and a well designed script Attaching a debugger to catch exceptions Team 2 Call trace using (dum(b)ug) tracer Manual testing using existing client Script for sending suspected overflow data Team 3 Disassembly using IDA Semi-Manual fuzzing according to disassembly

Summary Different vulnerability testing methods are available, each with different properties and areas of application. For quick bug finding, automated methods are best. For thorough analysis, manual methods and static analysis should be preferred.