Hunting Vulnerabilities with Graph Databases



Similar documents
Mining for Bugs with Graph Database Queries

Modeling and Discovering Vulnerabilities with Code Property Graphs

Linux Kernel. Security Report

Ching-Yung Lin, Ph.D. Adjunct Professor, Dept. of Electrical Engineering and Computer Science IBM Chief Scientist, Graph Computing. October 29th, 2015

! E6893 Big Data Analytics Lecture 9:! Linked Big Data Graph Computing (I)

Dynamic Behavior Analysis Using Binary Instrumentation

CSE 504: Compiler Design. Data Flow Analysis

Defense in Depth: Protecting Against Zero-Day Attacks

How graph databases started the multi-model revolution

Bypassing Memory Protections: The Future of Exploitation

POACHER TURNED GATEKEEPER: LESSONS LEARNED FROM EIGHT YEARS OF BREAKING HYPERVISORS. Rafal Wojtczuk

SAF: Static Analysis Improved Fuzzing

Lecture 9. Semantic Analysis Scoping and Symbol Table

Understanding Infrastructure as Code. By Michael Wittig and Andreas Wittig

Sandbox Roulette: Are you ready for the gamble?

Using Eclipse CDT/PTP for Static Analysis

Obfuscation: know your enemy

An Efficient Black-box Technique for Defeating Web Application Attacks

The Need for Fourth Generation Static Analysis Tools for Security From Bugs to Flaws

Korset: Code-based Intrusion Detection for Linux

Improving Application Security with Data Flow Assertions

Static Taint-Analysis on Binary Executables

Visualizing Information Flow through C Programs

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Unix Security Technologies. Pete Markowsky <peterm[at] ccs.neu.edu>

How To Trace

Penetration Test Report

Secure Software Programming and Vulnerability Analysis

A Comparison Of Shared Memory Parallel Programming Models. Jace A Mogill David Haglin

Chucky: Exposing Missing Checks in Source Code for Vulnerability Discovery

WHITEPAPER ON SAP SECURITY PATCH IMPLEMENTATION Helps you to analyze and define a robust strategy for implementing SAP Security Patches

File Management. Chapter 12

Protection, Usability and Improvements in Reflected XSS Filters

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

Security of IPv6 and DNSSEC for penetration testers

ERNW Newsletter 51 / September 2015

This presentation explains how to monitor memory consumption of DataStage processes during run time.

Improving Application Security with Data Flow Assertions

Web Application Security Payloads. Andrés Riancho Director of Web Security OWASP AppSec USA Minneapolis

Precise XSS Detection with Static Analysis using String Analysis

I. INTRODUCTION. International Journal of Computer Science Trends and Technology (IJCST) Volume 3 Issue 2, Mar-Apr 2015

Software Metrics in Static Program Analysis

Physical Data Organization

Braindumps.C questions

Applying Clang Static Analyzer to Linux Kernel

Integrating VoltDB with Hadoop

Oracle Big Data Spatial & Graph Social Network Analysis - Case Study

Making Dynamic Memory Allocation Static To Support WCET Analyses

Integrated Network Vulnerability Scanning & Penetration Testing SAINTcorporation.com

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

Security Vulnerabilities in Open Source Java Libraries. Patrycja Wegrzynowicz CTO, Yonita, Inc.

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

The Leader in Cloud Security SECURITY ADVISORY

How to Sandbox IIS Automatically without 0 False Positive and Negative

ProTrack: A Simple Provenance-tracking Filesystem

Lambda Architecture. Near Real-Time Big Data Analytics Using Hadoop. January Website:

Web Application Security

Software Defined Networking What is it, how does it work, and what is it good for?

Textual Modeling Languages

Comprehensive Security for Internet-of-Things Devices With ARM TrustZone

The Native AFS Client on Windows The Road to a Functional Design. Jeffrey Altman, President Your File System Inc.

Cross Site Scripting (XSS) and PHP Security. Anthony Ferrara NYPHP and OWASP Security Series June 30, 2011

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

Dissecting and digging application source code for vulnerabilities

DFW INTERNATIONAL AIRPORT STANDARD OPERATING PROCEDURE (SOP)

Automating Security Testing. Mark Fallon Senior Release Manager Oracle

RIPS - A static source code analyser for vulnerabilities in PHP scripts

Transparent Monitoring of a Process Self in a Virtual Environment

Databases and Information Systems 1 Part 3: Storage Structures and Indices

RED HAT DEVELOPER TOOLSET Build, Run, & Analyze Applications On Multiple Versions of Red Hat Enterprise Linux

Implementation of Web Application Firewall

Visualization of C++ Template Metaprograms

PERFORMANCE TOOLS DEVELOPMENTS

Optimizing compilers. CS Modern Compilers: Theory and Practise. Optimization. Compiler structure. Overview of different optimizations

Introduction to Big data. Why Big data? Case Studies. Introduction to Hadoop. Understanding Features of Hadoop. Hadoop Architecture.

Lecture 2 CS An example of a middleware service: DNS Domain Name System

REAL TIME OPERATING SYSTEM PROGRAMMING-II: II: Windows CE, OSEK and Real time Linux. Lesson-12: Real Time Linux

Secure Programming with Static Analysis. Jacob West

Web Vulnerability Assessment Report

SLURM Resources isolation through cgroups. Yiannis Georgiou Matthieu Hautreux

MCAFEE FOUNDSTONE FSL UPDATE

Check list for web developers

OWASP OWASP. The OWASP Foundation Selected vulnerabilities in web management consoles of network devices

Static Analysis. Find the Bug! : Analysis of Software Artifacts. Jonathan Aldrich. disable interrupts. ERROR: returning with interrupts disabled

Software security assessment based on static analysis

Overview on Graph Datastores and Graph Computing Systems. -- Litao Deng (Cloud Computing Group)

COMPSCI 314: SDN: Software Defined Networking

How To Fix A Snare Server On A Linux Server On An Ubuntu (Amd64) (Amd86) (For Ubuntu) (Orchestra) (Uniden) (Powerpoint) (Networking

Robust Defence against XSS through Context Free Grammar

Leak Check Version 2.1 for Linux TM

Transcription:

Hunting Vulnerabilities with Graph Databases Fabian fabs Yamaguchi Nico Golde (Qualcomm) INBOT 14 GEORG-AUGUST-UNIVERSITÄT GÖTTINGEN

CVE-2013-6381: qeth buffer overflow in snmp ioctl 2

CVE-2013-6381: qeth buffer overflow in snmp ioctl First arg of copy_from_user propagates to third arg of memcpy without being checked. 3

CVE-2013-6381: qeth buffer overflow in snmp ioctl Goal: make searching for bugs as easy as talking about them. 4

Building a Bug Search Engine» It s only really useful it it s generic enough to express lots of different kinds of bugs» We want to be able to query the database for» What the code looks like (syntax)» Statement execution order (control flow)» How data flows through the program (data flow)» Long story short: We built it, let s talk about it. 5

How compilers analyze syntax: ASTs 6

How compilers analyze control flow 7

How compilers analyze data flow: dependence graphs 8

Merge: Code Property Graphs 9

Graph databases! Big Data! Cloud-era!» Designed to store social networks 10 From: http://markorodriguez.com/2011/08/03/on-the-nature-of-pipes/

GraphDBs: Not limited to storage of useless crap» You can store code property graphs in graph databases 11

Overview of the System (Joern) Source Code Robust Parser Query Response 12

Querying the Database: Sending in the Gremlin» Imperative language to traverse graphs by Marko Rodriguez» Turing complete, embedded groovy» Feels functional» Runs on top of Blueprints» Traversals» Find starting nodes using an index» Describe how to walk the graph from the starting node by chaining elementary traversals ( pipes )» Return all nodes reached 13

Gremlin Chaining Pipes» A pipe maps sets of nodes to new sets of nodes» Pipes are chained to describe traversals in the graph» Chained pipes can be encapsulated in custom pipes 14 From: http://markorodriguez.com/2011/08/03/on-the-nature-of-pipes/

>> g.v(1).out( knows ).name vadas, josh >> g.v(1).out( knows ).filter{ it.age > 30}.name josh >> g.v(1).out().loop(1){ it.loops < 2}.name ripple Gremlin in a Nuttshell 15

Custom steps Basis for code analysis with Gremlin Gremlin.defineStep( twohopsaway, [Vertex,Pipe], { _().out().out() }) >> g.v(1).twohopsaway().name ripple 16

Steps for code analysis: python-joern» Start node selection:» getargs, getparameters, getassignments» Elementary AST-steps» children(), parents(), ithchild(), astnodes()» Node-specific utility steps for ASTs» calltoithargument(), assignmenttolval(),» Data flow and control flow steps» sources(), definitions(), unsanitized(), paths()» A language for bug description 17

Simple example: multiplications inside args to malloc $ echo "getarguments('malloc', '0').astNodes().filter{it.type == 'MultiplicativeExpression'}.code lookup.py -g» Syntax-only:» Get all first arguments to malloc» Get all nodes of trees rooted at these (astnodes)» Select only multiplicative expressions» Get rid of sizeof» Pipe to lookup.py of joern-tools 18

Building block for tainting The unsanitized pipe» It s possible to build very complex pipes» Inject arbitrary groovy code into the DB!» Meet the pipe unsanitized(sanitizers)» All CFG paths from sources to a sink where» A symbol is propagated from source to sink (data flow)» (No node on the path re-define the symbol)» No node on the path matches a sanitizer-description 19

Determining symbols used and possible sources Gremlin.defineStep('unsanitized', [Vertex, Pipe], { sanitizer, src = { [1]._() }-> _().sideeffect{ dst = it; }.uses().sideeffect{ symbol = it.code }.transform{ dst.producers([symbol]) }.scatter().transform{ cfgpaths(symbol, sanitizer, it, dst.statements().tolist()[0] ) }.scatter().firstelem() })» What this query does» Determine symbols used by a statement» Determine producers of that symbol» Return first element of cfgpaths for (producer,symbol) 20

Determine CFG paths with a functional program cfgpaths = { symbol, sanitizer, src, dst -> _cfgpaths(symbol, sanitizer, src, dst, [:], []) } Object.metaClass._cfgPaths = {symbol, sanitizer, curnode, dst, visited, path -> if(curnode == dst) return [path + curnode] as Set if( ( path!= [] ) && isterminationnode(symbol, sanitizer, curnode, visited)) return [] as Set def X = [] as Set; def x; def children = curnode._().out(cfg_edge).tolist() for(child in children){ def curnodeid = curnode.tostring() x = _cfgpaths(symbol, sanitizer, child, dst, visited + [ (curnodeid) : (visited.get(curnodeid, 0) + 1)], path + curnode) X += x } X } 21

Functional feel cfgpaths = { symbol, sanitizer, src, dst -> _cfgpaths(symbol, sanitizer, src, dst, [:], []) } Object.metaClass._cfgPaths = {symbol, sanitizer, curnode, dst, visited, path -> if(curnode == dst) return [path + curnode] as Set if( ( path!= [] ) && isterminationnode(symbol, sanitizer, curnode, visited)) return [] as Set def children = curnode._().out(cfg_edge).tolist() for(child in children){ def curnodeid = curnode.tostring() } X } X += _cfgpaths(symbol, sanitizer, child, dst, visited + [ (curnodeid) : (visited.get(curnodeid, 0) + 1)], path + curnode) 22

Taking Joern for a spin on the Linux Kernel» Crafted queries for four different types of vulnerabilities» Buffer overflows» Zero-byte allocation» Memory mapping bugs» Memory disclosure» Let s take a look at the buffer overflow examples 23

Query for buffer overflows in write handlers (Joern 0.2) query1 = getfunctionastsbyname('*_write*').getarguments('(copy_from_user OR memcpy)', '2').sideEffect{ paramname = 'c(ou)?nt'; }.filter{ it.code.matches(paramname) }.unsanitized( { it._().or( _().ischeck('.*' + paramname + '.*'), _().codecontains('.*alloc.*' + paramname + '.*'), _().codecontains('.*min.*') )} ).param( '.*c(ou)?nt.*' ).locations() 24

Query for qeth-style buffer overflows (Joern 0.2) query2 = getarguments('(copy_from_user OR memcpy)', '2').filter{!it.argToCall().toList()[0].code.matches('.*(sizeof min).*') }.sideeffect{ argument = it.code; } /* store argument */.sideeffect{ dstid = it.statements().tolist()[0].id; } /* store id of sink */.unsanitized({ it._().or( _().ischeck('.*' + Pattern.quote(argument) + '.*'), _().codecontains('.*alloc.*' + Pattern.quote(argument) + '.*'), _().codecontains('.*min.*') ) }, { it._().filter{ it.code.contains('copy_from_user')} } ).filter{ it.id!= dstid } /* filter flows from node to self */.locations() 25

Profit: Seven 0-days in eleven hits Running queries 1 and 2 26

Search queries for four different types of bugs» 18 zero-days, acknowledged /fixed by developers 27

Thank you! Questions?» Tool:» http://mlsec.org/joern» http://github.com/fabsx00/joern» Fabian Yamaguchi» fabs@goesec.de» http://codeexploration.blogspot.de» Twitter: @fabsx00 28