Source Code Scanners for Better Code
Coding is tough enough, and coding right can sometimes seem an almost impossible task. Between design constraints, deadlines and making it work in the first place, it's difficult to get your code secure. Security concerns, however, can be helped by scanners.
Source code scanners are nothing new. Tools like lint have been around for many, many years to help you find errors in your C code. There are even lint checkers for DNS and HTML files, nslint and weblint, respectively. The lint tool doesn't explicitly talk about insecure code, though, only basic inconsistencies in your style.
Source code audits are also great things, things like the Linux Auditing Project. However, audits can take a lot of time and money if you outsource them, though the payback is well worth the investment. Source code scanners used available for only commercial software, prohibiting their use by many Linux developers and researchers, who didn't always place user friendliness high on their lists of goals.
A couple of years ago, pscan was released under the GPL. It's a simple format string scanner but one of the first such tools commonly available on the hobbyist developer market. Since then, three new source code scanners have become available for source available software, and all three are worth looking at. Not all of them are open source, but they do work well for most users coding in C or C++.
The resources listed at the end of this article are worth checking out. The Open Source Quality Project has links to several sites, including commercial products and academic research groups, involved in performing software quality testing. Some of these tools can do more rigorous testing but can be far less user-friendly.
Developed by the noted author and coder David Wheeler, Flawfinder is a Python program that can be used to assist auditing C and C++ code. It's in the early stages, currently at version 0.19, but already it's strong competition for the other tools listed here in the 1.x stages. Flawfinder is also quite fast, covering thousands of lines of C code on a typical desktop machine in a matter of seconds. Flawfinder is released under GPL version 2, meaning it is free software.
Flawfinder also shows some intelligence when it comes to scanning for vulnerabilities. For example, in tests using intentionally insecure code, Flawfinder was able to distinguish between strcpy() from a constant sized string and variable length strings and tell the difference between vulnerabilities and false hits. Furthermore, Flawfinder understands the gettext libraries and their use in internationalization.
RATS, the Rough Auditing Tool for Security, is a source code scanner under active development that is capable of scanning C, C++, Perl, PHP and Python source code. Also released under the GPL, some of the RATS developers also worked on a similar tool, ITS4 (discussed below). The current version, 1.3, is noticeably more stable than version 1.2, but it still can fail on large amounts of input.
RATS is configurable when the source code is modified (through lexical analysis), with error messages controlled by XML reporting filters, which requires the XML tool expat to also be installed. At runtime, you can configure the level of output you wish to see (defaulting to medium), alternative vulnerability databases and even report functions that accept input from the user, facilitating the tracking of user supplied data.
Some of the specific limitations of RATS include the use of greedy pattern matchings, meaning that tracking for "printf" will match not only "print()" calls but also "vsnprintf()" and the like. This can make it difficult to filter hits from noise when specific functions are being sought with the -a flag.
The authors of RATS and Flawfinder, by the way, plan to coordinate their development efforts to produce a high quality, open-source development tool. This should be good to watch, as each development team is well respected in the field.
One of the original source available scanners for Linux and UN*X, It's the Software Stupid Source Scanner (ITS4), scans C and C++ source for common security-related flaws. Developed by Cigital (then known as RST Technologies) and some of the same people who went on to develop RATS, ITS4 has set the pace. Many of the niceties in ITS4 are also available in RATS or Flawfinder, such as ignorable lines, tracking user input (the -m flag) and alternative databases.
Modification of a particular project or site is relatively straightforward. A simple text file of vulnerabilities is used, which can be added to or modified to suit any specifics of a system. It should be noted that ITS4 comes with a non-free license, even though the source is available. Users should read and understand the license if they are doing anything beyond hobbyist programming with it.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
|Working with Command Arguments||May 28, 2016|
|Secure Desktops with Qubes: Installation||May 28, 2016|
|CentOS 6.8 Released||May 27, 2016|
|Secure Desktops with Qubes: Introduction||May 27, 2016|
|Chris Birchall's Re-Engineering Legacy Software (Manning Publications)||May 26, 2016|
|ServersCheck's Thermal Imaging Camera Sensor||May 25, 2016|
- Secure Desktops with Qubes: Introduction
- Secure Desktops with Qubes: Installation
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Working with Command Arguments
- CentOS 6.8 Released
- The Italian Army Switches to LibreOffice
- Linux Mint 18
- ServersCheck's Thermal Imaging Camera Sensor
- Chris Birchall's Re-Engineering Legacy Software (Manning Publications)
- Petros Koutoupis' RapidDisk
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide