# Patent

## Title
Stream scanning through network proxy servers

## Abstract

Methods, systems, and computer readable media for managing transmission of a requested computer file (140) from a remote host compute (125) to a client computer (120). A proxy server computer (110) receives a first chunk (315) of the requested computer file (140). The proxy server (120) generates a hash of the chunk (315) and compares the hash to a hash of a chunk of previously downloaded file. If the two hashes are identical, the chunk (315) of the requested computer file (140) is passed to the client computer (120).

## Background
TECHNICAL FIELD
This invention relates generally to enhancing the performance of malicious code detection methods for proxy server computers. More specifically, this invention relates to methods for selectively passing forward file contents that have previously been scanned for the presence of malicious code.
BACKGROUND ART
During the brief history of computers, system administrators and users have been plagued by attacking agents such as viruses, worms, and Trojan Horses, which are designed to disable host computer systems or propagate themselves to connected systems.
In recent years, two developments have increased the threat posed by these attacking agents. Firstly, increased dependence on computers to perform mission critical business tasks has increased the economic cost associated with system downtime. Secondly, increased interconnectivity among computers has made it possible for attacking agents to spread to a large number of systems in a matter of hours.
Many network systems employ proxy servers to provide additional protection against attacking agents. These proxy servers manage interaction such as HyperText Transport Protocol (HTTP) communications between client systems and outside systems. This manner of setup allows network administrators to control and monitor those sites which are accessed by users and institute an additional layer of protection by configuring the proxy server to scan any incoming files for infection by attacking agents.
However, this additional layer of protection can place significant performance demands on the proxy and greatly increase transmission latency. Many attacking agents can be detected only after a file has been fully downloaded. Detection of these agents typically requires access to non-sequential sections of the file as well as the ability to emulate the execution of the file and monitor its output. The time required to fully download a large file and scan it before beginning to transmit the file to a client can generate frustrating delays for users of client systems.
What is needed is a method for reducing the latency of files transmitted through scanning proxy servers.
DISCLOSURE OF INVENTION
The present invention comprises methods, systems, and computer readable media for managing transmission of a requested computer file (140) from a remote host computer (125) to a client computer (120). A proxy server computer (110) receives a first chunk (315) of the requested computer file (140). The proxy server (120) generates a hash of the chunk (315) and compares the hash to a hash of a chunk of previously downloaded file. If the two hashes are identical, the chunk (315) of the requested computer file (140) is passed to the client computer (120).



BRIEF DESCRIPTION OF THE DRAWINGS
These and other more detailed and specific objects and features of the present invention are more fully disclosed in the following specification, reference being had to the accompanying drawings, in which:
FIG. 1 is a high level block diagram illustrating interaction among a remote host computer 125, a proxy server computer 110, and a client computer 120.
FIG. 2 is a high level block diagram illustrating a more detailed view of a proxy server computer system 110.
FIG. 3 is a more detailed view of the memory 206 of the proxy server computer 110.
FIG. 4 is a block diagram illustrating an entry 415 in the hash table 325 within memory 206.
FIG. 5 is a more detailed view of a security module 310.
FIG. 6 is a flow chart illustrating an embodiment of the present invention.



DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
The present invention comprises systems, methods, and computer readable media for verifying that a computer file 140 is free of malicious code before passing the computer file 140 to a client computer 120. As used herein, the term “malicious code” refers to any program, module, or piece of code that enters a computer without an authorized user's knowledge and/or without an authorized user's consent. The term “attacking agent” includes Trojan Horse programs, worms, viruses, and other such insidious software that insert malicious code into a computer file 140. An attacking agent may include the ability to replicate itself and compromise other computer systems.
FIG. 1 is a high level block diagram illustrating interaction among a remote host computer 125, a proxy server computer 110, and a client computer 120. The client computer 120 is a conventional computer, which may be employed by a user for accessing Web content and performing other computing tasks. The remote host computer 125 can be any computer system which a user of the client computer 120 may wish to access. In one embodiment, the remote host computer 125 is an HTTP server on the Internet.
The proxy server computer 110 manages the transfer of files 140 from the remote host computer 125 to the client computer 120. In one embodiment, the proxy server computer 110 shares an internal Local Area Network (LAN) or Wide Area Network (WAN) with the client computer 120, and controls all access between the client computer 120, and computers outside the internal network. In an alternate embodiment, the proxy server 110 communicates with the client computer 120 through the Internet and uses the proxy server computer 110 to provide an additional layer of security.
When the client computer 120 attempts to access a computer file 140 stored on the remote server 125, it transmits a request to the proxy server computer 110 that includes a Uniform Resource Locator (URL) for the computer file 140. The proxy server computer 110 receives the request and transmits a conventional file retrieval request to the remote host computer 125, which transmits the computer file 140 to the proxy server computer 110.
The proxy server computer 110 verifies that the computer file 140 is free of malicious code. The process of verifying that the computer file 140 is free of malicious code is described in greater detail with respect to FIG. 6. If the computer file 140 is free of malicious code, the proxy server computer 110 transmits the computer file 140 to the client computer 120.
If the computer file 140 contains malicious code, the proxy server computer 110 blocks transmission of the file 140. Alternately, the proxy server computer 110 can remove the malicious code from the computer file 140 and transmit the cleaned file to the client computer 120. In one embodiment, the proxy server computer 110 maintains a cache of recently downloaded files to minimize bandwidth demands between the proxy server computer 110 and the remote host computer 125.
While in the present embodiment, the proxy server 110 interacts with an independent client computer system 120, in an alternate embodiment, the functions of the client computer system 120 can be performed by an application running on an enterprise server or any combination of software and hardware.
Additionally, while the embodiments disclosed below refer to a proxy server 120 which manages HTTP communications between client computers 120 and remote host computer 125, in alternate embodiments, the proxy server also manages File Transfer Protocol (FTP) communications and streaming media communication.
FIG. 2 is a high level block diagram illustrating a more detailed view of a proxy server computer system 110. Illustrated are a processor 202 coupled to a bus 204. There may be more than one processor 202. Also coupled to the bus 204 are a memory 206, a storage device 208, a keyboard 210, a graphics adapter 212, a pointing device 214, and a network adapter 216. A display 218 is coupled to the graphics adapter 212.
The processor 202 may be any specific or general-purpose processor such as an INTEL x86 or POWERPC-compatible central processing unit (CPU). The storage device 208 may be any device capable of holding large amounts of data, such as a hard drive, compact disk read-only memory (CD-ROM), DVD, or some other form of fixed or removable storage device.
FIG. 3 is a more detailed view of the memory 206 of the proxy server computer 110. The memory 206 includes a security module 310, which is configured to verify that a computer file 140 is free of infection before passing the computer file 140 to the client computer 120. As used herein, the term “module” refers to computer program logic and/or any hardware or circuitry utilized to provide the functionality attributed to the module. A module may be implemented in hardware, software, firmware, or any combination thereof.
When the proxy server computer 110 transmits an HTTP request to the remote host computer 125, the remote host computer 125 begins to stream the computer file 140 to the proxy server computer 110.
When the proxy server computer 110 receives a first chunk 315 of the computer file 140, the security module 308 determines whether the chunk 315 is identical to a previously downloaded file chunk 315. The proxy server 110 checks in a hash database for a hash entry having an identifier that indicates that the hash stored in the hash entry is a hash of a chunk the same file and compares the newly downloaded hash to the stored hash. The organization of the hash database is described in greater detail with respect to FIG. 4. As used herein, the term “chunk” refers to any continuous section of a file 140. In one embodiment, chunks are 64 KB or smaller. The security module 310 then generates a hash of the file chunk 315.
As used herein, a “hash” or “hash function” is a substantially collision free one-way function, from a variable sized input to a fixed size output. Normally, the output is smaller than the input. “One-way” means that it is easy to compute the output from the input, but computationally infeasible to compute the input from the output. “Substantially collision free” means that it is very difficult to find two or more inputs that hash to the same output. Examples of suitable hash functions usable in the present invention are MD5 and a CRC (Cyclic Redundancy Check) function.
The security module 310 then checks the hash table 325, which stores hashes of previously downloaded chunks, for a previously generated hash of the first chunk 315 of the requested computer file 140. The hash table 325 is stored in a local or remote cache and stores hashes of file chunks 315. The hash table 325 is periodically emptied when new threat definitions are made available to the security module 310. Alternately, the hash table 325 may be updated at regular intervals.
If the previously generated hash is present in the hash table 325, the security module 310 compares it to the hash of the first chunk of the requested computer file 140. If a hash corresponding to the new chunk 315 is not present or is not identical, the security module 310 downloads the full computer file 140 to the client computer 120. The security module 310 scans the computer file 140 for the presence of malicious code. If the computer file 140 contains malicious code, the security module 308 blocks transmission of the computer file 140. If the computer file 140 does not contain malicious code, the computer file 140 is transmitted to the client computer 120.
If the hashes are identical, the security module 310 passes the first chunk to the client computer 120. This process is repeated for each succeeding chunk until a chunk is received whose hash does not match the corresponding hash in the hash table 325, or the computer file 140 is fully transmitted to the client computer 120. This process is described in greater detail with respect to FIG. 6.
FIG. 4 is a block diagram illustrating an entry 415 in the hash table 325. The entry includes a hash 425 of a chunk 315 of a previously downloaded computer file 140. The entry 415 additionally includes a file identifier 430 that indicates the computer file 140 from which the associated chunk 315 was extracted. The file identifier 430 is used by the security module 310 to initially locate a hash of a requested computer file 140. The file identifier 430 typically includes the name of the computer file 140, but may also include characteristics such as its size and associated URL. In an alternate embodiment, the hash 425 itself serves as an identifier. The entry 415 additionally includes a hash ID 435 indicating a location in the computer file 140 from which the chunk 310 was taken. For example, in one embodiment the hash ID 435 indicates that the hash 425 is extracted from a chunk 315 located between offsets CA0000 and CAFFFF (memory locations in hexadecimal notation). In an alternate embodiment, a single hash entry 415 includes all of the hashes for a single computer file 140.
FIG. 5 is a more detailed view of a security module 310. The security module 310 comprises a group of constituent modules that perform various functions of the security module 310.
The security module 310 includes a selection module 508. The selection module 508 is configured to compare a hash of a chunk 315 of a requested computer file 140 to a previously generated hash 425. If the two hashes are identical, the selection module 508 passes the chunk 315 to the client computer 120. If the two hashes are not identical, the selection module 508 holds the chunk 315 until the entire computer file 140 has been downloaded.
The security module 310 additionally includes a hash generator 504. The hash generator 504 is configured to generate hashes of chunks 315 of files 140 for comparison with previously generated hashes stored in the hash table 325.
The security module 310 further includes a scanning module 502. The scanning module 502 is configured to check a computer file 140 for the presence of malicious code. The scanning module 502 typically checks selected areas of a computer file 140 for distinct code sequences or other signature information. Alternately, the scanning module 502 may check the computer file 140 for distinctive characteristics, such as a particular size.
The scanning module 502 can additionally apply more complex detection techniques to a computer file 140. For example, the scanning module 502 can detect the presence of a polymorphic encrypted virus. A polymorphic encrypted virus (“polymorphic virus”) includes a decryption routine and an encrypted viral body. To avoid standard detection techniques, polymorphic viruses use decryption routines that are functionally the same for each infected computer file 140, but have different sequences of instructions. To detect these viruses, the scanning module 502 applies an algorithm that loads the executable computer file 140 into a software-based CPU emulator acting as a simulated virtual computer. The computer file 140 is allowed to execute freely within this virtual computer. If the executable computer file 140 does contain a polymorphic virus, the decryption routine is allowed to decrypt the viral body. The scanning module 502 detects the virus by searching through the virtual memory of the virtual computer for a signature from the decrypted viral body. The scanning module 502 may also be configured to detect metamorphic viruses, that, while not necessarily encrypted, also vary the instructions stored in the viral body.
Furthermore, the security module 310 includes an update module 506. The update module 506 is configured to update the hash table 325 after a computer file 140 has been scanned for the presence of malicious code. The update module 506 generates new entries in the hash table 325 for files lacking entries and updates hashes 435 for files 140 that already have entries 415 in the hash table 325.
FIG. 6 is a flow chart illustrating an embodiment of the present invention. The process begins with the proxy server computer 110 receiving 600 a request to download a computer file 140 from a remote host computer 125. The proxy server computer 110 begins downloading 605 the computer file 140 from the remote host computer 125. When the proxy server computer 110 receives the first chunk 310 of the computer file 140, the selection module 508 checks 615 the hash table 325 for the presence of an identical hash. Step 615 enables the proxy server computer 110 to determine if the file 140 has been previously downloaded, as it is unlikely that the hash table 310 would store an identical hash if the same file 140 had not been downloaded earlier.
If an identical hash does not appear in the hash table 325, the proxy server computer 110 allows the complete computer file 140 to download 620 to the proxy server 110. When the computer file 140 has been downloaded in its entirety, the scanning module 502 scans the computer file 140 to determine 625 whether the computer file 140 contains malicious code. If the computer file 140 is found by the scanning module 502 to contain malicious code, the selection module 508 blocks 627 transmission of the computer file 140 to the client computer. Alternately, the scanning module 502 can repair the computer file 140 and transmit the repaired computer file 140 to the client computer 120. In one embodiment, the repaired computer file 140 is cached on the proxy server computer 125. If a similarly infected file 140 is detected by the proxy server computer 125, it can transmit the cached repaired file 140 to the client computer 120, rather than repair the infected file 140.
If the computer file 140 is found by the scanning module 502 to be free of malicious code, the hash generator 604 generates a hash of all the constituent chunks 315 of the computer file 140 and stores them in new entries in the hash table 325. These hashes are stored for later comparison against future files that the proxy server computer 110 downloads at the request of the client computer 120. The computer file 140 is then transmitted 635 to the client computer 120. In an alternate embodiment, the hash generator generates new hashes of the chunks 315 of the computer file 140 as the chunks 315 are received, rather than generating the hashes after the file download is completed.
If a hash that is identical to the generated hash of the downloaded chunk 315 of the computer file 140 appears in the hash table 325, this means that the file 140 has likely been downloaded and scanned by the proxy server 110. Thus, the selection module 508 transmits 638 the chunk 315 to the client computer 120. The hash generator 504 then generates 640 a hash of the file chunk 315, and the selection module 508 compares 645 the hash to a corresponding hash in the hash table 325. If the hashes are different or if no corresponding hash exists in the hash table 325, the selection module 508 determines that the file 140 is not identical to a previously scanned file and ends 650 the download.
In an alternate embodiment, the selection module 508 permits the file 140 to download to the proxy server 110 as indicated in step 620. The scanning module 502 then scans 625 the file 140 for the presence of malicious code. If the file 140 contains malicious code, the scanning module 502 can cancel 627 the download the file 140 or clean the file 140 of malicious code and pass it to the client computer 120. If the file 140 does not contain malicious code, the selection module 508 passes 635 the file 140 to the client computer 120 and updates the associated hash entries 415 to store the hashes 425 of the new version of the file 140.
If more chunks 315 are determined 660 to remain in the computer file 140, steps 640, 645, 650, and 655 are repeated until the computer file 140 has been transmitted.
The above description is included to illustrate the operation of the preferred embodiments and is not meant to limit the scope of the invention The scope of the invention is to be limited only by the following claims. From the above discussion, many variations will be apparent to one skilled in the relevant art that would yet be encompassed by the spirit and scope of the invention.

## Claims

1. A method for managing transmission of a requested computer file from a remote host to a client, the method comprising the steps of:
receiving a chunk of the requested computer file from the remote host;
generating a hash of the chunk of the requested computer file;
comparing the hash of the chunk of the requested computer file to a hash of a chunk of a previously downloaded computer file; and
transmitting the chunk of the requested file to the client when the hash of the chunk of the requested computer file is identical to the hash of the chunk of the previously downloaded computer file.

2. The method of claim 1, further comprising the step of receiving a remainder of the requested computer file when the hash of the chunk of the requested computer file is not identical to the hash of the chunk of the previously downloaded computer file.

3. The method of claim 2, further comprising the step of scanning the requested computer file for the presence of malicious code.

4. The method of claim 3, further comprising the step of transmitting the requested computer file to the client when the requested computer file is found to be free of malicious code.

5. The method of claim 3, further comprising the step of generating new hashes of chunks of the requested computer file when the requested computer file is free of malicious code.

6. The method of claim 3, further comprising the steps of:
determining that the file contains malicious code;
removing the malicious code from the file; and
transmitting the file to the client.

7. The method of claim 6, further comprising storing a repaired copy of the file in a cache.

8. The method of claim 7, further comprising:
downloading a chunk of a second requested computer file;
generating a hash of the chunk of the second requested computer file;
comparing the hash of the chunk of the second requested computer file to a hash of a chunk of the previously downloaded computer file; and
transmitting the repaired copy of the file to the client when the hash of the chunk of the second requested computer file is not identical to the hash of the chunk of the previously downloaded computer file.

9. The method of claim 1, further comprising the step of ending a transmission of the requested computer file to the client when the hash of the chunk of the requested computer file is not identical to the hash of the chunk of the previously downloaded computer file.

10. The method of claim 1, wherein the step of comparing the hash of the chunk of the requested computer file to a hash of a chunk of a previously downloaded computer file comprises the sub-steps of:
checking a cache for a hash of a chunk of a computer file corresponding to the requested computer file; and
determining that the hash of the chunk of the requested computer file is not identical to a hash of a chunk of a previously downloaded computer file when the cache does not contain a hash of a chunk of a computer file corresponding to the requested computer file.

11. A system for managing transmission of a requested computer file from a remote host to a client, the system comprising:
a selection module configured to:
receive a chunk of the requested computer file from the remote host;
compare a hash of the chunk of the requested computer file to a hash of a chunk of a previously downloaded computer file; and
transmit the chunk of the requested file to the client when the hash of the chunk of the requested computer file is identical to the hash of the chunk of the previously downloaded computer file; and

a hash generator, coupled to the selection module, and configured to generate a hash of the chunk of the requested computer file.

12. The system of claim 11, wherein the selection module is further configured to receive a remainder of the requested computer file when the hash of the chunk of the requested computer file is not identical to the hash of the chunk of the previously downloaded computer file.

13. The system of claim 12, further comprising a scanning module, coupled to the selection module, and configured to scan the requested computer file for the presence of malicious code.

14. The system of claim 13, wherein the selection module is further configured to transmit the requested computer file to the client when the requested computer file is found by the scanning module to be free of malicious code.

15. The system of claim 13, wherein the hash generator is further configured to generate new hashes of chunks of the requested computer file when the scanning module has scanned the requested computer file and the requested computer file is found by the scanning module to be free of malicious code.

16. The system of claim 11, wherein the selection module is further configured to end a transmission of the requested computer file when the hash of the chunk of the requested computer file is not identical to the hash of the chunk of the previously downloaded computer file.

17. A computer-readable medium containing computer code instructions for managing transmission of a requested computer file from a remote host to a client, the computer code comprising instructions for:
receiving a chunk of the requested computer file from the remote host;
generating a hash of the chunk of the requested computer file;
comparing the hash of the chunk of the requested computer file to a hash of a chunk of a previously downloaded computer file; and
transmitting the chunk of the requested file to the client when the hash of the chunk of the requested computer file is identical to the hash of the chunk of the previously downloaded computer file.

18. The computer readable medium of claim 17, wherein the instructions for managing transmission of a requested computer file from a remote host to a client further comprise instructions for receiving a remainder of the requested computer file when the hash of the chunk of the requested computer file is not identical to the hash of the chunk of the previously downloaded computer file.

19. The computer readable medium of claim 18, wherein the instructions for managing transmission of a requested computer file from a remote host to a client further comprise instructions for scanning the requested computer file for the presence of malicious code.

20. The computer readable medium of claim 19, wherein the instructions for managing transmission of a requested computer file from a remote host to a client further comprise instructions for transmitting the requested computer file to the client when the requested computer file is found to be free of malicious code.

21. The computer readable medium of claim 20, wherein the instructions for managing transmission of a requested computer file from a remote host to a client further comprise instructions for generating new hashes of chunks of the requested computer file when the requested computer file is found to be free of malicious code.

22. The computer readable medium of claim 17, wherein the instructions for managing transmission of a requested computer file from a remote host to a client further comprise instructions for ending a transmission of the requested computer file to the client when the hash of the chunk of the requested computer file is not identical to the hash of the chunk of the previously downloaded computer file.

23. The computer readable medium of claim 17, wherein the instructions for comparing the hash of the chunk of the requested computer file to a hash of a chunk of a previously downloaded computer file comprises instructions for:
checking a cache for a hash of a chunk of a computer file corresponding to the requested computer file; and
determining that the hash of the chunk of the requested computer file is not identical to a hash of a chunk of a previously downloaded computer file when the cache does not contain a hash of a chunk of a computer file corresponding to the requested computer file.