SlideShare a Scribd company logo
Copyright © 2015, CigitalCopyright © 2016, Cigital
Static Analysis Tools and Frameworks:
Overcoming a Dangerous Blind Spot
Mike Lyman
Senior Consultant
mlyman@cigital.com
https://www.cigital.com/blog/static-analysis-tool-framework-blind-spot/
Copyright © 2016, Cigital
Copyright © 2015, CigitalCopyright © 2016, Cigital
Who am I?
Mike Lyman
• Senior Consultant at Cigital
• mlyman@cigital.com
• 9+ years of software security focus
• 19 years in the security business
• CISSP/CSSLP
• @mlyman87
Copyright © 2015, CigitalCopyright © 2016, Cigital
Who are you?
• Developers?
• Managers?
• Testers?
• Part of a security team?
Are you using static analysis tools?
What are your concerns with these tools?
Copyright © 2015, CigitalCopyright © 2016, Cigital
Agenda
• Intro to static analysis tools
• Static analysis concepts
• Frameworks
• The blind spot
• How to overcome it
• .Net Web API walkthrough
Copyright © 2015, CigitalCopyright © 2016, Cigital
Testing with static analysis tools
is often referred to as Static
Application Security Testing
(SAST).
Copyright © 2015, CigitalCopyright © 2016, Cigital
SAST tools
• Tools that look at source code for certain types of bugs
• As simple as “glorified grep”
• simple pattern recognition
• As complicated as compilers
• control and data flow analysis
• Often a combination of both
• Free and commercially available
Copyright © 2015, CigitalCopyright © 2016, Cigital
SAST concepts
• Taint: data from untrusted sources is considered tainted
• Source: source of data
• Sink: function that consumes data
• Taint flows through the data flows until it is either:
• removed through validation or sanitization
• consumed by a sink
• If taint reaches sink, bad things can happen
• Examples:
• Buffer overflows
• Command injection
• SQL injection
Copyright © 2015, CigitalCopyright © 2016, Cigital
Frameworks
• Speed up development
• Provide a lot of basic functionality
• Allows a focus on core functionality
• Might be completely separate from your language
• Java and Spring
• Might be tightly coupled
• C# and .Net (but with some advanced features that are available
as separate downloads)
Copyright © 2015, CigitalCopyright © 2016, Cigital
The blind spot
Copyright © 2015, CigitalCopyright © 2016, Cigital
The blind spot
• What is going on under the hood?
• Obvious question: Are there security bugs in the framework itself?
• Not so obvious: Do frameworks introduce problems for your code?
• New sources of tainted data?
• New dangerous sinks?
• Pass through functions that pass on or add taint?
• How do the data flows work with the framework?
• Does your SAST tool understand this?
• Using non-framework 3rd party libraries can cause the same issues.
Copyright © 2015, CigitalCopyright © 2016, Cigital
Does your tool know about these issues?
• New frameworks and new versions appearing faster than
we can keep up – can the tool vendor?
• Are there enough users to get the vendor’s attention?
• Even if you have the source code, can the tool trace the
data flows?
• If your static analysis tool cannot see or understand the
framework it cannot report issues – false negatives!
Copyright © 2015, CigitalCopyright © 2016, Cigital
False positives are annoying.
False negatives are dangerous!
False positives are annoying.
False negatives are dangerous!
Copyright © 2015, CigitalCopyright © 2016, Cigital
How do you know you have a problem?
• Penetration testers find code implementation problems
• SAST doesn’t
• Functionality analysis
• What functionality does the framework (or 3rd party library) provide?
• What types of problems can be introduced there or occur there?
• Create vulnerable test cases
• Scan the test cases
• Binary analysis
• Decompile and analyze
• Watch for questions on the tool’s support forums
• Ask the vendor
Copyright © 2015, CigitalCopyright © 2016, Cigital
How do you fix it?
• Teach the tool to handle the issues through custom rules
• May need pre-scan processing
• Supplement with a different tool
• Pressure the vendor
• If you find actual bugs in the framework, report them
Copyright © 2015, CigitalCopyright © 2016, Cigital
.Net Web API
A Walkthrough
Copyright © 2015, CigitalCopyright © 2016, Cigital
The setup
• Customer is creating micro-services based on the .Net
Web API (System.Web.Http.ApiController).
• Penetration testers find code implementation issues.
• SAST doesn’t understand the Web API or asynchronous
calls, despite both being available for years.
• Need to enable SAST tools to find these issues.
Copyright © 2015, CigitalCopyright © 2016, Cigital
Non-live walkthrough
• Code taken from the stub program is created when you
create a new Web API C# application.
• These code snippets don’t necessarily contain security
bugs. They are used to illustrate the discovery method
used to figure out how to get the SAST tool to
understand code derived from the APIController.
• Images of MSIL code taken from ILSpy.
Copyright © 2015, CigitalCopyright © 2016, Cigital
The .Net ApiControl (WebAPI) provides
automatic routing and databinding for HTTP
methods.
Databinding can be simple types (shown
here) or complex custom classes.
Data coming into these controllers via the
automatic routing and databinding is part of
http requests and should be considered
tainted input.
The SAST tool in use does an okay job of
identifying tainted data sources both for
things that followed the Get, Post, etc.
naming conventions and for custom named
methods mapped to HTTP methods (via
attributes).
The job isn’t perfect and needs to be
supplemented with custom rules, especially
after implementing some of the solutions
discussed in the following slides.
Copyright © 2015, CigitalCopyright © 2016, Cigital
Real SAST problems arise with async
methods and awaits. The SAST tool is blind
to problems here. Data coming into these
methods is not identified as tainted data.
The initial instinct is to craft custom rules
looking at C# in these methods. This
approach doesn’t work here.
Since custom rules based on C# don’t work,
more research is necessary to include
examining the assemblies themselves with
ILSpy.
Copyright © 2015, CigitalCopyright © 2016, Cigital
ILSpy can take the assemblies and show you the MSIL and then take the MSIL back to either C# or VB.Net.
The C# version of ChangePassword that comes from the decompiled assembly looks vastly different than
the C# on the previous slide. Since the SAST tool in use looks at the compiled assemblies with its data flow
rules, rather than the original C# source code, it’s now apparent why custom rules based on the original C#
aren’t working.
The compiler replaces the original code in the async method and generates a nested class to implement a
state machine to handle the asynchronous task.
The problems are now occurring in the generated class.
Copyright © 2015, CigitalCopyright © 2016, Cigital
The generated nested class creates a state machine that manages the async call. Most of the work is done
in the MoveNext method (collapsed in the image above) as it steps through the various states until the task
is complete. Analysis shows that this is where a large part of the custom rules effort is needed.
Copyright © 2015, CigitalCopyright © 2016, Cigital
We now know where to look. However…
• It is clear that custom rules need to be built based on the
generated, nested classes. However, they didn’t exist
before compile time.
• A pre-scan step examines the compiled assemblies
using FXCop and Mono.Cecil, and generates custom
rules on the fly.
• The custom rules are used to scan the assemblies with
the SAST tool.
• It still fails to work properly.
Copyright © 2015, CigitalCopyright © 2016, Cigital
Now what?
• The generated classes are nested: private classes with
private methods. The SAST tool appears to ignore them.
• Another pre-scan step is created to use Mono.Cecil to
modify the assemblies by making the generated
methods and classes public.
• The dynamically generated rules start working.
Copyright © 2015, CigitalCopyright © 2016, Cigital
Confirmation
• Test cases are created in C# with known dangerous sinks to
test if the SAST tool works with the custom data source rules.
• Test cases confirm proper data flows are identified from
tainted sources, to the known dangerous sinks, and issues
raised by the tool.
• Due to compiler generated code, this didn’t provide complete
test coverage.
• Test cases are injected directly into the compiled assemblies
using Mono.Cecil and we can confirm that the rules work.
Copyright © 2015, CigitalCopyright © 2016, Cigital
Problem discovery recap
• Gained a deeper understanding of .Net Web APIs and
asynchronous methods.
• Discovered the main tool’s custom rules had to look for
MSIL syntax – not C#.
• Observed that taint sources existed within compiler-
generated classes and methods that SAST couldn’t see.
• Noticed that visibility issues hid problems from SAST tools.
• Private vs. public access modifiers
• Nested compiler created classes
Copyright © 2015, CigitalCopyright © 2016, Cigital
Solutions recap
• Created custom rules based on MSIL syntax.
• Created a pre-scan step to dynamically incorporate custom
source rules based on generated MSIL for classes inherited
from ApiController.
• Created a pre-scan step to modify class and method visibility
in generated assemblies.
• Created test cases in C# to test dynamic rules.
• Created a process to inject MSIL test cases into compiled
assemblies for more complete test coverage.
Copyright © 2015, CigitalCopyright © 2016, Cigital
Questions?

More Related Content

PPTX
Can You Really Automate Yourself Secure
Cigital
 
PDF
The Path to Proactive Application Security
Cigital
 
PPTX
What Good is this Tool? A Guide to Choosing the Right Application Security Te...
Kevin Fealey
 
PPTX
DAST, SAST, Hybrid, Hybrid 2.0 & IAST - Methodology & Limitations
iAppSecure Solutions
 
PDF
Open Source Security for Newbies - Best Practices
Black Duck by Synopsys
 
PDF
SAST vs. DAST: What’s the Best Method For Application Security Testing?
Cigital
 
PDF
Manual Code Review
n|u - The Open Security Community
 
PPTX
Making Security Agile
Oleg Gryb
 
Can You Really Automate Yourself Secure
Cigital
 
The Path to Proactive Application Security
Cigital
 
What Good is this Tool? A Guide to Choosing the Right Application Security Te...
Kevin Fealey
 
DAST, SAST, Hybrid, Hybrid 2.0 & IAST - Methodology & Limitations
iAppSecure Solutions
 
Open Source Security for Newbies - Best Practices
Black Duck by Synopsys
 
SAST vs. DAST: What’s the Best Method For Application Security Testing?
Cigital
 
Making Security Agile
Oleg Gryb
 

What's hot (20)

PDF
FLIGHT WEST 2018 Presentation - Open Source License Management in Black Duck Hub
Black Duck by Synopsys
 
PPTX
Automating Your Tools: How to Free Up Your Security Professionals for Actual ...
Kevin Fealey
 
PDF
FLIGHT WEST 2018 Presentation - Continuous Monitoring of Open Source Componen...
Black Duck by Synopsys
 
PPTX
Static Analysis Security Testing for Dummies... and You
Kevin Fealey
 
PDF
Threat Modeling for System Builders and System Breakers - Dan Cornell of Deni...
Denim Group
 
PDF
FLIGHT WEST 2018 - Presentation - SCA 101: How to Manage Open Source Security...
Black Duck by Synopsys
 
PPTX
Making the Strategic Shift to Open Source at Fujitsu Network Communication
Black Duck by Synopsys
 
PDF
Software Security Assurance for DevOps
Black Duck by Synopsys
 
PPTX
Agile & Secure SDLC
Paul Yang
 
PPTX
Cyber security - It starts with the embedded system
Rogue Wave Software
 
PPTX
Secure Software Development Life Cycle
Maurice Dawson
 
PPTX
Testing Tools and Tips
SoftServe
 
PPTX
Software Security Initiative Capabilities: Where Do I Begin?
Cigital
 
PDF
Pactera - App Security Assessment - Mobile, Web App, IoT - v2
Kyle Lai
 
PPTX
24may 1200 valday eric anklesaria 'secure sdlc – core banking'
Positive Hack Days
 
ODP
Basic of SSDLC
Chitpong Wuttanan
 
PPTX
Agile and Secure Development
Nazar Tymoshyk, CEH, Ph.D.
 
PPTX
Perforce on Tour 2015 - Grab Testing By the Horns and Move
Perforce
 
PDF
Create code confidence for better application security
Rogue Wave Software
 
PPTX
Shifting the conversation from active interception to proactive neutralization
Rogue Wave Software
 
FLIGHT WEST 2018 Presentation - Open Source License Management in Black Duck Hub
Black Duck by Synopsys
 
Automating Your Tools: How to Free Up Your Security Professionals for Actual ...
Kevin Fealey
 
FLIGHT WEST 2018 Presentation - Continuous Monitoring of Open Source Componen...
Black Duck by Synopsys
 
Static Analysis Security Testing for Dummies... and You
Kevin Fealey
 
Threat Modeling for System Builders and System Breakers - Dan Cornell of Deni...
Denim Group
 
FLIGHT WEST 2018 - Presentation - SCA 101: How to Manage Open Source Security...
Black Duck by Synopsys
 
Making the Strategic Shift to Open Source at Fujitsu Network Communication
Black Duck by Synopsys
 
Software Security Assurance for DevOps
Black Duck by Synopsys
 
Agile & Secure SDLC
Paul Yang
 
Cyber security - It starts with the embedded system
Rogue Wave Software
 
Secure Software Development Life Cycle
Maurice Dawson
 
Testing Tools and Tips
SoftServe
 
Software Security Initiative Capabilities: Where Do I Begin?
Cigital
 
Pactera - App Security Assessment - Mobile, Web App, IoT - v2
Kyle Lai
 
24may 1200 valday eric anklesaria 'secure sdlc – core banking'
Positive Hack Days
 
Basic of SSDLC
Chitpong Wuttanan
 
Agile and Secure Development
Nazar Tymoshyk, CEH, Ph.D.
 
Perforce on Tour 2015 - Grab Testing By the Horns and Move
Perforce
 
Create code confidence for better application security
Rogue Wave Software
 
Shifting the conversation from active interception to proactive neutralization
Rogue Wave Software
 
Ad

Viewers also liked (18)

ODP
Joxean Koret - Interactive Static Analysis Tools for Vulnerability Discovery ...
RootedCON
 
ODP
Static analysis tools
Aman Ahmed
 
PDF
How to Select a Static Analysis Tool
Parasoft_Mitchell
 
PDF
Static Analysis Techniques For Testing Application Security - Houston Tech Fest
Denim Group
 
PPTX
Static Application Security Testing Strategies for Automation and Continuous ...
Kevin Fealey
 
PPTX
Voice enabling system for blind people using gps and gsm
Abhijit Ghosh
 
PPTX
Top 10 static code analysis tool
scmGalaxy Inc
 
PPTX
Tyre Industry Analysis
Soupa Soundararajan
 
PPT
Idioma
VidmaryQ
 
PPTX
Preventive measures and support regarding Child Sexual Exploitation in Bulgaria
BASPCAN
 
PDF
Biological_clustering_for_asthma_and_copd_MichaelGhebre
Michael A Ghebre, PhD
 
PPTX
Sent Down To Suffer
BASPCAN
 
PPTX
The unexpected
kozzia
 
DOCX
nơi nào dịch vụ giúp việc văn phòng giá tốt ở hồ chí minh
pricilla894
 
PPTX
Mapping Sexually Exploited Young People in Dundee
BASPCAN
 
DOC
Farmacología cardiovascular y del aparato respiratorio cuestionario
Álvaro Miguel Carranza Montalvo
 
ODP
Ternasco de Aragon
supercoci
 
PPT
Universal and Clergy Mandated Reporting Laws and Child Maltreatment Report Rates
BASPCAN
 
Joxean Koret - Interactive Static Analysis Tools for Vulnerability Discovery ...
RootedCON
 
Static analysis tools
Aman Ahmed
 
How to Select a Static Analysis Tool
Parasoft_Mitchell
 
Static Analysis Techniques For Testing Application Security - Houston Tech Fest
Denim Group
 
Static Application Security Testing Strategies for Automation and Continuous ...
Kevin Fealey
 
Voice enabling system for blind people using gps and gsm
Abhijit Ghosh
 
Top 10 static code analysis tool
scmGalaxy Inc
 
Tyre Industry Analysis
Soupa Soundararajan
 
Idioma
VidmaryQ
 
Preventive measures and support regarding Child Sexual Exploitation in Bulgaria
BASPCAN
 
Biological_clustering_for_asthma_and_copd_MichaelGhebre
Michael A Ghebre, PhD
 
Sent Down To Suffer
BASPCAN
 
The unexpected
kozzia
 
nơi nào dịch vụ giúp việc văn phòng giá tốt ở hồ chí minh
pricilla894
 
Mapping Sexually Exploited Young People in Dundee
BASPCAN
 
Farmacología cardiovascular y del aparato respiratorio cuestionario
Álvaro Miguel Carranza Montalvo
 
Ternasco de Aragon
supercoci
 
Universal and Clergy Mandated Reporting Laws and Child Maltreatment Report Rates
BASPCAN
 
Ad

Similar to Static Analysis Tools and Frameworks: Overcoming a Dangerous Blind Spot (20)

PPTX
Software Analytics: Towards Software Mining that Matters (2014)
Tao Xie
 
PPTX
.NET Core Summer event 2019 in Brno, CZ - War stories from .NET team -- Karel...
Karel Zikmund
 
PPTX
.NET Core Summer event 2019 in Prague, CZ - War stories from .NET team -- Kar...
Karel Zikmund
 
PDF
Software Analytics - Achievements and Challenges
Tao Xie
 
PPTX
.NET Core Summer event 2019 in Vienna, AT - War stories from .NET team -- Kar...
Karel Zikmund
 
PPTX
.NET Core Summer event 2019 in NL - War stories from .NET team -- Karel Zikmund
Karel Zikmund
 
PPTX
SAST_QSDL
Ivan Elkin
 
PDF
Статический анализ кода в контексте SSDL
Positive Hack Days
 
PPTX
.NET Core Summer event 2019 in Linz, AT - War stories from .NET team -- Karel...
Karel Zikmund
 
PPT
Beyond Static Analysis: Integrating .NET Static Analysis with Unit Testing a...
Erika Barron
 
PPTX
NDC Oslo 2019 - War stories from .NET team -- Karel Zikmund
Karel Zikmund
 
PDF
The App Sec How-To: Choosing a SAST Tool
Checkmarx
 
PDF
Embedded world 2017
ChantalWauters
 
PDF
Software Mining and Software Datasets
Tao Xie
 
PPTX
Production debugging web applications
Ido Flatow
 
PPTX
A simplest way to reconstruct .Net Framework - CRB Tech
Pooja Gaikwad
 
PPTX
A simplest-way-to-reconstruct-.net-framework
sonia merchant
 
PDF
Software Analytics: Data Analytics for Software Engineering
Tao Xie
 
PDF
Software Security Engineering (Learnings from the past to fix the future) - B...
DebasisMohanty43
 
PDF
Software Analytics: Data Analytics for Software Engineering and Security
Tao Xie
 
Software Analytics: Towards Software Mining that Matters (2014)
Tao Xie
 
.NET Core Summer event 2019 in Brno, CZ - War stories from .NET team -- Karel...
Karel Zikmund
 
.NET Core Summer event 2019 in Prague, CZ - War stories from .NET team -- Kar...
Karel Zikmund
 
Software Analytics - Achievements and Challenges
Tao Xie
 
.NET Core Summer event 2019 in Vienna, AT - War stories from .NET team -- Kar...
Karel Zikmund
 
.NET Core Summer event 2019 in NL - War stories from .NET team -- Karel Zikmund
Karel Zikmund
 
SAST_QSDL
Ivan Elkin
 
Статический анализ кода в контексте SSDL
Positive Hack Days
 
.NET Core Summer event 2019 in Linz, AT - War stories from .NET team -- Karel...
Karel Zikmund
 
Beyond Static Analysis: Integrating .NET Static Analysis with Unit Testing a...
Erika Barron
 
NDC Oslo 2019 - War stories from .NET team -- Karel Zikmund
Karel Zikmund
 
The App Sec How-To: Choosing a SAST Tool
Checkmarx
 
Embedded world 2017
ChantalWauters
 
Software Mining and Software Datasets
Tao Xie
 
Production debugging web applications
Ido Flatow
 
A simplest way to reconstruct .Net Framework - CRB Tech
Pooja Gaikwad
 
A simplest-way-to-reconstruct-.net-framework
sonia merchant
 
Software Analytics: Data Analytics for Software Engineering
Tao Xie
 
Software Security Engineering (Learnings from the past to fix the future) - B...
DebasisMohanty43
 
Software Analytics: Data Analytics for Software Engineering and Security
Tao Xie
 

More from Cigital (16)

PDF
7 Lessons Learned From BSIMM
Cigital
 
PPTX
Secure Design: Threat Modeling
Cigital
 
PDF
Getting Executive Support for a Software Security Program
Cigital
 
PPTX
Handle With Care: You Have My VA Report!
Cigital
 
PPTX
How to Choose the Right Security Training for You
Cigital
 
PPTX
6 Most Common Threat Modeling Misconceptions
Cigital
 
PPTX
Video Game Security
Cigital
 
PDF
Get Your Board to Say "Yes" to a BSIMM Assessment
Cigital
 
PPTX
Software Security Metrics
Cigital
 
PPTX
Cyber War, Cyber Peace, Stones, and Glass Houses
Cigital
 
PDF
The Complete Web Application Security Testing Checklist
Cigital
 
PDF
BSIMM By The Numbers
Cigital
 
PPTX
BSIMM: Bringing Science to Software Security
Cigital
 
PPTX
BSIMM-V: The Building Security In Maturity Model
Cigital
 
PPT
5 Models for Enterprise Software Security Management Teams
Cigital
 
PPT
How to Avoid the Top Ten Software Security Flaws
Cigital
 
7 Lessons Learned From BSIMM
Cigital
 
Secure Design: Threat Modeling
Cigital
 
Getting Executive Support for a Software Security Program
Cigital
 
Handle With Care: You Have My VA Report!
Cigital
 
How to Choose the Right Security Training for You
Cigital
 
6 Most Common Threat Modeling Misconceptions
Cigital
 
Video Game Security
Cigital
 
Get Your Board to Say "Yes" to a BSIMM Assessment
Cigital
 
Software Security Metrics
Cigital
 
Cyber War, Cyber Peace, Stones, and Glass Houses
Cigital
 
The Complete Web Application Security Testing Checklist
Cigital
 
BSIMM By The Numbers
Cigital
 
BSIMM: Bringing Science to Software Security
Cigital
 
BSIMM-V: The Building Security In Maturity Model
Cigital
 
5 Models for Enterprise Software Security Management Teams
Cigital
 
How to Avoid the Top Ten Software Security Flaws
Cigital
 

Recently uploaded (20)

PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PPTX
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PPTX
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
Exploring AI Agents in Process Industries
amoreira6
 
PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PPTX
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Exploring AI Agents in Process Industries
amoreira6
 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Activate_Methodology_Summary presentatio
annapureddyn
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 

Static Analysis Tools and Frameworks: Overcoming a Dangerous Blind Spot

  • 1. Copyright © 2015, CigitalCopyright © 2016, Cigital Static Analysis Tools and Frameworks: Overcoming a Dangerous Blind Spot Mike Lyman Senior Consultant [email protected] https://www.cigital.com/blog/static-analysis-tool-framework-blind-spot/ Copyright © 2016, Cigital
  • 2. Copyright © 2015, CigitalCopyright © 2016, Cigital Who am I? Mike Lyman • Senior Consultant at Cigital • [email protected] • 9+ years of software security focus • 19 years in the security business • CISSP/CSSLP • @mlyman87
  • 3. Copyright © 2015, CigitalCopyright © 2016, Cigital Who are you? • Developers? • Managers? • Testers? • Part of a security team? Are you using static analysis tools? What are your concerns with these tools?
  • 4. Copyright © 2015, CigitalCopyright © 2016, Cigital Agenda • Intro to static analysis tools • Static analysis concepts • Frameworks • The blind spot • How to overcome it • .Net Web API walkthrough
  • 5. Copyright © 2015, CigitalCopyright © 2016, Cigital Testing with static analysis tools is often referred to as Static Application Security Testing (SAST).
  • 6. Copyright © 2015, CigitalCopyright © 2016, Cigital SAST tools • Tools that look at source code for certain types of bugs • As simple as “glorified grep” • simple pattern recognition • As complicated as compilers • control and data flow analysis • Often a combination of both • Free and commercially available
  • 7. Copyright © 2015, CigitalCopyright © 2016, Cigital SAST concepts • Taint: data from untrusted sources is considered tainted • Source: source of data • Sink: function that consumes data • Taint flows through the data flows until it is either: • removed through validation or sanitization • consumed by a sink • If taint reaches sink, bad things can happen • Examples: • Buffer overflows • Command injection • SQL injection
  • 8. Copyright © 2015, CigitalCopyright © 2016, Cigital Frameworks • Speed up development • Provide a lot of basic functionality • Allows a focus on core functionality • Might be completely separate from your language • Java and Spring • Might be tightly coupled • C# and .Net (but with some advanced features that are available as separate downloads)
  • 9. Copyright © 2015, CigitalCopyright © 2016, Cigital The blind spot
  • 10. Copyright © 2015, CigitalCopyright © 2016, Cigital The blind spot • What is going on under the hood? • Obvious question: Are there security bugs in the framework itself? • Not so obvious: Do frameworks introduce problems for your code? • New sources of tainted data? • New dangerous sinks? • Pass through functions that pass on or add taint? • How do the data flows work with the framework? • Does your SAST tool understand this? • Using non-framework 3rd party libraries can cause the same issues.
  • 11. Copyright © 2015, CigitalCopyright © 2016, Cigital Does your tool know about these issues? • New frameworks and new versions appearing faster than we can keep up – can the tool vendor? • Are there enough users to get the vendor’s attention? • Even if you have the source code, can the tool trace the data flows? • If your static analysis tool cannot see or understand the framework it cannot report issues – false negatives!
  • 12. Copyright © 2015, CigitalCopyright © 2016, Cigital False positives are annoying. False negatives are dangerous! False positives are annoying. False negatives are dangerous!
  • 13. Copyright © 2015, CigitalCopyright © 2016, Cigital How do you know you have a problem? • Penetration testers find code implementation problems • SAST doesn’t • Functionality analysis • What functionality does the framework (or 3rd party library) provide? • What types of problems can be introduced there or occur there? • Create vulnerable test cases • Scan the test cases • Binary analysis • Decompile and analyze • Watch for questions on the tool’s support forums • Ask the vendor
  • 14. Copyright © 2015, CigitalCopyright © 2016, Cigital How do you fix it? • Teach the tool to handle the issues through custom rules • May need pre-scan processing • Supplement with a different tool • Pressure the vendor • If you find actual bugs in the framework, report them
  • 15. Copyright © 2015, CigitalCopyright © 2016, Cigital .Net Web API A Walkthrough
  • 16. Copyright © 2015, CigitalCopyright © 2016, Cigital The setup • Customer is creating micro-services based on the .Net Web API (System.Web.Http.ApiController). • Penetration testers find code implementation issues. • SAST doesn’t understand the Web API or asynchronous calls, despite both being available for years. • Need to enable SAST tools to find these issues.
  • 17. Copyright © 2015, CigitalCopyright © 2016, Cigital Non-live walkthrough • Code taken from the stub program is created when you create a new Web API C# application. • These code snippets don’t necessarily contain security bugs. They are used to illustrate the discovery method used to figure out how to get the SAST tool to understand code derived from the APIController. • Images of MSIL code taken from ILSpy.
  • 18. Copyright © 2015, CigitalCopyright © 2016, Cigital The .Net ApiControl (WebAPI) provides automatic routing and databinding for HTTP methods. Databinding can be simple types (shown here) or complex custom classes. Data coming into these controllers via the automatic routing and databinding is part of http requests and should be considered tainted input. The SAST tool in use does an okay job of identifying tainted data sources both for things that followed the Get, Post, etc. naming conventions and for custom named methods mapped to HTTP methods (via attributes). The job isn’t perfect and needs to be supplemented with custom rules, especially after implementing some of the solutions discussed in the following slides.
  • 19. Copyright © 2015, CigitalCopyright © 2016, Cigital Real SAST problems arise with async methods and awaits. The SAST tool is blind to problems here. Data coming into these methods is not identified as tainted data. The initial instinct is to craft custom rules looking at C# in these methods. This approach doesn’t work here. Since custom rules based on C# don’t work, more research is necessary to include examining the assemblies themselves with ILSpy.
  • 20. Copyright © 2015, CigitalCopyright © 2016, Cigital ILSpy can take the assemblies and show you the MSIL and then take the MSIL back to either C# or VB.Net. The C# version of ChangePassword that comes from the decompiled assembly looks vastly different than the C# on the previous slide. Since the SAST tool in use looks at the compiled assemblies with its data flow rules, rather than the original C# source code, it’s now apparent why custom rules based on the original C# aren’t working. The compiler replaces the original code in the async method and generates a nested class to implement a state machine to handle the asynchronous task. The problems are now occurring in the generated class.
  • 21. Copyright © 2015, CigitalCopyright © 2016, Cigital The generated nested class creates a state machine that manages the async call. Most of the work is done in the MoveNext method (collapsed in the image above) as it steps through the various states until the task is complete. Analysis shows that this is where a large part of the custom rules effort is needed.
  • 22. Copyright © 2015, CigitalCopyright © 2016, Cigital We now know where to look. However… • It is clear that custom rules need to be built based on the generated, nested classes. However, they didn’t exist before compile time. • A pre-scan step examines the compiled assemblies using FXCop and Mono.Cecil, and generates custom rules on the fly. • The custom rules are used to scan the assemblies with the SAST tool. • It still fails to work properly.
  • 23. Copyright © 2015, CigitalCopyright © 2016, Cigital Now what? • The generated classes are nested: private classes with private methods. The SAST tool appears to ignore them. • Another pre-scan step is created to use Mono.Cecil to modify the assemblies by making the generated methods and classes public. • The dynamically generated rules start working.
  • 24. Copyright © 2015, CigitalCopyright © 2016, Cigital Confirmation • Test cases are created in C# with known dangerous sinks to test if the SAST tool works with the custom data source rules. • Test cases confirm proper data flows are identified from tainted sources, to the known dangerous sinks, and issues raised by the tool. • Due to compiler generated code, this didn’t provide complete test coverage. • Test cases are injected directly into the compiled assemblies using Mono.Cecil and we can confirm that the rules work.
  • 25. Copyright © 2015, CigitalCopyright © 2016, Cigital Problem discovery recap • Gained a deeper understanding of .Net Web APIs and asynchronous methods. • Discovered the main tool’s custom rules had to look for MSIL syntax – not C#. • Observed that taint sources existed within compiler- generated classes and methods that SAST couldn’t see. • Noticed that visibility issues hid problems from SAST tools. • Private vs. public access modifiers • Nested compiler created classes
  • 26. Copyright © 2015, CigitalCopyright © 2016, Cigital Solutions recap • Created custom rules based on MSIL syntax. • Created a pre-scan step to dynamically incorporate custom source rules based on generated MSIL for classes inherited from ApiController. • Created a pre-scan step to modify class and method visibility in generated assemblies. • Created test cases in C# to test dynamic rules. • Created a process to inject MSIL test cases into compiled assemblies for more complete test coverage.
  • 27. Copyright © 2015, CigitalCopyright © 2016, Cigital Questions?