SlideShare a Scribd company logo
Software Security
             Static analysis tools


                                        Presented by
                                      Emanuela Boroș
“Al. I. Cuza” University, Faculty of Computer Science
                   Master of Software Engineering, II
1. What is Static Analysis?

2. Static Analysis Advantages

3. Static Analysis Tools for C/C++, Java

4. Samples
What is Static Analysis?
What is Static Analysis?



● performed without actually executing or running
that software

●   performed by an automated tool
Static Analysis Advantages
Static Analysis Advantages

●   improve the quality and reliability of embedded
    systems software

●   significant reductions in development testing and
    field failures

●   careful when large amount of code is used in the
    development projects
Static Analysis Advantages

●   can detect

    ● buffer overflows,
    ● security vulnerabilities,

    ● memory leaks,

    ● timing anomalies (such as race conditions,

      deadlocks, and livelocks),
    ● dead or unused source code segments,

    ● and other common programming mistakes
Static Analysis Tools
Software Tool         Domain    Responsible Party     Languages      Platforms

CodeSonar         Commercial     Grammatech            C, C++       Windows

Coverity          Commercial     Coverty, Inc.         C, C++       Windows

CodeSurfer        Commercial     Grammatech            C, C++       Windows

FlawFinder        GPL            David A. Wheeler      C, C++       UNIX

ITS4              Commercial     Cigital               C, C++       Linux, Solaris,
                                                                    Windows
Java PathFinder   Academic       NASA Ames             Java         Any JVM
                                                                    compatible
                                                                    platform
JLint             Academic       Konstantin Knizhnik   Java         Any JVM
                                 Cyrille Arthro                     compatible
                                                                    platform
PREfix and        Commercial     Microsoft             C, C++, C#   Windows
PREfast
RATS              Academic       Secure Software        C, C++      Windows, Unix

Splint            Academic       University of Virginia, C          Windows, Unix,
                                 Department of                      Linux
                                 Computer Science
C/C++
rats-2.3

●   Rough Auditing Tool for Security

●   open source tool

●   C, C++, Perl, PHP and Python source code

●   rough analysis of source code

●   manual inspection of the code is still necessary,
    but greatly aided with this tool
rats-2.3

●   error messages controlled by XML reporting filters
    (requires the XML tool expat to also be installed)

●   configure the level of output

●   alternative vulnerability databases

●   buffer overflows and TOCTOU (Time Of Check,
    Time Of Use) race conditions
rats-2.3

●   extremely simple

●   scans through a file (lexically) looking for
    syntactic matches based on several simple rules
    that might indicate possible security
    vulnerabilities

●   “use of strcpy() should be avoided”
rats-2.3

●   the use of greedy pattern matchings

●   "printf" will match not only "print()" calls but also
    "vsnprintf()"

●   authors of RATS and Flawfinder, by the way, plan
    to coordinate their development efforts to produce
    a high quality, open-source development tool
Usage
rats [-d ] [-h] [-r] [-w ] [-x] [file1 file2 ... filen]



Options explained:

  -d Specifies a vulnerability database to be loaded. You may have multiple -d options and each database
specified will be loaded.

   -h Displays a brief usage summary

  -i Causes a list of function calls that were used which accept external input to be produced at the end of the
vulnerability report.

   -l Force the specified language to be used regardless of filename extension. Currently valid language names are
"c", "perl", "php" and "python".

   -r Causes references to vulnerable function calls that are not being used as calls themselves to be reported.

   -w Sets the warning level. Valid levels are 1, 2 or 3. Warning level 1 includes only default and high severity Level
2 includes medium severity. Level 2 is the default warning level 3 includes low severity vulnerabilities.

   -x Causes the default vulnerability databases to not be loaded.
Samples
Issue: fixed size global buffer Severity: High
Extra care should be taken to ensure that character arrays that are allocated on the stack are used safely. They
are prime targets for buffer overflow attacks.

int main(int argc, char *argv[])
{
    char dir[1024];
    char cmd[1200];
    char buff[1024];...


Issue: sprintf Severity: High
Check to be sure that the format string passed as argument 2 to this function call does not come from an untrusted
source that could have added formatting characters that the code is not prepared to handle. Additionally, the
format string could contain `%s' without precision that could result in a buffer overflow.

if (getenv("HOME") != NULL) {
    sprintf(dir, "%s", getenv("HOME"));
}...
Samples



Issue: strcpy Severity: High
Check to be sure that argument 2 passed to this function call will not copy more data than can be handled,
resulting in a buffer overflow.

if (argc == 2)
{
     strcpy(dir, argv[1]);
}
Caveats


●   the lack of any preprocessing, so no macros or definitions are expanded
    #define p(x) printf ## x
    char *string1, *string2;
    /* stuff happens ... */
    p((string1));                        /* insecure! */
    p((string2));                        /* insecure! */
    p(("%s", string1));                  /* correct! */

●   produces only one error in the definition but not in the use of the macro

●   insecure calls can be made multiple times, which will go unnoticed by the code scanner
Conclusions



●   source code scanners can help improve the state
    of your code in development or afterwards

●   these are tools help assist you in the auditing
    process, not automate it

More Related Content

Similar to Software Security - Static Analysis Tools

Dmitriy D1g1 Evdokimov - DBI Intro
Dmitriy D1g1 Evdokimov - DBI IntroDmitriy D1g1 Evdokimov - DBI Intro
Dmitriy D1g1 Evdokimov - DBI Intro
DefconRussia
 
Secure Coding Practices for Middleware
Secure Coding Practices for MiddlewareSecure Coding Practices for Middleware
Secure Coding Practices for Middleware
Manuel Brugnoli
 
Embedded Rust
Embedded RustEmbedded Rust
Embedded Rust
Jens Siebert
 
20100309 03 - Vulnerability analysis (McCabe)
20100309 03 - Vulnerability analysis (McCabe)20100309 03 - Vulnerability analysis (McCabe)
20100309 03 - Vulnerability analysis (McCabe)
LeClubQualiteLogicielle
 
Alvaro Denis Resume
Alvaro Denis ResumeAlvaro Denis Resume
Alvaro Denis Resume
Alvaro Denis Acosta Quesada
 
Java Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECJava Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPREC
Sreedhar Chowdam
 
Java Notes
Java Notes Java Notes
Java Notes
Sreedhar Chowdam
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource Kernels
Silvio Cesare
 
Software security
Software securitySoftware security
Software security
Roman Oliynykov
 
Stage 1 Tradecraft
Stage 1 TradecraftStage 1 Tradecraft
Stage 1 Tradecraft
matt806068
 
SmartphoneHacking_Android_Exploitation
SmartphoneHacking_Android_ExploitationSmartphoneHacking_Android_Exploitation
SmartphoneHacking_Android_Exploitation
Malachi Jones
 
Security tools
Security  toolsSecurity  tools
Security tools
Swapnil Srivastav PMP®
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharing
James Hsieh
 
Virtual platform
Virtual platformVirtual platform
Virtual platform
sean chen
 
Applying Provenance in APT Monitoring and Analysis Practical Challenges for S...
Applying Provenance in APT Monitoring and Analysis Practical Challenges for S...Applying Provenance in APT Monitoring and Analysis Practical Challenges for S...
Applying Provenance in APT Monitoring and Analysis Practical Challenges for S...
Graeme Jenkinson
 
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Codemotion
 
Open64 compiler
Open64 compilerOpen64 compiler
Open64 compiler
Maria Akther
 
Kunal - Introduction to BackTrack - ClubHack2008
Kunal - Introduction to BackTrack - ClubHack2008Kunal - Introduction to BackTrack - ClubHack2008
Kunal - Introduction to BackTrack - ClubHack2008
ClubHack
 
Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to backtrack - ClubHack2008Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to backtrack - ClubHack2008
ClubHack
 
Workshop on BackTrack live CD
Workshop on BackTrack live CDWorkshop on BackTrack live CD
Workshop on BackTrack live CD
amiable_indian
 

Similar to Software Security - Static Analysis Tools (20)

Dmitriy D1g1 Evdokimov - DBI Intro
Dmitriy D1g1 Evdokimov - DBI IntroDmitriy D1g1 Evdokimov - DBI Intro
Dmitriy D1g1 Evdokimov - DBI Intro
 
Secure Coding Practices for Middleware
Secure Coding Practices for MiddlewareSecure Coding Practices for Middleware
Secure Coding Practices for Middleware
 
Embedded Rust
Embedded RustEmbedded Rust
Embedded Rust
 
20100309 03 - Vulnerability analysis (McCabe)
20100309 03 - Vulnerability analysis (McCabe)20100309 03 - Vulnerability analysis (McCabe)
20100309 03 - Vulnerability analysis (McCabe)
 
Alvaro Denis Resume
Alvaro Denis ResumeAlvaro Denis Resume
Alvaro Denis Resume
 
Java Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECJava Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPREC
 
Java Notes
Java Notes Java Notes
Java Notes
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource Kernels
 
Software security
Software securitySoftware security
Software security
 
Stage 1 Tradecraft
Stage 1 TradecraftStage 1 Tradecraft
Stage 1 Tradecraft
 
SmartphoneHacking_Android_Exploitation
SmartphoneHacking_Android_ExploitationSmartphoneHacking_Android_Exploitation
SmartphoneHacking_Android_Exploitation
 
Security tools
Security  toolsSecurity  tools
Security tools
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharing
 
Virtual platform
Virtual platformVirtual platform
Virtual platform
 
Applying Provenance in APT Monitoring and Analysis Practical Challenges for S...
Applying Provenance in APT Monitoring and Analysis Practical Challenges for S...Applying Provenance in APT Monitoring and Analysis Practical Challenges for S...
Applying Provenance in APT Monitoring and Analysis Practical Challenges for S...
 
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
 
Open64 compiler
Open64 compilerOpen64 compiler
Open64 compiler
 
Kunal - Introduction to BackTrack - ClubHack2008
Kunal - Introduction to BackTrack - ClubHack2008Kunal - Introduction to BackTrack - ClubHack2008
Kunal - Introduction to BackTrack - ClubHack2008
 
Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to backtrack - ClubHack2008Kunal - Introduction to backtrack - ClubHack2008
Kunal - Introduction to backtrack - ClubHack2008
 
Workshop on BackTrack live CD
Workshop on BackTrack live CDWorkshop on BackTrack live CD
Workshop on BackTrack live CD
 

Recently uploaded

“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
Fwdays
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
Fwdays
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
ScyllaDB
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
Vadym Kazulkin
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
DianaGray10
 

Recently uploaded (20)

“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
 

Software Security - Static Analysis Tools

  • 1. Software Security Static analysis tools Presented by Emanuela Boroș “Al. I. Cuza” University, Faculty of Computer Science Master of Software Engineering, II
  • 2. 1. What is Static Analysis? 2. Static Analysis Advantages 3. Static Analysis Tools for C/C++, Java 4. Samples
  • 3. What is Static Analysis?
  • 4. What is Static Analysis? ● performed without actually executing or running that software ● performed by an automated tool
  • 6. Static Analysis Advantages ● improve the quality and reliability of embedded systems software ● significant reductions in development testing and field failures ● careful when large amount of code is used in the development projects
  • 7. Static Analysis Advantages ● can detect ● buffer overflows, ● security vulnerabilities, ● memory leaks, ● timing anomalies (such as race conditions, deadlocks, and livelocks), ● dead or unused source code segments, ● and other common programming mistakes
  • 9. Software Tool Domain Responsible Party Languages Platforms CodeSonar Commercial Grammatech C, C++ Windows Coverity Commercial Coverty, Inc. C, C++ Windows CodeSurfer Commercial Grammatech C, C++ Windows FlawFinder GPL David A. Wheeler C, C++ UNIX ITS4 Commercial Cigital C, C++ Linux, Solaris, Windows Java PathFinder Academic NASA Ames Java Any JVM compatible platform JLint Academic Konstantin Knizhnik Java Any JVM Cyrille Arthro compatible platform PREfix and Commercial Microsoft C, C++, C# Windows PREfast RATS Academic Secure Software C, C++ Windows, Unix Splint Academic University of Virginia, C Windows, Unix, Department of Linux Computer Science
  • 10. C/C++
  • 11. rats-2.3 ● Rough Auditing Tool for Security ● open source tool ● C, C++, Perl, PHP and Python source code ● rough analysis of source code ● manual inspection of the code is still necessary, but greatly aided with this tool
  • 12. rats-2.3 ● error messages controlled by XML reporting filters (requires the XML tool expat to also be installed) ● configure the level of output ● alternative vulnerability databases ● buffer overflows and TOCTOU (Time Of Check, Time Of Use) race conditions
  • 13. rats-2.3 ● extremely simple ● scans through a file (lexically) looking for syntactic matches based on several simple rules that might indicate possible security vulnerabilities ● “use of strcpy() should be avoided”
  • 14. rats-2.3 ● the use of greedy pattern matchings ● "printf" will match not only "print()" calls but also "vsnprintf()" ● authors of RATS and Flawfinder, by the way, plan to coordinate their development efforts to produce a high quality, open-source development tool
  • 15. Usage rats [-d ] [-h] [-r] [-w ] [-x] [file1 file2 ... filen] Options explained: -d Specifies a vulnerability database to be loaded. You may have multiple -d options and each database specified will be loaded. -h Displays a brief usage summary -i Causes a list of function calls that were used which accept external input to be produced at the end of the vulnerability report. -l Force the specified language to be used regardless of filename extension. Currently valid language names are "c", "perl", "php" and "python". -r Causes references to vulnerable function calls that are not being used as calls themselves to be reported. -w Sets the warning level. Valid levels are 1, 2 or 3. Warning level 1 includes only default and high severity Level 2 includes medium severity. Level 2 is the default warning level 3 includes low severity vulnerabilities. -x Causes the default vulnerability databases to not be loaded.
  • 16. Samples Issue: fixed size global buffer Severity: High Extra care should be taken to ensure that character arrays that are allocated on the stack are used safely. They are prime targets for buffer overflow attacks. int main(int argc, char *argv[]) { char dir[1024]; char cmd[1200]; char buff[1024];... Issue: sprintf Severity: High Check to be sure that the format string passed as argument 2 to this function call does not come from an untrusted source that could have added formatting characters that the code is not prepared to handle. Additionally, the format string could contain `%s' without precision that could result in a buffer overflow. if (getenv("HOME") != NULL) { sprintf(dir, "%s", getenv("HOME")); }...
  • 17. Samples Issue: strcpy Severity: High Check to be sure that argument 2 passed to this function call will not copy more data than can be handled, resulting in a buffer overflow. if (argc == 2) { strcpy(dir, argv[1]); }
  • 18. Caveats ● the lack of any preprocessing, so no macros or definitions are expanded #define p(x) printf ## x char *string1, *string2; /* stuff happens ... */ p((string1)); /* insecure! */ p((string2)); /* insecure! */ p(("%s", string1)); /* correct! */ ● produces only one error in the definition but not in the use of the macro ● insecure calls can be made multiple times, which will go unnoticed by the code scanner
  • 19. Conclusions ● source code scanners can help improve the state of your code in development or afterwards ● these are tools help assist you in the auditing process, not automate it