static code analysis - umsl...

16
Static Code Analysis By: Nathan Want, Nikolay Filipets, Sasa Basara

Upload: truongkiet

Post on 06-May-2018

241 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Static Code Analysis

By: Nathan Want, Nikolay Filipets, Sasa Basara

Page 2: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Overview

▸ Method▸ Tools▸ Applications (dl-fidigi & Mantra broswer) ▸ Errors & Resolutions

Page 3: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Static code analsyis is preformed without running the program. The analysis is preformed on the source code and is generally referred to as white box testing.

What is Static Code Analysis?

Page 4: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Advantages andDisvantages

• Weakness found at exact location

• Quicker turn around for fixes

• Tools can scan entire code base

• False positives and false negatives

• Provide a false sense of secuirty

• Vulnerabilities in runtime environment not found

Advantages

Disadvantages

Page 5: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Cppcheck

Cppcheck primarily detects the types of bugs that compliers normally do not detect. The goal is to detect only real errors in the code and reduce the false positives. Cppcheck unlike other analysis tools does not detect syntax errors in the code.

Page 6: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Screen shot example of our analysis (of dl-fidigi) using cppchecker

Page 7: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

dl-fidigi

dl-fldigi is an adapted version of the excellent free FLdigi soundcard decoding software. It takes the audio from your radio, decodes the balloon's signal, and then sends the telemetry it's found over the internet to a server running habitat, which plots the payloads position on to the SpaceNear map.

Page 8: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

dl-fidigi

Static Analysis results using Cppcheck:

Page 9: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Index missing conditional statement

Solution:

Make sure index does not exceed 13th element in ‘if’ statement.

Page 10: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Solution:

Do not enter loop if j== s.size

Loop missing conditional

Page 11: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Solution:

%5 should be %4

Incorret value

Page 12: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Mantra broswer

Mantra is a web browser developed by OWASP. It is a free browser that comes with a powerful set of security tools. A few notable features of Mantra are: FireCat/KromCAT menu structure, proxy tools, FTP, SSH, REST and SQLite clients, and URL increment/decrement buttons to quickly change URLS.

Page 13: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Mantra broswer

Static Analysis results using Cppcheck:

Page 14: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Memory freed twice

Solution:

nGetterText was deleted previosuly.Only delete mGetterText once

Page 15: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Array out of bounds

Solution:

Insert additonal condition to check if I is less than 32 before exuction of the statement

Page 16: Static Code Analysis - UMSL Blogsblogs.umsl.edu/infosec/files/2016/01/INFSYS6868_StaticAnalysis...What is Static Code Analysis? Advantages and ... Cppcheck unlike other analysis tools

Questions?