taintless
play

Taintless Defeating taint-powered protection techniques Abbas Naderi - PowerPoint PPT Presentation

Taintless Defeating taint-powered protection techniques Abbas Naderi (aka AbiusX) Mandana Bagheri Shahin Ramezany Covered Topics y Before We Begin Taintless While you obtain the tools and get ready, well Describing the


  1. Taintless Defeating taint-powered protection techniques Abbas Naderi (aka AbiusX) 
 Mandana Bagheri 
 Shahin Ramezany

  2. Covered Topics y ✓ ✓ Before We Begin Taintless While you obtain the tools and get ready, we’ll Describing the tool, its modes of operations and warm-up our systems. goals. ✓ ✓ Getting To Know Taint Demonstration What is Taint? What types of taint are there? Trying Taintless on a bunch of software, What processes use taint to defeat cyber-attacks? attempting to analyze and bypass their protections and weaknesses. ✓ ✓ Q&A Existing Techniques Studying a select group of candidate taint-based Covering any final thoughts the audience might techniques helps us better understand -and hence have. defeat- taint.

  3. k ❝ if it breaks you, it makes you stronger ❞

  4. ⚡ Before We Begin Let’s warm-up our systems by solving this challenge while you get the tool: You can’t run code on your brain! (Or can you?) 
 http://ideone.com/C7bOrg github.com/abiusx/taintless22 2 (needs2composer) 
 github.com/abiusx/WP:SQLI:LAB 
 github.com/abiusx/WP:SQL:SINK If you solved both challenges, find harder ones on my twitter.com/abiusx

  5. 0 ❝ Data! Data! Data!" he cried impatiently. "I can't make bricks ❞ without clay.

  6. What is Taint? a Sources of Taint + Just like in real life, sources of taint Sick programs behave differently • • are typically people and unexpectedly Applications are designed to work • well with proper input Improper input makes a program • sick

  7. What is Taint? a Tainted Input + User-input to an application is Everybody knows that, nobody • • generally considered tainted does that. Specially on web, were anyone Our forefathers didn’t even know • • can visit! that (Legacy Code) Tainted input needs to be sanitized • before use in the application

  8. What is Taint? a Sinks + Everything entering the application Sinks are important, just like body • • system is categorized as tainted organs, as tainted input aims that (e.g Second order attacks) specific organ. Taint propagates throughout the Sinks are wrapped in taint-based • • program, until it reaches a sink techniques A sink is a [security] critical • operation inside the application (e.g database query)

  9. What is Taint? a Taint Propagation + The more complex a code-base, Taint may totally change form, • • the more possible means of taint typically rendering it harmless, but spreading around sometimes this change morphs it into something dangerous 
 (e.g encrypting an innocent string Just like a virus in our body, taint • into a piece of code) can play hide and seek to bypass all sentinels and filters

  10. Taint Tracking a What is Taint Tracking? + Traditional taint-based technique Typically performed on strings, • • for protecting applications is treating them (or individual known taint tracking characters) as black and white (and sometimes gray) Already available in core at Perl, • Ruby, PHP and many others as String operations throughout the • extensions program propagate the taint Intensive processing, impossible Taint is increased, reduced or • • to accurately model morphed in the process

  11. Taint Tracking a Taint Tracking Example 1 + <?php 
 $x=$_GET[‘input’]; 
 $y=substr($x,0,10); //reduced $z=str_replace($x,”a”,”b”); //modified $w=str_repeat($x,3); //increased mysql_query_(“SELECT * FROM users WHERE username=‘{$y}’”);

  12. Taint Tracking a Taint Tracking Example 2 + <?php 
 $x=$_GET[‘input’]; if ($x*1>0) //its a number mysql_query_(“SELECT * FROM users WHERE userid={$x}”);

  13. Taint Tracking a Sink Analysis + Parses SQL query (or any other Policies define what to do with • • expected data) and marks critical gray areas. (security-intensive) tokens If taint exists in (or conforms) these • tokens, disinfects Easiest disinfectant is exit(-1) •

  14. Taint Tracking a Gray Taint + If an string operation fades tainted data into mixed data, disallowing a one-to- • one mapping (or modeling), gray taint is made Example: 
 • $x=$_GET[‘input’]; 
 $y=preg_replace($x,”(\d).(\d)”,”9$29$19”); 
 $z=md5(“username=‘{$x}’”); $y has gray taint because it’s hard to model regular expression taint • propagation

  15. Taint Tracking a Gray Taint (2) + Example: 
 • $x=$_GET[‘input’]; 
 $y=preg_replace($x,”(\d).(\d)”,”9$29$19”); 
 $z=md5(“username=‘{$x}’”); $z has gray taint because its impossible (infeasible) to model md5 taint • propagation It’s not always impossible for the attacker! •

  16. Taint Tracking a Treating Gray Taint + Whether to consider gray taint as Most solutions claim to handle • • safe or unsafe, is a matter of gray taint well, but non of them threshold. actually do. They just ignore it to make the program work, rather than stop them and break the Thresholds result in false negative • code. and positives Totally in contrast with what our • bodies do!

  17. Taint Tracking a Positive Taint + So far all taint mentioned was Will break the programs more, but • • negative taint, i.e bad is intrinsic to the nature of application (no attacker control) Positive taint is what we know to • be good: Track it and assume • everything else to be bad (just like our bodies)

  18. Taint Tracking a Positive Taint Tracking + Very few solutions for positive taint Hard to model many • • tracking operations e.g Diglossia, Halfond et. al. Impossible to model some • • others They suffer from the same • propagation hardships of negative Typically configured very • taint tracking loosely

  19. 1 ❝ The world is full of obvious things which nobody by any chance ever observes. ❞

  20. Taint Inference 1 Inferring Taint - Since we can’t track taint Way lower accuracy, way more • • accurately, and are bound to simple and fast approximation; why not employ approximation from the start? Instead of tracking taint from • application input to the sink, modeling every organ in its complicated body; inspect the value from time to time, and infer which parts are tainted

  21. Taint Inference 1 Example - <?php 
 • function mysql_query_($query) { 
 $input=$_GET[‘u’]; 
 $len=strlen($input); 
 $match=substr($query, strpos($input,$query),len); 
 if (levenshtein($match,$input)/$len<0.1) exit(-1); 
 } 
 mysql_query_(“SELECT * FROM users WHERE username=‘{$_GET[‘u’]}’ ”);

  22. 
 
 Taint Inference 1 Feasibility - Approximating input/output correspondence seems very easy, but is actually • very computation hungry 
 foreach $query in $queries 
 foreach $input in $inputs 
 $match=approximateFind($input,$query); 
 $distance=stringDistance($match,$input) / length($match) 
 if ($distance>$threshold) die(); 
 O(x L x M x I) 
 N=number of queries, M=number of inputs, L= query size, I = input size

  23. Taint Inference 1 Feasibility (2) - A typical application has 20 Still in the optimum case, a • • queries, and a few inputs. polynomial of power 4 is not very fast. Queries don’t typically grow very • large (at most a few kilobytes), but inputs typically do. Specially when they upload their • files

  24. Taint Inference 1 Positive Taint Inference - All discussed so far regarded Remember, as long as nothing • • negative taint inference, i.e critical is bad, we’re good inferring bad tainted input in the output Not as impossible as positive taint • tracking Positive taint inference finds good • parts of the output, inferring the rest as bad

  25. Taint Inference 1 Taint-Tracking vs Taint-Inference Sink Sink Protected2 Protected2 User2Input User2Input Application Application

  26. p ❝ Detection is, or ought to be, an exact science, and should be treated in the ❞ same cold and unemotional manner.

  27. 
 
 
 Existing Techniques p We will briefly study one sample from each category: - + - + PHP Aspis Diglossia S 3 NTI Negative Taint Positive Taint Negative Taint Positive Taint Tracking Tracking 
 Inference 
 Inference 
 ! (Sekar et. al.) 
 2011 2013 2009 2013 Joza - + Hybrid Taint Inference 
 2014

  28. Existing Techniques p PHP-Aspis = Started as a taint-tracking paper There’s a lot of details on how it • • (should) works and how they modeled everything Turned into a PhD thesis • (Imperial College folks) But it’s not actually used anywhere • (last update 2011) They tried to model every single • function, by re-writing PHP interpreter Can you guess why? • https://github.com/jpapayan/aspis

  29. Existing Techniques p Diglossia = Started as a positive taint-tracking At the sink, critical tokens should • • paper on ACM CCS 2013 be Korean. Keeps track of user inputs, and The paper overcomplicates things • • converts application strings mixed to make the reader feel it’s doing with user-input, on a character by magic, but basically it’s positive character basis (mapping them to taint tracking. Korean) Only works on very simple • Rewrites PHP interpreter operations. •

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend