What Do You Mean My Appsec Tools Don't Work on Apis?

What Do You Mean My Appsec Tools Don't Work on Apis?

What do you mean my appsec tools don’t work on APIs?!! Jeff Williams LASCON @planetlevel 1 A HISTORY OF APPLICATION SECURITY AUTOMATION Development (find vulnerabilities) Operations (block attacks) SAST DAST WAF IDS/IPS (Static (Dynamic (Web Application (Intrusion Detection/ AppSec Testing) AppSec Testing) Firewall) Prevention System) IAST RASP (Interactive (Runtime Application AppSec Testing) Self-Protection) Unified Agent IAST and RASP 2 *EVERYONE* USES APIS n=1374 How long has your organization been providing or developing APIs? *SmartBear State of API 2016 Survey 3 UBER 4 APIS ARE THE NEW “HIDDEN FIELD” Automated Business Access Capabilities Account Hijacking Direct Object References mobile code Corruption thing sql APIs desktop nosql Injection server Denial of Service files Information Theft … actions Similar threats, similar vulnerabilities – testing is all different 5 WHAT TECHNIQUE SHOULD YOU USE TO TEST APIS? Pentest Code Review Dynamic (DAST) Static (SAST) Proxy JavaSnoop Instrumentation (IAST) Client(s) API(s) ? 6 VERIFYING API SECURITY - SIX PROBLEMS 1. Protocols 2. Data Parsers Why is automated verification of 3. API Specifications APIs different than plain old 4. Frameworks and Data Flow web applications? 5: AuthN and AuthZ 6: Futures and Promises 7 PROBLEM 1: PROTOCOLS • ProtocoL couLd be muLtipLe nested protocoLs, or even custom protocoL – Websocket, XMPP, AMQP, MQTT – Without a Lot of work, we can’t scan, intercept, or bLock custom protocoLs • Intercepting is now reaLLy hard – CouLd spend your whoLe pentest just getting proxy – EspeciaLLy difficuLt with SSL – IOS: Setup reverse proxy, modify trust store, reverse/recompiLe with forward proxy, use iOS kill switch to avoid DNS pinning, etc… 8 GWT TRAFFIC 5|0|12|http://192.168.0.1:9080/gwt_test/|5E2238F4BEC12E99ABC5F1B1D661286C| com.gwttest.client.GreetingService|greetServer|java.utiL.ArrayList/3821976829| com.gwttest.client.CustomObj/8395292932|com.gwttest.client.Person/748395744| PersonName|java.Lang.Integer/374839484|CustomObjParam1|CustomObjParam2| CustomObjParam3|1|2|3|4|2|5|6|5|2|7|200|8|7|200|8|6|9|200|10|11|12|10| 9 PROBLEM 2: DATA PARSERS • DeniaL of Service (DOS) – entity expansion bombs – Billion laughs attack • eXternal Entity (XXE) – DOCTYPE causes parser to incLude sensitive data • Server Side Request Forgery (SSRF) – DOCTYPE causes parser to emit maLicious HTTP requests • Untrusted DeseriaLization – DeseriaLizing arbitrary cLasses enables remote code execution (RCE) • Standard: URL, JSON, GWT, seriaLized objects, etc… • Custom 10 DYNAMICALLY SELECTED PARSERS 11 PROBLEM 3: API SPECIFICATIONS • Can your tooL understand the API? – RMI, CORBA, IDL – WSDL, WADL, DTD, SLate – Swagger, Blueprint, RAML – Annotations Reverse – None? Engineer Specification? Generate • What do you send? Interface? – How do you make API run? • Most specifications don’t teLL you anything about security 12 SWAGGER 13 PROBLEM 4: FRAMEWORKS OBSCURE DATA/CONTROL FLOW Apache Axis Apache Wink Apache Axis2 Apache Tuscany Apache CXF Cuubez Jersey Everrest Web Services Interoperability Technology RESTX Web Services Invocation Framework RestExpress XFire became Apache CXF restSQL XML Interface for Network Services Sparkjava JAX-RS Retrofit JAX-WS Swagger Spring WS Spring Web MVC Sun Metro Jooby Restfulie Ninja Restlet Jodd Dropwizard (Jetty, Jersey, Jackson) Jhipster Jackson Javalite RESTEasy Ratpack Play Vert.x 14 AUTOBINDING The calls to request.getParameter() and other untrusted sources are no longer in ? the source code acct-balance: Long anywhere! 15 ------INTERMISSION------ A HISTORY OF APPLICATION SECURITY AUTOMATION Development (find vulnerabilities) Operations (block attacks) SAST DAST WAF IDS/IPS (Static (Dynamic (Web Application (Intrusion Detection/ AppSec Testing) AppSec Testing) Firewall) Prevention System) IAST RASP (Interactive (Runtime Application AppSec Testing) Self-Protection) Unified Agent IAST and RASP 17 HOW DO YOU KNOW? OWASP TO THE RESCUE… OWASP Benchmark • Extensive test suite to measure appsec tools • Same tests for SAST, DAST, IAST, {WAF, RASP} • Scientifically test capabilities of tools Sponsored by DHS 18 THE OWASP BENCHMARK PROJECT Vulnerability True False Category Vulnerabilities Vulnerabilities 21,041 test cases 1 Command Injection 1802 906 2 Cross Site Scripting 1540 1909 TP and FP 3 Insecure Cookie 201 215 4 LDAP Injection 521 215 Free and open 5 Path Traversal 1706 924 6 SQL Injection 2297 1232 7 Trust Boundary Violation 505 220 Totally 8 Weak Encryption Algorithm 720 720 reproducible 9 Weak Hash Algorithm 714 707 10 Weak Random Number 1612 2028 11 XPath Injection 217 130 This is the easy Totals 11835 9206 easy stuff… https://www.owasp.org/index.php/Benchmark 19 FREE, OPEN, AND REPRODUCIBLE FOR ANYONE 1. Test Suite Expected Source Code Running App Results SAST DAST IAST Report(s) 2. Scorecard Findbugs AppScan Dynamic Contrast Report(s) HP Fortify Burp Suite Pro Synopsys Seeker Report(s) Generator (Actual PMD OWASP ZAP Report(s)Tool (ActualResults) IBM AppScan Source Arachni Reports(Actual Veracode Acunetix Results) with(ActualResults) CheckMarx Rapid7 AppSpider Results) Synopsys Coverity HP WebInspect Actual Parasoft WhiteHat Results 3. Benchmark SonarQube Netsparker Scorecard(s) Google Skipfish w3af 20 OWASP BENCHMARK SCORING Ideal AppSec Tools It’s trivial to write a tool that reports everything Every false alarm costs an organization the opportunity to eliminate real vulnerabilities It’s trivial to write a tool that reports nothing 21 THE OWASP BENCHMARK IS WORKING • The resuLts are fascinating… – WiLdLy varying resuLts for different tooLs – Some tooLs are amazing at certain things – Some tooLs have inexpLicabLe weaknesses • Driving improvement… – Fortify, Checkmarx, Contrast, Arachni, ZAP, FindSecBugs, and SonarQube have already made improvements to their tools 22 ADDING API TEST CASES TO OWASP BENCHMARK Vulnerability True False Category Vulnerabilities Vulnerabilities 1 Command Injection 56 56 We are 2 Insecure Cookie 16 16 contributing over 3 LDAP Injection 16 16 1,100 new API test 4 Path Traversal 56 56 cases to the 5 SQL Injection 116 116 OWASP 6 Trust Boundary Violation 20 60 Benchmark Project 7 Weak Encryption Algorithm 64 64 8 Weak Hash Algorithm 64 64 Total lines: 132,451 9 Weak Random Number 160 128 10 XPath Injection 8 8 No XSS Totals 576 584 23 EXAMPLE API TEST CASE 24 PRELIMINARY RESULTS STATIC TOOL 1 Total vulnerabilities reported: 3,393 25 PRELIMINARY RESULTS STATIC TOOL 2 Total vulnerabilities reported: 560,000 26 CONTRAST ANALYZES APIS FROM THE INSIDE Your application stack All agents report to Contrast Contrast TeamServer to protect the entire Custom Code Agent application portfolio in parallel Libraries Frameworks Runtime Contrast IAST/RASP Agent instruments your application with sensors that protect against both vulnerabilities and attacks 27 DETECTING AND BLOCKING BOTH ATTACKS AND VULNERABILITIES Sensors woven into running application Developer Business SQL Tester Controller Validation Session Data Layer Logic API Database User Attacker ✘ Vulnerability? HTTP Validation Data Data Escaping ✓ Query Request Tags Tracking Parsing Tags ✓Attack? Security context assembled within Contrast Agent 28 ACCURACY: IAST/RASP HAS AN UNFAIR ADVANTAGE IAST/RASP provideSoftware full visibility is a black into box. running application SAST Runtime Data Software Code Libraries DAST Flow Architecture HTTP Runtime Server Frameworks WAF Traffic Control Flow Configuration Backend Configuration Platform Etc… IAST/RASP Connections Data Runtime 29 PRELIMINARY RESULTS CONTRAST Total vulnerabilities reported: 576 30 KEY TAKEAWAYS • APIs are a large and increasing part of your attack surface – Legacy SAST and DAST tools don’t work on APIs – ManuaL penetration testing and code review don’t work on APIs • Are you sure your APIs are protected? • Contrast’s instrumentation-based approach is effective – Both traditionaL web appLications and APIs • Use the OWASP Benchmark Project when choosing tooLs 31 THANK YOU http://contrastsecurity.com Jeff Williams [email protected] @planetlevel 32 33 SOFTWARE TRENDS CHALLENGING SAST/DAST/WAF Explosive growth in Microservices, Rapidly growing High speed libraries and APIs, REST/XML use of cloud and software frameworks services containers development Libraries Services Cloud Agile SAST can’t handle SAST and DAST WAF can’t handle SAST, DAST, and scale and can’t handle API infrastructure WAF all require complexity of and web service deployment pace experts in the supply chain complexity and complexity critical path 34 PROBLEM 4: DATA FLOW • Data fLow is criticaL! – Primary cause of missed vuLnerabiLities and faLse positives – JSON -> parser -> binding -> bean -> query -> SQL Injection – Websocket -> byte[] -> custom parser -> fiLename -> Path TraversaL • CompLex data fLow is hard to track – Sources, sinks, and propagators are now deep in Libraries – Every framework works differentLy • TooLs – Instrumentation (IAST) has highLy accurate data flow, regardLess of frameworks 35 ABUSING URLS • Authentication http://user:[email protected]/foo/bar • HTTP Parameter Pollution (HPP) • Faking the method with _method parameter • NoSQL REST APIs foLLow their schema • Every service has its own approach * http://www.slideshare.net/DinisCruz/res-ting-on-your-laureLs-wiLL-get-you-powned4-3 36 DIFFERENCE 5: AUTHENTICATION AND AUTHORIZATION • Many techniques… – HTTP BASIC authentication over HTTPS – Cookies and session management – Token in HTTP headers (e.g. OAuth 2.0) – Query Authentication with additionaL signature parameters • Often custom impLementation • TooLs – AlL tooLs require custom auth’n and auth’z ruLes 37 DIFFERENCE 6: FUTURES AND PROMISES • APIs are far more LikeLy to take advantage of concurrency – Netty, PLay, GrizzLy are aLL heaviLy multithreaded – Adds compLexity to controL and data fLows • TooLs – Dynamic (DAST) and Interactive (IAST) tooLs avoid these problems 38.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    38 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us