9.1. Best practices for security review and design
Developers that are packaging software should make a best effort to ensure that the installation of the software, or its use, does not introduce security risks to either the system it is installed on or its users.
In order to do so, they should make their best to review the source code of the package and detect any flaws that might introduce security bugs before releasing the software or distributing a new version. It is acknowledged that the cost of fixing bugs grows for different stages of its development, so it is easier (and cheaper) to fix bugs when designing than when the software has been deployed and is in maintenance mode (some studies say that the cost in this later phase is sixty times higher). Although there are some tools that try to automatically detect these flaws, developers should strive to learn about the different kind of security flaws in order to understand them and be able to spot them in the code they (or others) have written.
Some of these issues might not be easy to spot unless you are an expert in the programming language the software uses, but some security problems are easy to detect and fix. For example, finding temporary race conditions due to misuse of temporary directories can easily be done just by running grep -r "/tmp/" .
. Those calls can be reviewed and replace the hardcoded filenames using temporary directories to calls to either mktemp
or tempfile
in shell scripts, File::Temp(3perl) in Perl scripts, or tmpfile(3) in C/C++.
When packaging software developers have to make sure that they follow common security principles, including:
The software runs with the minimum privileges it needs:
Programmed (i.e., cron
) tasks running in the system do NOT run as root or, if they do, do not implement complex tasks.