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.
Compiler with static analysis capabilities for C/C++.
http://clang-analyzer.llvm.org/
Clang and very recent GCC also have dynamic “sanitizers”. For example:
http://clang.llvm.org/docs/AddressSanitizer.html
A tool for matching and fixing source code for C, C++, and other languages.
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):
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).
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.
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/
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.
A static analysis tool to find race conditions, locking errors, null pointer uses, and a number of other problems in Java programs.
Klockwork tools analyze source code on-the-fly, simplify peer code reviews, and extend the life of complex software (requires license).
PMD scans Java source code for potential problems.
pscan is a package which is designed to audit C and C++ source files for format string vulnerabilities.
Pylint is a Python static analysis tool.
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.
A static analysis tool for C.
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.
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.
Detect many memory management and threading bugs, and profile your programs in detail.
Provides runtime analysis of Linux kernel modules including device drivers, file system modules, etc.
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
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.
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.
inotify can observe directories like /tmp for changes, e.g. insecure creation of files etc.
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.
Security auditing tool based on the SCAP line of system security compliance standards managed by NIST.
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).
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.
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.
The fsfuzzer is a filesystem fuzzer tool that does stress tests of various filesystems in a reproducible and logged way.
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.
A Linux System call fuzz tester.
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.
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.
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.
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.
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.
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.
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
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.
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).
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.
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
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.
The Debian Security Audit Project maintains a list of Security Auditing Tools, mostly for automated static source code analysis, along with Automated Audit Examples.
http://securitytools.wikidot.com/defensive-programming
http://securitytools.wikidot.com/penetration-vulnerability-ids-ips