Secure Programs
Consider what we mean when we say that a
program is "secure." We saw in Chapter 1
that security implies some degree of trust that the program enforces expected
confidentiality, integrity, and availability. From the point of view of a
program or a programmer, how can we look at a software component or code
fragment and assess its security? This question is, of course, similar to the
problem of assessing software quality in general. One way to assess security or
quality is to ask people to name the characteristics of software that
contribute to its overall security. However, we are likely to get different
answers from different people. This difference occurs because the importance of
the characteristics depends on who is analyzing the software. For example, one
person may decide that code is secure because it takes too long to break
through its security controls. And someone else may decide code is secure if it
has run for a period of time with no apparent failures. But a third person may
decide that any potential fault in meeting security requirements makes code
insecure.
An assessment of security can also be influenced by someone's
general perspective on software quality. For example, if your manager's idea of
quality is conformance to specifications, then she might consider the code
secure if it meets security requirements, whether or not the requirements are
complete or correct. This security view played a role when a major computer
manufacturer delivered all its machines with keyed locks, since a keyed lock
was written in the requirements. But the machines were not secure, because all
locks were configured to use the same key! Thus, another view of security is
fitness for purpose; in this view, the manufacturer clearly had room for improvement.
In general, practitioners often look at
quantity and types of faults for evidence of a product's quality (or lack of
it). For example, developers track the number of faults found in requirements,
design, and code inspections and use them as indicators of the likely quality
of the final product. Sidebar 3-1
explains the importance of separating the faultsthe causes of problemsfrom the
failures, the effects of the faults.
Fixing Faults
One approach to judging quality in security has
been fixing faults. You might argue that a module in which 100 faults were
discovered and fixed is better than another in which only 20 faults were
discovered and fixed, suggesting that more rigorous analysis and testing had
led to the finding of the larger number of faults. Au contraire, challenges
your friend: a piece of software with 100 discovered faults is inherently full
of problems and could clearly have hundreds more waiting to appear. Your
friend's opinion is confirmed by the software testing literature; software that
has many faults early on is likely to have many others still waiting to be
found.
Sidebar 3-1: IEEE Terminology for Quality
Frequently, we talk
about "bugs" in software, a term that can mean many different things
depending on context. A bug can be a
mistake in interpreting a requirement, a syntax error in a piece of code, or
the (as-yet-unknown) cause of a system crash. The IEEE has suggested a standard
terminology (in IEEE Standard 729) for describing bugs in our software products
[IEEE83].
When a human makes a
mistake, called an error, in
performing some software activity, the error may lead to a fault, or an incorrect step, command, process, or data definition
in a computer program. For example, a designer may misunderstand a requirement
and create a design that does not match the actual intent of the requirements
analyst and the user. This design fault is an encoding of the error, and it can
lead to other faults, such as incorrect code and an incorrect description in a
user manual. Thus, a single error can generate many faults, and a fault can
reside in any development or maintenance product.
A failure is a departure from the system's required behavior. It can
be discovered before or after system delivery, during testing, or during
operation and maintenance. Since the requirements documents can contain faults,
a failure indicates that the system is not performing as required, even though
it may be performing as specified.
Thus, a fault is an inside view of the system, as seen by the eyes of the
developers, whereas a failure is an outside view: a problem that the user sees.
Not every fault corresponds to a failure; for example, if faulty code is never
executed or a particular state is never entered, then the fault will never
cause the code to fail.
Early work in computer
security was based on the paradigm of "penetrate and patch," in which analysts searched for and
repaired faults. Often, a top-quality "tiger team" would be convened
to test a system's security by attempting to cause it to fail. The test was
considered to be a "proof" of security; if the system withstood the
attacks, it was considered secure. Unfortunately, far too often the proof
became a counterexample, in which not just one but several serious security
problems were uncovered. The problem discovery in turn led to a rapid effort to
"patch" the system to repair or restore the security. (See Schell's
analysis in [SCH79].) However, the patch
efforts were largely useless, making the system less secure rather than more
secure because they frequently introduced new faults. There are at least four
reasons why.
·
The pressure to repair a specific problem encouraged a narrow focus
on the fault itself and not on its context. In particular, the analysts paid
attention to the immediate cause of the failure and not to the underlying
design or requirements faults.
·
The fault often had nonobvious side effects in places other than
the immediate area of the fault.
·
Fixing one problem often caused a failure somewhere else, or the
patch addressed the problem in only one place, not in other related places.
·
The fault could not be fixed properly because system functionality
or performance would suffer as a consequence.
Unexpected Behavior
The inadequacies of penetrate-and-patch
led researchers to seek a better way to be confident that code meets its
security requirements. One way to do that is to compare the requirements with
the behavior. That is, to understand program security, we can examine programs
to see whether they behave as their designers intended or users expected. We
call such unexpected behavior a program
security flaw; it is inappropriate program behavior caused by a program
vulnerability. Unfortunately, the terminology in the computer security field is
not consistent with the IEEE standard described in Sidebar
3-1; the terms "vulnerability" and "flaw" do not
map directly to the characterization of faults and failures. A flaw can be
either a fault or failure, and a vulnerability usually describes a class of
flaws, such as a buffer overflow. In spite of the inconsistency, it is
important for us to remember that we must view vulnerabilities and flaws from
two perspectives, cause and effect, so that we see what fault caused the
problem and what failure (if any) is visible to the user. For example, a Trojan
horse may have been injected in a piece of codea flaw exploiting a
vulnerabilitybut the user may not yet have seen the Trojan horse's malicious
behavior. Thus, we must address program security flaws from inside and outside,
to find causes not only of existing failures but also of incipient ones.
Moreover, it is not enough just to identify these problems. We must also
determine how to prevent harm caused by possible flaws.
Program security flaws can
derive from any kind of software fault. That is, they cover everything from a
misunderstanding of program requirements to a one-character error in coding or
even typing. The flaws can result from problems in a single code component or
from the failure of several programs or program pieces to interact compatibly
through a shared interface. The security flaws can reflect code that was
intentionally designed or coded to be malicious or code that was simply
developed in a sloppy or misguided way. Thus, it makes sense to divide program
flaws into two separate logical categories: inadvertent human errors versus
malicious, intentionally induced flaws.
These categories help us understand some ways
to prevent the inadvertent and intentional insertion of flaws into future code,
but we still have to address their effects, regardless of intention. That is,
in the words of Sancho Panza in Man of La Mancha, "it doesn't matter
whether the stone hits the pitcher or the pitcher hits the stone, it's going to
be bad for the pitcher." An inadvertent error can cause just as much harm
to users and their organizations as can an intentionally induced flaw.
Furthermore, a system attack often exploits an unintentional security flaw to
perform intentional damage. From reading the popular press (see Sidebar 3-2), you might conclude that intentional
security incidents (called cyber attacks)
are the biggest security threat today. In fact, plain, unintentional human
errors are more numerous and cause much more damage.
Sidebar 3-2: Continuing Increase in Cyber Attacks
Carnegie Mellon
University's Computer Emergency Response Team (CERT) tracks the number and
kinds of vulnerabilities and cyber attacks reported worldwide. Part of CERT's
mission is to warn users and developers of new problems and also to provide
information on ways to fix them. According to the CERT coordination center,
fewer than 200 known vulnerabilities were reported in 1995, and that number
ranged between 200 and 400 from 1996 to 1999. But the number increased
dramatically in 2000, with over 1,000 known vulnerabilities in 2000, almost
2,420 in 2001, and 4,129 in 2002. Then the trend seemed to taper off slightly
with 3,784 in 2003 and 3,780 in 2004, but the count shot up again with 5,990 in
2005 and 1,597 in the first quarter of 2006 alone. (For current statistics, see
http://www.cert.org/stats/cert_stats.html#vulnerabilities.)
How does that translate
into cyber attacks? CERT reported over 137,000 incidents in 2003 and 319,992
total for the years 19882003. Because the number of incidents had become so
large, the attacks so widespread, and the reporting structure so widely used,
CERT stopped publishing a count of incidents in 2004, arguing that more
significant metrics were needed.
Moreover, as of June
2006, Symantec's Norton antivirus software checked for over 72,000 known virus
patterns. The Computer Security Institute and the FBI cooperate to take an
annual survey of approximately 500 large institutions: companies, government
organizations, and educational institutions [CSI05]. The response from
1999 through 2005 has been fairly constant: In each year approximately 40
percent of respondents reported from one to five incidents, 20 percent six to
ten, and 10 percent more than ten. The respondents reported total losses
exceeding $42 million due to virus attacks.
It is clearly time to take security seriously, both as users and
developers.
Regrettably, we do not have
techniques to eliminate or address all program security flaws. As Gasser [GAS88] notes, security is fundamentally hard,
security often conflicts with usefulness and performance, there is no
""silver bullet" to achieve security effortlessly, and false
security solutions impede real progress toward more secure programming. There
are two reasons for this distressing situation.
Program controls apply at the level of the
individual program and programmer. When we test a system, we try to make sure
that the functionality prescribed in the requirements is implemented in the
code. That is, we take a "should do" checklist and verify that the
code does what it is supposed to do. However, security is also about preventing
certain actions: a "shouldn't do" list. A system shouldn't do
anything not on its "should do" list. It is almost impossible to
ensure that a program does precisely what its designer or user intended, and
nothing more. Regardless of designer or programmer intent, in a large and
complex system, the pieces that have to fit together properly interact in an
unmanageably large number of ways. We are forced to examine and test the code
for typical or likely cases; we cannot exhaustively test every state and data
combination to verify a system's behavior. So sheer size and complexity
preclude total flaw prevention or mediation. Programmers intending to implant
malicious code can take advantage of this incompleteness and hide some flaws
successfully, despite our best efforts.
Programming and software engineering techniques
change and evolve far more rapidly than do computer security techniques. So we
often find ourselves trying to secure last year's technology while software
developers are rapidly adopting today'sand next year'stechnology.
Still, the situation is far
from bleak. Computer security has much to offer to program security. By
understanding what can go wrong and how to protect against it, we can devise
techniques and tools to secure most computer applications.
Types of Flaws
To aid our understanding of
the problems and their prevention or correction, we can define categories that
distinguish one kind of problem from another. For example, Landwehr et al. [LAN94] present a taxonomy of program flaws,
dividing them first into intentional and inadvertent flaws. They further divide
intentional flaws into malicious and nonmalicious ones. In the taxonomy, the
inadvertent flaws fall into six categories:
·
validation error (incomplete or inconsistent): permission checks
·
domain error: controlled access to data
·
serialization and aliasing: program flow order
·
inadequate identification and authentication: basis for
authorization
·
boundary condition violation: failure on first or last case
·
other exploitable logic errors
Other authors, such as Tsipenyuk et al. , the OWASP project , and Landwehr ,
have produced similar lists. This list gives us a useful overview of the ways
in which programs can fail to meet their security requirements. We leave our
discussion of the pitfalls of identification and authentication for Chapter 4, in which we also investigate separation
into execution domains. In this chapter, we address the other categories, each
of which has interesting examples.
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.