Although we have just demonstrated a nightmare scenario for any system administrator, we must bear in mind that ALL such buffer overfl ow attacks are very preventable, and the “disease” that allows them to persist certainly may be eradicated in the future. However, an effective vaccine must first be developed.
The remainder of this report will focus on cure and prevention. Please select from the menu.
1. Use Different Language Tools. Language tools that provide . automatic
modern operating systems in use today are written in rightstheC language. The language tool becomes particularly critical when low-level hardware access is
bounds checking such as Perl, Python, and Java. True, these are available.
However, this is usually not possible or practical when you consider almost all
necessary. The good news is with languages evolving,full language and code security has becoming a serious issue. For example, Microsoft in their .NET
initiative has completely re-written Visual Basicretainsand Visual C++22 with “string safe” security in mind. Additionally, they have added the Visual C# tool which
was designed from the ground up with security in mind.
2. Eliminate The Use Of Flawed LibraryAuthorFunctions. Programming languages are only as flawed as the programmer allows them to be. In our demonstration, we utilized three flawed functions from the Standard C Library (gets(), strcpy, and strcmp). These are just three of many such functions that fail to check the length or bounds of their arguments. For instance, we could have completely eliminated2002,the buffer
overflow vulnerability in our demonstration by changing one line of code. This simple
change informs strcpy()Institutethat it only has an eight byte destination buffer and that it
must discontinue raw copy at eight bytes.
The persistence of programming errors of this nature may indeed be related to the manner in which we train and educate young programmers. One can pick up anSANSintroductory college textbook on C or C++ and find this set of flawed functions introduced by the third chapter. Sure, they make great training aids. However, humans are creatures of habit and tend to use what they know© best and are most comfortable with.
3. Design And Build Security Within Code. It takes more work, and it takes more effort, but software can be designed with security foremost in mind. If
22 Visual C++ is Microsoft’s proprietary version of the C++ language.
2/6/2003 Page 19 of 24
© SANS Institute 2002, As part of the Information Security Reading Room. Author retains full rights.
is no23.
the previous example, we could have yet added one extra step to assure complete buffer safety:
Again, this may go back to how we train programmers. Is code security
taught and encouraged? Are they given the extra time to design security . within their code? Typically, and unfortunately, the answerrightsto these questions
4. Use Safe Library Modules. String safe library modules are available for use, even in problematic languages such as C++. For instance, the C++ Standard
Template Library offers the Class String in its standard namespace. The
String Class provides bounds checking within its functionsfull and be preferred
for use over the standard string handling functions.
5. Use Available Middleware Libraries. Several freeware offerings of “safe
libraries” are available for use. For instance,retains Bell Labs developed the “libsafe24” library to guard against unsafe function use. libsafe works on the
structure of stack frame linkage Authorthrough frame pointers by following frame pointer to the stack frame that allocated a buffer. When a function executes,
it can then prevent the return address from being overwritten. However, libsafe is not without security problems of its own as it has been reported that libsafe's protections can be bypassed in a format-string-based attack by using flag characters that are used by glibc but not libsafe. Users of libsafe should
upgrade to version 2.0-12 2002,
6. Use Source CodeInstituteScanning Tools. Several attempts have been made to design a tool that performs analysis on raw source code with the hope of
identifying undesirable constructs to include buffer vulnerabilities. The boys at L0pht Heavy Industries (now a white hat group called @atstake) produced one such tool called “Slint” a few years back, but it was never released. Probably SANSthe most successful tool to date is Rational’s
(http://www.rational.com) PurifyPlus Software Suite that capably performs a dynamic analysis of Java, C, or C++ source code. Although the specialty of
PurifyPlus is memory leak detection, it is capable of hunting down unchecked ©
23 It was recently reported in the media that Bill Gates went on a tirade about code security at Microsoft In fact, he reportedly stopped all new code production for one month to train his programmers in code security basics. Until now, Microsoft has stressed form and function at the expense of security.
24 Libsafe has apparently now been turned over to Avaya Labs http://www.avaya.com for keeping
and maintenance.
2/6/2003 Page 20 of 24
© SANS Institute 2002, As part of the Information Security Reading Room. Author retains full rights.
buffers and other coding errors that could possibly lead to buffer overrun conditions.
7. Use Compiler Enhancement Tools. Although a relatively new concept, several compiler add-on tools have recently been made available that work closely with function return address space to prevent overwriting. One such tool, Stack Shield (http://www.angelfire.com/sk/stackshield), provides protection by taking a copy of RET and temporarily placing it in a location not subject to overflow attacks. Upon return, the two address values are compared. If they are different, the return address has been. modified and Stack Shield terminates the program. A somewhat similar tool, Stack Guard (http://www.immunix.org/stackguard.html), is able to detect a return address
being overwritten in real time. When it does, it proceeds to terminate the
program. full rights
8. Disable Stack Execution. Although it requires the operating system kernel
to be recompiled, patches are available forretainssomeversions of UNIX that render the stack non-executable. Since most buffer overrun exploits depend on an
executable stack, this modification will essentially stop them dead in their tracks. A patch for the Linux kernel has been made available by the Openwall Project (http://www.openwallAuthor.com).
9. Know What Is On Your System. Awareness of what is on your system and who has the privileges to execute it is essential. SUID root executable, and
root owned world writable files and directories are the favorite target of many attacks. Find them, list them,2002, and know them. The following few simple commands may be your best friend:
Once your list is complete and in hand, programs are available to test each
for buffer overrunInstitutevulnerabilities. Should a “segmentation fault” be occur
during testing, chances are you have just discovered a vulnerable program.
10. Patch The Operating System And Application. Perhaps the very best
defense isSANSto stay informed and remain “offensive”. As new vulnerabilities are
discovered© and reported, apply the necessary patches and fixes promptly. If
you are in a Microsoft shop, this may get very tiresome very quickly. It may even seem like an endless task. But cheer up. Knowledge in increasing and understanding is improving. The diseased will be cured.
đang được dịch, vui lòng đợi..