A security bug in computer software is a flaw in its programmed operation that can allow a user unintended access to functions, resources or data that would otherwise be protected by the program. The cause of a security bug can include mistakes in programming, improper understanding of external libraries, or oversights when moving from a test version of a program to a release version. It can be difficult to diagnose and repair a security bug, because it has the potential to be a combination of several aspects of the program, some of which could be pre-compiled with no original source code available for programmers to examine.
One of the primary causes for a security bug can be the interaction between two different parts of computer code that might not have been written by the same person. Problems can arise when a function or class performs actions that are unknown or unexpected, such as modifying a variable that holds some part of the program state or changing internal properties without notifying associated elements. This can lead other parts of the program to operate on assumptions, or to be bypassed completely, creating a security hole that could be exploited. External libraries developed by commercial software companies can sometimes cause a security problem, especially in cases such as graphical user interfaces (GUIs) and network protocol wrappers that contain a large amount of hidden processing code.
Other reasons why a security bug might exist include simple programming errors and problems with memory allocation that can overwrite code segments or spill information from memory into areas where it can be exploited. Undeveloped features within a program also can cause a security bug by allowing a condition within the program that could pass execution to an unfinished portion of code without the proper security checks for input and output. The larger and more complex a program is, the higher the probability that a security bug exists within the code.
There are multiple ways to try to prevent a security bug from passing into final release versions of software. One of the most important is user testing, in which many people attempt to use the program to see whether it is working properly. Using software profilers — programs that examine and record memory usage and other statistics while software is running — can help to catch some internal bugs that could lead to a security problem. As the bugs are caught and repaired, most companies release updates or patches that eliminate the discovered bugs in software already in distribution.