Top Banner
Source code analysis tools Paweł Krawczyk
32

Source Code Scanners

Dec 26, 2014

Download

Technology

Paweł Krawczyk

Overview of tools for static code security analysis, with special focus on Yasca. See http://ipsec.pl/ for more details.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Source Code Scanners

Source code analysis tools

Paweł Krawczyk

Page 2: Source Code Scanners

„Static analysis is great for catching common errors early”

Brian Chess (Fortify)

Page 3: Source Code Scanners

Source code analysis

• Why?– Visibility limitations of blackbox testing– Insight not only into what is implemented but also how– Timing

• Blackbox needs working product• Code analysis can start with single line of code

• Risks– What you see is not always what ends up on the server

Page 4: Source Code Scanners

Why find bugs early?

Applied Software Measurement, Capers Jones, 1996Building Security Into The Software Life Cycle, Marco M. Morana, 2006

Early code audit

Page 5: Source Code Scanners

Why find bugs early?

Applied Software Measurement, Capers Jones, 1996Building Security Into The Software Life Cycle, Marco M. Morana, 2006

PentestLate code audit

Page 6: Source Code Scanners

Source code scanners

• Why?– Manual testing is time consuming– Manual testing is not easily standardised– Human factor of manual testing

• Automated scanning– Repeatable, standardised– Better automated than none

Page 7: Source Code Scanners

SCA in ASVS

• OWASP Application Security Verification Standard (ASVS)– Level 1B: Source code scan – partial

automated verfication– Level 2B: Code review – partial manual

verification

Page 8: Source Code Scanners

Tested free tools

• Yasca

• OWASP Code Crawler

• FxCop

• CAT.NET

• Agnitio

Page 9: Source Code Scanners

Yasca requirements

• PHP– http://www.php.net/

• JRE– 1.6.x from SDS or http://java.sun.com/

Page 10: Source Code Scanners

Installation

• Download main Yasca package– yasca-2.1.zip– http://sourceforge.net/projects/yasca/files/

• Download plugins– yasca-2.1-something.zip

Page 11: Source Code Scanners

Installation #2

• Unpack yasca-2.1.zip– No installer– Any destination– Runs directly from that directory

• Unpack plugins to a dedicated directory– c:\static-analyzers

• Set environment variable SA_HOME– SA_HOME=c:\static-analyzers\

Page 12: Source Code Scanners

Running Yasca

Page 13: Source Code Scanners

Running Yasca

Page 14: Source Code Scanners

Yasca performance

• Real application– Java and JSP source code– 17 MB uncompressed– 2500 files– 200 subdirectories– Network share (LAN)

• Run time ~10 minutes

Page 15: Source Code Scanners

Yasca reporting

Page 16: Source Code Scanners

Troubleshooting

• Official manual– http://www.yasca.org/h/documentation/

• Issues noticed– PMD crashing sometimes– How to limit large number of irrelevant issues?

Page 17: Source Code Scanners

OWASP Code Crawler

Page 18: Source Code Scanners

Features

• Version 2.5.1

• Supports C# and Java

Page 19: Source Code Scanners

Requirements

• .NET Framework 3.5

• Visual Studio 2008– Works with VS 2010 Beta

Page 20: Source Code Scanners

Results

Page 21: Source Code Scanners

Issues

• Trivial detection rules– „sha” in „shared” triggers „weak crypto” alert

• Work on one file at a time

Page 22: Source Code Scanners

MicrosoftFxCop

Page 23: Source Code Scanners

Features

• .NET only

• Works on .NET assemblies– EXE, DLL

• Needs full project with debug binaries

• Tested 1.36

Page 24: Source Code Scanners

Results

Page 25: Source Code Scanners

MicrosoftCAT.NET

Page 26: Source Code Scanners

Features

• .NET only

• Requires .NET Framework 4.0

• Requires Visual Studio 2005– Works with VS 2010 Beta

• Tested version 2.0

• Requires unstripped PDB files

• Requires experience with .NET

Page 27: Source Code Scanners

Running

C:\Program Files\Microsoft Information Security\Microsoft Code Analysis for .NET

(CAT.NET) v2.0>CATNetCmd.exe /file:"h:\Pentesting\Example - Employee Managemet

System\Employee Managemet System\bin\Debug\Employee Managemet System.exe" /confi

gdir:"h:\Pentesting\Example - Employee Managemet System\Employee Managemet Syste

m\Properties"

Page 28: Source Code Scanners

Results

Page 29: Source Code Scanners

Agnitio

• Audit management & reporting tool• Record basic application information• Build your own checklist

– „Has a centeralized whitelist approach to input validation been implemented?”

– Find evidence in source code– Answer Yes/No

• Did not really work for me– Issues with saving apps, validating fields

Page 30: Source Code Scanners
Page 31: Source Code Scanners

Commercial

• Ounce– now IBM Rational AppScan Source Edition

• Veracode– SaaS model – upload your code, automated

and manually assisted

• Fortify 360 Source Code Analyzer

• Checkmarx CxAudit

• Klocwork

Page 32: Source Code Scanners

Questions?

• http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis• IBM: „11 proven practices for more effective, efficient peer code

review”– http://ibm.co/eszW1V