Scripts are used in interpretive environments to automate tasks. The scripts are interpreted via an interpreter. Conceptually, the interpreter operates in a serial manner, inputting a string from the script and interpreting the string into a command. The command is associated with a set of executable instructions that perform the command when executed by a processor. Security problems arise when one or more strings are interpreted into malicious and/or harmful commands (e.g., format c:). There are various ways in which a malicious and/or harmful command can be “inserted” into an otherwise harmless script.
One technique at minimizing the likelihood that a malicious and/or harmful command is inserted into a script is by requiring the script to be digitally signed. Various techniques have been developed to digitally sign scripts. In general, digitally signing scripts involves computing a hash of the script and then signing the hash with a digital certificate issued from a trusted certificate authority. The digital certificate may include a chain of certificates ending with a root certificate. The signed hash and each of the certificates included in the chain are combined into a digital signature block. The digital signature block is converted into a text signature block using base64 encoding techniques. The text signature block may then be appended to the script.
Using the above technique, the digitally signed script undergoes a verification process before the script is processed by the interpreter. The verification process creates a hash value of the script. The hash value is compared with the digitally signed hash value obtained from the text signature block. If the two hash values are the same, the original script has not been modified. Therefore, the interpreter is allowed to process the script. If the two hash values are not the same, the original script has been modified. Therefore, the interpreter is not allowed to process the script. The verification process is an option that can be selected by a user. If this option is selected, the user greatly reduces the likelihood that the interpreter will process a script having malicious and/or harmful commands.
Unfortunately, however, many times users do not have this option selected. In fact, in certain situations, users may blindly rely on that fact that the script is signed as an indication that the script is secure and safe to process. If this occurs, the interpreter may process a digitally signed script that has had malicious and/or harmful commands inserted into the script after being digitally signed. Thus, digitally signing the script, by itself, is ineffective in preventing the processing of scripts which have malicious and/or harmful commands inserted within them.
Thus, there is a continual demand for finding solutions that help minimize the likelihood of interpreting malicious and/or harmful commands while processing scripts.
The techniques and mechanisms described herein are directed to an interpreter security mechanism that minimizes potential security problems while interpreting a script written with a scripting language. The interpreter security mechanism recognizes a marker that indicates a beginning for a set of non-interpreted lines. Upon recognizing the marker, the interpreter refrains from interpreting subsequent lines in the script until an end of marker occurs or an end of file occurs. The end of marker indicates that the interpreter can resume interpreting the lines in the script that follow the end of marker. The end of marker may also be an end of a file, in which case interpreting the script has been completed.
This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
Non-limiting and non-exhaustive embodiments are described with reference to the following figures, wherein like reference numerals refer to like parts throughout the various views unless otherwise specified.
Briefly, the present interpreter security mechanism and technique minimizes the security risks associated with interpreting a script written with a scripting language. The interpreter security mechanism recognizes a marker within a script that indicates a beginning for a set of non-interpreted lines. Once the marker is recognized, the interpreter refrains from interpreting the subsequent lines in the script until an end of marker is recognized. Upon recognizing the end of marker, the interpreter resumes interpreting the subsequent lines in the script. Alternatively, the end of marker may be an end of a file, in which case interpreting the script has been completed. The marker may indicate a start of a digital signature block, a block of comments, or the like. Thus, as will be described below, even if a user does not have the verification option selected for verifying digital signatures, malicious and/or harmful commands inserted within the digital signature block will not unknowingly be processed by the interpreter. These and other advantages will become clear after reading the following detailed description.
Exemplary Computing Environment
The various embodiments of the present interpreter security mechanism may be implemented in different computer environments. The computer environment shown in
With reference to
Computing device 100 may have additional features or functionality. For example, computing device 100 may also include additional data storage devices (removable and/or non-removable) such as, for example, magnetic disks, optical disks, or tape. Such additional storage is illustrated in
Computing device 100 may also contain communication connections 128 that allow the device to communicate with other computing devices 130, such as over a network. Communication connection(s) 128 is one example of communication media. Communication media may typically be embodied by computer-readable instructions, data structures, program modules, or other data in a modulated data signal, such as a carrier wave or other transport mechanism, and includes any information delivery media. The term “modulated data signal” means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, RF, infrared and other wireless media. The term computer-readable media as used herein includes both storage media and communication media.
Various modules and techniques may be described herein in the general context of computer-executable instructions, such as program modules, executed by one or more computers or other devices. Generally, program modules include routines, programs, objects, components, data structures, etc. for performing particular tasks or implement particular abstract data types. These program modules and the like may be executed as native code or may be downloaded and executed, such as in a virtual machine or other just-in-time compilation execution environment. Typically, the functionality of the program modules may be combined or distributed as desired in various embodiments.
An implementation of these modules and techniques may be stored on or transmitted across some form of computer readable media. Computer readable media can be any available media that can be accessed by a computer. By way of example, and not limitation, computer readable media may comprise “computer storage media” and “communications media.”
Interpreter 204 (also commonly referred to as a script engine) may be one or more software modules implemented within the operating system 106 illustrated in
However, by implementing the present interpreter security mechanism, the risk of executing harmful commands within script 202 may be significantly reduced. The interpreter 204 includes a security mechanism 206. Briefly, the security mechanism 206, described in detail below in conjunction with the flow diagram illustrated in
Because script 300 is text, a user may easily open the script 300 using any text editor and review the script 300. The user may be interested in reviewing the lines 302 to determine whether the user wants to run the script or not. In addition, the user may review the script to see whether there are any harmful commands written within the script. While reviewing the script, the user may notice that the script is digitally signed and notice the beginning marker 310 indicating a start of a digital signature block. As mentioned above, because script 300 is digitally signed, the user may rely on the digital signature block as an indication that it is safe to process the script and will not verify the digital signature before processing. Thus, a malicious and/or harmful command 322 that is inserted within the digital signature block may go unnoticed by the user. This is especially true in the situation where the digital signature block is quite long and unintelligible to the user. In some cases, the digital signature block may be around 200 lines long regardless of the length of the actual script. Without the present interpreter security mechanism, the malicious and/or harmful command 322 would be executed. However, as will be described below in conjunction with the flow diagram in
Again, the user may not notice the malicious and/or harmful command 422 while reviewing the script within an editor. As will be described below, the interpreter security mechanism may perform a difference calculation to determine whether a phony beginning marker has been maliciously inserted to give the appearance of an actual beginning marker. For example, the string “End of Processing” may be modified by removing an “s” to make the string “End of Procesing”. Then, when a user is reviewing script 400 and notices the phony beginning marker, the user may believe that the phony beginning marker is the actual beginning marker. Therefore, the user may not review the lines after the phony beginning marker. However, as will be described below in conjunction with the flow diagram in
At block 502, a line from the script is retrieved. Retrieving the line is performed in any well known manner. Processing continues at optional block 504.
At optional block 504, a difference calculation is performed on the line. In one embodiment, the difference calculation may be an edit distance calculation. The edit distance calculation is performed to determine whether the line contains a phony marker that is masquerading as a beginning marker. Edit distance calculations are typically performed by spell checkers when determining how to correct a misspelled word. In general, the calculation determines the minimum number of operations that must be performed on a first string to obtain a second string. Any commercially available edit distance calculation may be used. The calculation uses a list of known keywords for the beginning markers during its calculation. The known keywords may be hard-coded within the interpreter. Processing continues at optional decision block 506.
At optional decision block 506, a determination is made whether the line contains a phony marker. If the line contains a phony marker, processing continues at optional block 508.
At optional block 508, a warning message is issued to the user that alerts them to the phony marker. By issuing the warning message, the user is alerted that there is a phony marker that may have been mistaken as a beginning marker when the user reviewed the script. Processing continues at optional decision block 510.
At optional decision block 510, a determination is made whether the user has selected to proceed with the processing of the script or to quit processing the script. However, the interpreter may also automatically quit processing of the script after sending the warning message or after identifying the phony marker. If the user wishes to proceed, processing continues at block 512. Otherwise, processing continues to the end and processing is complete.
At block 512, the line is processed. If the line is a phony marker that begins with a comment designator, the interpreter ignores the line. Processing continues at decision block 514.
At decision block 514, a determination is made whether there is another line within the script. If there is another line, processing loops back to block 502 to get another line and proceeds as described above. Otherwise, processing is complete.
If the determination at optional decision block 506 concludes that the line does not contain a phony marker, processing continues at decision block 516.
At decision block 516, a determination is made whether the line contains one of the keywords for a beginning marker recognized by the interpreter. As mentioned above, the beginning marker may indicate the start of a digital signature block, a comment block, or the like. If the line does not contain a beginning marker, processing continues at block 512 as described above. However, if the line does contain a beginning marker, processing continues at decision block 518.
At decision block 518, a determination is made whether there is a subsequent line after the beginning marker. Typically, there will be at least one subsequent line after the beginning marker. Once all the subsequent lines have been processed, processing is complete and proceeds to the end. Otherwise, processing continues at block 520.
At block 520, a subsequent line is retrieved from the script. Processing continues at optional decision block 522.
At optional decision block 522, a determination is made whether the subsequent line contains a command. As described above in the example scripts shown in
At decision block 524, a determination is made whether the line is an end marker. If the line is an end marker, the line represents the last line in the non-interpreted block. Processing continues at “C” to check whether there is another line in the script and proceeds as described above in conjunction with decision block 514. If the line is not an end marker, processing loops back to decision block 518 and proceeds as described above.
If the determination at optional block 522 concludes that the line does contain a command, processing continues at optional block 526.
At optional block 526, a warning message is issued to the user that alerts the user that a potentially malicious and/or harmful command has been encountered. By issuing the warning message, the user is alerted that there is a command that may have been overlooked when the user reviewed the script. Processing continues at optional decision block 528.
At optional decision block 528, a determination is made whether the user has selected to stop processing the script. However, the interpreter may also automatically quit processing the script after sending the warning message or after identifying the command within the non-interpreted block. If the user wishes to stop processing the script, processing continues to the end. Otherwise, processing continues at optional decision block 530.
At optional decision block 530, a determination is made whether the user has selected to skip the command. For example, the user may review the line that generated the warning message and determine that the command should not be processed. Then, instead of exiting the entire script, the user may select to skip the command and proceed to “B” which loops back to decision block 518 and continues as described above. If, however, the user reviews the line that generated the warning message and determines that the command can be processed, processing continues at optional block 532. When optional decision blocks 528 and 530 are not implemented, the interpreter may automatically skip the command without requesting input from the user.
At optional block 532, the line is processed. Processing continues at “B” which proceeds back to decision block 518 to check if there is another line in the script. Processing then continues at described above.
One skilled in the art will appreciate that the beginning and end marker may be various keywords. In addition, the interpreter may have various options for determining whether a line contains a phony marker. Then, by utilizing the present interpreter security mechanisms while processing the script, an administrator responsible for running the script may be provided information alerting him to potential security problems within the script.
Using the above teachings, the present interpreter security mechanisms may be implemented in different interpretive environments by those skilled in the art. Each of the interpretive environments can then achieve the advantages outlined above. For example, the interpretive security mechanism may be implemented within the MONAD shell developed by the Microsoft Corporation of Redmond, Washington.
While example embodiments and applications have been illustrated and described, it is to be understood that the invention is not limited to the precise configuration and resources described above. Various modifications, changes, and variations apparent to those skilled in the art may be made in the arrangement, operation, and details of the methods and systems of the present invention disclosed herein without departing from the scope of the claimed invention.