Abstract:
A system and method determines whether software includes malicious code. A validation machine is instrumented with tools and monitors that capture the static and dynamic behavior of software. Software under examination is executed on the validation machine, and the tools and monitors are used to log data representative of the behavior of the software to detect vulnerable or malicious code. If possible, one or more operations are automatically performed on the software to enhance the security of the software by neutralizing the vulnerable or malicious code. Activities that cannot be neutralized automatically are flagged for human inspection. The software executed on the validation machine may be source code or non-source code, with different operations being disclosed and described in each case.

Description:
REFERENCE TO RELATED APPLICATION 
       [0001]    This application claims priority from U.S. Patent Application Ser. No. 61/015,462, filed Dec. 20, 2007, the entire content of which is incorporated herein by reference. 
     
    
     FIELD OF THE INVENTION 
       [0002]    This invention relates generally to computer systems and, in particular, to the instrumentation of a validation machine that gathers information about software and feeds this data into a learning or knowledge system operative to analyze different aspects of the software statically and dynamically and rates the program as safe or unsafe with some probability. 
       BACKGROUND OF THE INVENTION 
       [0003]    Verifying that software does not contain backdoors, vulnerabilities, or other unintended or malicious behavior is a very difficult task. Although no method can automatically detect all possible problems, the goal is to automatically analyze software behavior by a machine, with suspicious sections being passed on to a human for further inspection. 
       SUMMARY OF THE INVENTION 
       [0004]    This invention resides in a system and method of determining whether software includes malicious code. The method includes instrumenting a validation machine with tools and monitors that capture the static and dynamic behavior of software. Software under examination is executed on the validation machine, and the tools and monitors are used to log data representative of the behavior of the software to detect vulnerable or malicious code. If possible, one or more operations are automatically performed on the software to enhance the security of the software by neutralizing the vulnerable or malicious code. Activities that cannot be neutralized automatically are flagged for human inspection. 
         [0005]    The method may include the step of training the validation machine to automatically neutralize vulnerable or malicious code using knowledge gained through the human inspection. The method may include the step of installing drivers to monitor resources of interest by hooking into system calls. The method may further include the step of logging data representative of mouse, keyboard or other user inputs to determine if the software is performing suspicious operations with no associated user input. 
         [0006]    A firewall may be used to monitor network access, and/or internal operating system instrumentation (i.e., APIs) may be used to monitor and log activities of interest. A library of known trusted programs or malicious programs may be stored, with the method including the step of comparing the software to the stored programs to detect vulnerable or malicious code. Data mining techniques may also be used to find patterns indicative of malicious code. The machine may be interfaced to an unprotected network monitor hacker activities. A Bayesian network may be trained to recognize patterns between the logs to classify the behavior as likely safe or likely unsafe. 
         [0007]    The software executed on the validation machine may be source code or non-source code, with different operations being disclosed and described in each case. 
     
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0008]    According to this invention, we converted a Windows PC platform into an instrumented system for detecting malicious code. We labeled this platform the “validation machine.” The techniques generalize to other systems; however, including handheld devices such Palm Pilots, Blackberries, and cell phones or embedded devices like car computers and embedded systems. However, for proof of concept and wide applicability, we have chosen to illustrate the techniques using a PC. 
         [0009]    We broadly gather information about software code in question from as many angles as possible, and to feed this data into some form of learning or knowledge system, which rates the program as safe/unsafe with some probability. To do this we create “monitors” which analyze different aspects of the program statically and dynamically. Some of these monitoring categories include: 
         [0010]    Monitors Requiring Source Code 
         [0011]    Poorly written source code is a sign of potential vulnerabilities, so when source is available, we analyze it with commercial and custom tools to gather information to feed the analysis engine. Some of these include: 
         [0012]    1. Using code analysis tools like PC-LINT, LINTPlus, Purify, Coverity, and others to identify troublesome areas and problems with the code. However, these tools also report noise and often miss vulnerabilities put in purposely by a malicious author. More sophisticated techniques attempt to verify completely the security of the code, which in its entirety is proven impossible. Ideally, all available source code is run through a tool that is designed to spot security errors. 
         [0013]    2. Newer, safer libraries (libs) can be linked to the applications, improving security. Overflow bugs are sometimes found and posted online in common libs like zlib, libPNG, and libJPEG 1 . Without access to source code it is nearly impossible to fix exploits and prevent them in applications linked to other libraries. Microsoft is constantly updating its standard C libraries, making newer versions more secure than previous ones, and also offers advice on which old functions to avoid for security reasons.  1 Libjpeg is a commonly used open source library for reading/writing JPEG images. libPNG is for PNG images. Zlib is for compression. All three are commonly used, so an exploit found in one affects many products. 
         [0014]    3. Recompile the code with a newer compiler that has stack checking routines or technology in place. 2  GCC (a popular open source C/C++ compiler) and Microsoft are constantly adding security features to their compilers. For example, the basic buffer overflow shown above is no longer possible under code using either compiler, since there are “cookies” placed on the stack to prevent this. However, the security adds a few percent slowdowns. Microsoft&#39;s .NET platform has a lot of security features built in, so recompiling applications under .NET will add security for nearly free.  2 Stack-smashing protection is used to detect the most common buffer overflows by checking that the stack has not been altered when a function returns. If it has been altered, the program exits with a segmentation fault. Two such systems are StackGuard and ProPolice, both of which are extensions to gcc. As of gcc-4.1-stage2, the ProPolice (which appears to have obsoleted StackGuard) patch seems to have been incorporated into the mainline distribution. Microsoft .NET has similar code guards in place, and some flavors of Linux and Unix are implementing such features in the OS. A stack smashing article is at http://www.phrack.org/phrack/49/P49-14. 
         [0015]    4. Buffer checks—from compiler and dynamically, or by library or kernel updates. 
         [0016]    5. Using source code, a program can auto generate tests of small functions to detect weak points. This is coupled with the static analysis from above, and uses the information at runtime to check what the code is doing versus what it should be doing. 
         [0017]    Monitors When Source Code is Not Available 
         [0018]    Without source code, there are some things that can be done at runtime to make applications more secure and to detect suspicious behavior. Examples include: 
         [0019]    1. Logging file, registry (on Windows), configuration changes, network access, and other resource usage is mandatory. This allows an administrator to view the logs and look for suspicious activity. This is one area in which we intend to improve automation. 
         [0020]    2. Run in low-privilege modes and log access to items not allowed to the program. Never run a program above the privilege level needed to complete a task. 
         [0021]    3. Use virus detection. Most virus protection systems employ simple pattern matching of known exploit code to system files. They are well tested and work well, but cannot catch future threats, and are not designed to catch possible exploits. 
         [0022]    4. Rootkit detection. This is a new area on Windows, but one that is gaining ground. A rootkit installs itself and then hides by faking calls to system functions that look for bad files. Thus, once a rootkit is on a system, that system can never find the rootkit since the system now lies about itself. 
         [0023]    5. Auto hack programs by feeding bad data. Windows DLLs and .NET assemblies have information about functions and parameters supported. Automated programs throwing bad and random calls to these functions will often expose system errors, and this is an easy thing to test. Any binary applications that can have bad data thrown in automatically should be tested in this manner since it is cheap to do. 
         [0024]    6. Firewalls, inbound and outbound, should monitor network traffic and log activity. If anything is found to go bad, the logs can be examined (if they were not compromised). 
         [0025]    A workable combination requires knowledge of the source code and the runtime data and compares the two. Examples include: 
         [0026]    1. Buffer checking. The data can be compared form the known buffers in the source code and where they lie in memory, allowing a watcher process to monitor the program as it runs and report suspicious activity. 
         [0027]    2. Memory checking applications, like BoundsChecker, that use code instrumentation during a compile to place information in the executable. This instrumentation is then used to catch resource leaks and errors. 
         [0028]    3. Code coverage tools tell which sections of code have been executed. During development or testing complete code coverage should be obtained. If source has come from an outside vendor, obtaining complete code coverage while monitoring all activity provide a decent measure of the lack of any deliberately malicious code present. This, however, would not detect exploits. 
         [0029]    4. Test based on auto tests generated from code. This is coupled with the source code item above. 
         [0030]    Our invention uses a virtual 3  “validation machine” instrumented with various tools and monitors that capture static and dynamic behavior of software. Although all the types of monitors above can be added, for Phase I we only added a few for testing. The validation machine logs various forms of activity during normal use, catching and monitoring known exploit techniques, and flagging activity that is outside its understanding for human inspection. This human guidance trains the validation machine to detect vulnerable and malicious code using standard machine learning techniques.  3 VMWare, www.vmware.com 
         [0031]    In accordance with the invention, Windows is installed on a virtual machine. The virtual machine provides a rapid way to roll-back changes to a system, as well as to have before and after snapshots of a system for forensic comparison. Drivers are installed to monitor resources of interest by hooking into system calls. For Windows, the necessary drivers are available with source from www.sysinternals.com, and include the following 
         [0032]    DiskMon—monitor disk activity 
         [0033]    FileMon—monitor file accesses 
         [0034]    RegMon—monitor registry calls 
         [0035]    A newer process monitor from the same location gives an integrated program with the above three functions. 
         [0036]    User activity, such as mouse and keyboard input, may optionally be logged as well. If the program is performing suspicious operations with no associated user input, this should be noted. Monitoring keyboard and mouse use will help determine this type of behavior. Other drivers may be developed or obtained on an as-needed basis. 
         [0037]    A firewall such as ZoneAlarm (www.zonealarm.com) may be used to monitor network access, with the internal Windows instrumentation API being used to monitor and log other activities of interest. All of these applications either log their information, or could be modified with source to do so. The goal is to log all machine activity to a central location so we can analyze program behavior. 
         [0038]    For programs for which we have source code, we ran source analysis tools (PC-LINT). We could instrument the code with monitoring tools like Bounds Checker (www.compuware.com) to further offer diagnostics and information on the code. GCC and the Microsoft C/C++ compiler ship with source code to the main libraries, so we can instrument those to monitor memory accesses and releases, calls to dangerous C Library functions, etc. Again, the idea is to gather as much logged data from the application as possible. This step will detect possible buffer overflows by code analysis. 
         [0039]    While a program is running, we keep track (like a debugger or code coverage tool does) of which code has been executed and what the effects on the logs were. A kernel module may be used to carry this out this automatically. When new or untrusted code is run for the first time, if any suspicious activity is logged as well as where in the code the activity occurred. 
         [0040]    For programs that do not have source available, we can obtain such coverage by dynamic disassembly, using tools like IDAPro (www.datarescue.com) to disassemble the code, determine where executable code was in memory, and then tag it as trusted or untrusted as it executes. In any case, we can link code in memory with activity in the log files. 
         [0041]    We gathered a baseline corpus of known trusted programs and malicious programs. Trusted sources include open source applications, applications from trusted vendors, and programs we have written and vetted. Malicious programs can easily be found on the net by downloading known hacker software and tools, or perhaps from working with virus software vendors like Symantec (www.symantec.com). In either case, we should be able to find many programs of known trustability to train our software. 
         [0042]    We ran programs and logged data for analysis. VMWare allows setting up multiple, independent, networked machines on one computer, and is ideal for testing like this. Each machine thinks it is the only machine, and so would behave as such, perhaps attacking other machines on its network. This is cost effective since it only requires one PC and no physical network. We gathered test data using this corpus of programs, with data mining techniques being used to find patterns indicative of malicious code. 
         [0043]    The machine may be hooked to an unprotected network (a DSL line with no firewall, for example), to monitor what happens when external black hats try their skill on the machine. This too helps gather data for weak and malicious programs. 
         [0044]    According to the invention, an algorithm may be trained to detect suspicious behavior, warn about possible weak source code, and attempt to trigger malicious behavior through sending bad data to an application. This will preferably be a Bayesian network, trained to notice patterns between the logs and then classify the behavior as likely safe or likely unsafe, much in the same way spam filters use patterns to classify email. Other approaches classifying the data, using data mining techniques, agent based systems, or whatever other types of learning and decision aid algorithms may also be applied this problem. 
         [0045]    The end result is a standalone system, the validation machine, that can be started from baseline whenever desired with minimal work, which can be fed a program with or without source code, and that will use as many tools as have been added to verify program behavior, using adaptive methods to offer assistance on program safety. All information gained from the program will be accessible for humans to go over if desired, but the main benefit is automated, robust, and thorough analysis of all information available to test program behavior.