Table of Contents

Tools

This page will give you some hints about various tools that might be used to uncover security vulnerabilities and perform code reviews.

Please note that the tools listed here have been recommended by various individuals who participate in the oss-security mailing list and there are no guarantees, so please take time to carefully evaluate any tools that you use.

Static Analysis

Clang

Compiler with static analysis capabilities for C/C++.

http://clang-analyzer.llvm.org/

http://clang.llvm.org/

Clang and very recent GCC also have dynamic “sanitizers”. For example:

http://clang.llvm.org/docs/AddressSanitizer.html

http://clang.llvm.org/docs/ThreadSanitizer.html

http://clang.llvm.org/docs/MemorySanitizer.html

Coccinelle

A tool for matching and fixing source code for C, C++, and other languages.

http://coccinelle.lip6.fr/

Coverity

Provides static analysis tools for C, C++, and other languages (requires license).

https://www.synopsys.com/software-integrity.html

Free scanning for open source C/C++ and Java projects (no license required):

https://scan.coverity.com/

cppcheck

Cppcheck is a static analysis tool for C/C++ code. Unlike C/C++ compilers and many other analysis tools it does not detect syntax errors in the code. Cppcheck primarily detects the types of bugs that the compilers normally do not detect. The goal is to detect only real errors in the code (i.e. have zero false positives).

http://cppcheck.sourceforge.net/

findbugs

FindBugs looks for bugs in Java programs. It is based on the concept of bug patterns. A bug pattern is a code idiom that is often an error.

http://findbugs.sourceforge.net

Flawfinder

Flawfinder is an free/open source static analysis tool and works by using a built-in database of C/C++ functions with well-known problems, such as buffer overflow risks (e.g., strcpy(), strcat(), gets(), sprintf(), and the scanf() family), format string problems ([v][f]printf(), [v]snprintf(), and syslog()), race conditions (such as access(), chown(), chgrp(), chmod(), tmpfile(), tmpnam(), tempnam(), and mktemp()), potential shell metacharacter dangers (most of the exec() family, system(), popen()), and poor random number acquisition (such as random()). The good thing is that you don't have to create this database - it comes with the tool.

http://www.dwheeler.com/flawfinder/

http://sourceforge.net/projects/flawfinder/

http://www.debian.org/security/audit/examples/flawfinder

gcc

The gcc compiler has extensive warning flags that can, among other things, find possible security vulnerabilities by locating variables that are used before being set, dangerous printf formats, mismatches between printf formats and arguments, and so forth. For example, you can use:

WARNINGS = -g -O -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wendif-labels -Wformat=2 -Winit-self -Wswitch-enum -Wdeclaration-after-statement -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wjump-misses-init -Wlogical-op -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Wundef -Wformat-security -Werror

with GCC (4.6 or later). Many of those are not security-related, of course, but -Wformat=2 certainly is, and some of the -Wall and -Wextra warnings are as well.

http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

JLint

A static analysis tool to find race conditions, locking errors, null pointer uses, and a number of other problems in Java programs.

http://artho.com/jlint/index.shtml

klocwork

Klockwork tools analyze source code on-the-fly, simplify peer code reviews, and extend the life of complex software (requires license).

http://www.klocwork.com/

PMD

PMD scans Java source code for potential problems.

http://pmd.sourceforge.net/

pscan

pscan is a package which is designed to audit C and C++ source files for format string vulnerabilities.

http://www.debian.org/security/audit/examples/pscan

Pylint

Pylint is a Python static analysis tool.

http://www.pylint.org/

RATS

RATS is a general purpose scanner for detecting potential security problems in a number of programming languages. RATS understands several programming languages, C, Perl, PHP, and Python and will treat each as valid source to examine.

http://www.debian.org/security/audit/examples/RATS

Smatch

A static analysis tool for C.

http://smatch.sourceforge.net/

Sparse

Sparse, the semantic parser, provides a compiler frontend capable of parsing most of ANSI C as well as many GCC extensions, and a collection of sample compiler backends, including a static analyzer also called “sparse”. Sparse provides a set of annotations designed to convey semantic information about types, such as what address space pointers point to, or what locks a function acquires or releases.

Sparse works similarly to clang. It was hacked up by the kernel folks for finding potential errors in the linux kernel. It has very few false positives. That means it's actually viable to strive for “no warnings” from it and run it as part of automated testsuites.

https://sparse.wiki.kernel.org/index.php/Main_Page

Splint

Splint is a tool for statically checking C programs for security vulnerabilities and coding mistakes. With minimal effort, Splint can be used as a better lint. If additional effort is invested adding annotations to programs, Splint can perform stronger checking than can be done by any standard lint.

http://www.splint.org/

More tools

https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis

Dynamic Analysis

Valgrind

Detect many memory management and threading bugs, and profile your programs in detail.

http://valgrind.org/

KEDR

Provides runtime analysis of Linux kernel modules including device drivers, file system modules, etc.

http://kedr.berlios.de/

kmemcheck, kmemleak

Linux Kernel debugging features for detecting memory issues.

http://lxr.linux.no/linux+v3.8.5/Documentation/kmemcheck.txt http://lxr.linux.no/linux+v3.8.5/Documentation/kmemleak.txt

System Security Checking

exec-notify

exec-notify globally shows which programs are executed on a system. This allows to track down shell escaping problems in larger applications which execute external programs every now and then or in bootup scripts.

http://www.suse.de/~krahmer/exec-notify.c

Fsnoop

Fsnoop is a tool to monitor file operations on GNU/Linux systems. Its primary purpose is to detect bad temporary file usages and therefore, file race condition vulnerabilities.

http://vladz.devzero.fr/fsnoop.php

inotify

inotify can observe directories like /tmp for changes, e.g. insecure creation of files etc.

http://www.suse.de/~krahmer/inotify.cc

lsof

List open files - “lsof” - is a tool to gather information about processes' open file descriptors (not only files itself). This information includes the name and PID of the process, the type of file and so on. Many Linux and BSD distributions ship lsof.

ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/

openscap

Security auditing tool based on the SCAP line of system security compliance standards managed by NIST.

http://www.open-scap.org/page/Main_Page

unix-privesc-check

Unix-privesc-checker is a script that runs on Unix systems (tested on Solaris 9, HPUX 11, Various Linuxes, FreeBSD 6.2). It tries to find misconfigurations that could allow local unprivileged users to escalate privileges to other users or to access local apps (e.g. databases).

http://code.google.com/p/unix-privesc-check

Penetration Testing

Metasploit

Metasploit software helps security and IT professionals identify security issues, verify vulnerability mitigations, and manage expert-driven security assessments, providing true security risk intelligence. Capabilities include smart exploitation, password auditing, web application scanning, and social engineering. Teams can collaborate in Metasploit and present their findings in consolidated reports.

http://www.metasploit.com/

OpenVAS

The Open Vulnerability Assessment System (OpenVAS) is a framework of several services and tools offering a comprehensive and powerful vulnerability scanning and vulnerability management solution.

http://www.openvas.org/

Fuzz Testing

fsfuzzer

The fsfuzzer is a filesystem fuzzer tool that does stress tests of various filesystems in a reproducible and logged way.

https://www.ee.oulu.fi/research/ouspg/fsfuzzer

Peach Fuzzing Platform

Peach is a SmartFuzzer that is capable of performing both generation and mutation based fuzzing. Peach has been under active development since 2004 and is in its second major version with the third currently under development. Peach was created and is actively developed by Michael Eddington of Deja vu Security.

http://peachfuzzer.com/

Trinity

A Linux System call fuzz tester.

http://codemonkey.org.uk/projects/trinity/

Source Code Navigation

cscope

With the help of cscope, reviewers can comfortable search for symbols in the source code of programs. It allows to search for definitions/declarations and calls of certain functions, macro definitions etc.. Most Linux and BSD distributions ship cscope.

http://cscope.sourceforge.net/

ctags

Ctags builds a cross-reference file (similar to cscope) from a source code tree called a “tag-file”. This allows reviewers with the help of a tag-file supporting editor (such as vim) to follow function calls while auditing and to step down into functions just as one would do at runtime with gdb. Despite its name, ctags supports a plenty of languages, not just C.

http://ctags.sourceforge.net/

Debian Code Search (DCS) is a search engine for source code — it searches all the open source projects which are included in the Debian archive.

http://codesearch.debian.net/

kscope

kscope uses the index file generated by cscope and gives developers a graphical frontend to generate call-graphs, search and edit functions etc.. A very convenient tool to browse large software projects such as the Linux kernel.

http://kscope.sourceforge.net/

ltrace

ltrace allows to trace the execution of library calls in programs and processes. By carefully observing the order and arguments of certain calls such as open(3) or chown(3) one can spot simple kinds of race conditions.

http://ltrace.alioth.debian.org/

sourcenav

sourcenav, or the Source-Navigator, is a source code analysis tool. It aids the process of code visualization during code reviews by displaying the relationships between functions and generating call trees. Also, it helps in analyzing the propagation of a change in the code to other source modules.

http://sourcenav.sourceforge.net/

strace/ktrace/truss

strace, similar to ltrace, allows to trace the execution of system calls in programs and processes. This helps to determine whether arguments are passed correctly during runtime, for example to chroot(2) or execve(2). Most Linux distributions ship strace and install it by default. BSD systems have a similar tool called “truss” although strace is available.

http://sourceforge.net/projects/strace/ http://www.freebsd.org/cgi/man.cgi?ktrace

Debugging

gdb

The GNU Debugger - “gdb” - is a general purpose debugger which also helps in source code reviews if you want to estimate whether a certain vulnerability is really exploitable. This is not always the case since the generated binary code makes exploitation impossible for example due to stack alignments or optimizations.

http://sourceware.org/gdb/

insight

insight is a Tcl/Tk based graphical frontend to gdb with many features and an intuitive interface. What sets insight apart from other gdb GUIs is its active and continuous development, and its integration with sourcenav (see below).

http://sourceware.org/insight/

Vulnerability Management

Faraday

With Faraday you may focus on discovering vulnerabilities while we help you with the rest. Just use it in your terminal and get your work organized on the run. Faraday was made to let you take advantage of the available tools in the community in a truly multiuser way. Faraday aggregates and normalyzses the data you load, allowing exploring it into different visualizations that are useful to managers and analyst alike.

Others

symboldb

Tool used to locate certain issues in RPM packages. SQL queries can be created to detect candidate vulnerabilities.

https://github.com/fweimer/symboldb/tree/master/doc/examples

victi.ms

Java/J2EE library JARs are typically included as dependencies for an application using build tools like maven that draw them from public repositories. Some of the maven central repository JARs are versions with known flaws. victi.ms maintains a web based DB of vulnerable JARs. victi.ms enforces scans of dependencies against known vulnerability DB.

https://victims-websec.rhcloud.com/

More Lists of Tools

Debian Security Audit Project

The Debian Security Audit Project maintains a list of Security Auditing Tools, mostly for automated static source code analysis, along with Automated Audit Examples.

Debian Automated Code Analysis Tools

http://qa.debian.org/daca/

OWASP

https://www.owasp.org/index.php?title=Phoenix/Tools

securitytools.wikidot.com

http://securitytools.wikidot.com/defensive-programming

http://securitytools.wikidot.com/penetration-vulnerability-ids-ips

http://securitytools.wikidot.com/fuzzing

wikipedia

http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis

http://en.wikipedia.org/wiki/Dynamic_program_analysis