[go: up one dir, main page]

JP2006172003A - Program execution monitoring apparatus, program execution monitoring method, and program creation method - Google Patents

Program execution monitoring apparatus, program execution monitoring method, and program creation method Download PDF

Info

Publication number
JP2006172003A
JP2006172003A JP2004361790A JP2004361790A JP2006172003A JP 2006172003 A JP2006172003 A JP 2006172003A JP 2004361790 A JP2004361790 A JP 2004361790A JP 2004361790 A JP2004361790 A JP 2004361790A JP 2006172003 A JP2006172003 A JP 2006172003A
Authority
JP
Japan
Prior art keywords
program
execution
memory area
memory
data input
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2004361790A
Other languages
Japanese (ja)
Inventor
Hideki Yukitomo
英記 行友
Akira Konno
晃 金野
Takehiro Nakayama
雄大 中山
Atsushi Takeshita
敦 竹下
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NTT Docomo Inc
Original Assignee
NTT Docomo Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NTT Docomo Inc filed Critical NTT Docomo Inc
Priority to JP2004361790A priority Critical patent/JP2006172003A/en
Publication of JP2006172003A publication Critical patent/JP2006172003A/en
Pending legal-status Critical Current

Links

Images

Abstract

【課題】動的にプロセッサの命令列を生成するようなプログラムにも適用可能であり、バッファオーバフローを検出し、プログラムの動作を監視するプログラム実行監視装置を提供する。
【解決手段】プログラム実行監視装置100は、プログラムの実行前に、プログラムの外部からのデータ入力経路と、監視対象となるメモリ領域とを設定する設定手段101aと、プログラムの実行中に、外部からのデータ入力経路を経て入力された値を用いた処理結果をメモリ領域へ格納する格納手段101bと、メモリ領域へ実行遷移が発生した場合、当該実行遷移を検出する検出手段101cとを備える。
【選択図】図1
A program execution monitoring apparatus that can be applied to a program that dynamically generates an instruction sequence of a processor, detects a buffer overflow, and monitors the operation of the program.
A program execution monitoring apparatus 100 sets a data input path from the outside of a program and a memory area to be monitored before executing the program, and externally during execution of the program. Storage means 101b for storing the processing result using the value input through the data input path in the memory area, and detecting means 101c for detecting the execution transition when the execution transition occurs in the memory area.
[Selection] Figure 1

Description

本発明は、プログラム実行監視装置、プログラム実行監視方法及びプログラム作成方法に関する。   The present invention relates to a program execution monitoring apparatus, a program execution monitoring method, and a program creation method.

計算機において実行するプログラムに不備があった場合、悪意のある利用者がこの不備をつき、ソフトウェアの実行を乗っ取り、その計算機に任意の動作をさせることが可能である。このようにプログラムの不備をつき、計算機に任意の動作をさせる行為の代表的なものに、バッファオーバフロー攻撃があるが(例えば、非特許文献1参照。)、これを防止するための数々の技術が提案されている。   If there is a deficiency in the program to be executed on the computer, a malicious user can take this deficiency, take over the execution of the software, and cause the computer to perform any operation. A typical example of an act of causing a computer to perform arbitrary operations in this way is a buffer overflow attack (see, for example, Non-Patent Document 1). Has been proposed.

バッファオーバフローを防止するための技術としては、例えば、プログラム中に含まれる実行遷移命令の遷移先メモリアドレスが、当該プログラムのソースコードにおいて関数の先頭メモリアドレスであるか否か、リターン命令の戻り先メモリアドレスがコール命令の後ろのメモリアドレスになっているかを確認することで、プログラムの実行を奪うことを防止する方法が開示されている(例えば、特許文献1参照。)。   As a technique for preventing the buffer overflow, for example, whether or not the transition destination memory address of the execution transition instruction included in the program is the start memory address of the function in the source code of the program, the return destination of the return instruction A method for preventing the execution of a program from being taken by checking whether the memory address is the memory address after the call instruction is disclosed (for example, see Patent Document 1).

又、バッファオーバフローは外部より攻撃者が入力したデータの中に命令列が含まれ、そのデータ列に実行遷移することにより成立するが、この点に着目し、バッファオーバフローを防止する方法も開示されている(例えば、非特許文献2参照。)。   In addition, buffer overflow is established by including an instruction sequence in data input by an attacker from the outside and executing execution transition to the data sequence. However, focusing on this point, a method for preventing buffer overflow is also disclosed. (See, for example, Non-Patent Document 2).

具体的には、非特許文献2が開示する方法は、プログラムを実行するプロセッサを改造し、予め、ネットワークや外部のファイルからデータが流入するメモリ領域には印を付加しておき、プログラム実行中、印が付加されたメモリ領域から複製された先のメモリ領域や、印が付加されたメモリ領域を用いた演算結果を格納するメモリアドレスには印をつけることを繰り返して印を伝播していき、印が付加されたメモリ領域に実行遷移しようとしたとき、悪意のあるコードを実行しようとしたとして、バッファオーバフローを検出する方法である。
US Patent application No.20040133777 Smashing The Stack For Fun And Profit, www.phrack.org, Phrack Vol. 49 Secure Program Execution via Dynamic Information Flow Tracking, G. Edward Suh, Jae W. Lee, and S. Devadas MIT, ACM Architectural Support for Programming Languages and Operating Systems (asplos) 20044.
Specifically, in the method disclosed in Non-Patent Document 2, a processor that executes a program is modified, and a mark is added to a memory area into which data flows from a network or an external file in advance. The mark is propagated repeatedly by marking the memory address that is copied from the marked memory area and the memory address that stores the operation result using the marked memory area. This is a method of detecting a buffer overflow when trying to execute malicious code when an execution transition is made to a memory area to which a mark is added.
US Patent application No.20040133777 Smashing The Stack For Fun And Profit, www. phrack. org, Phrack Vol. 49 Secure Program Execution via Dynamic Information Flow Tracking, G. Edward Suh, Jae W. Lee, and S. Devadas MIT, ACM Architectural Support for Programming Languages and Operating Systems (asplos) 20044.

しかしながら、特許文献1及び非特許文献2が開示する方法では、動的に実行コードを生成するようなソフトウェアには適用できないという問題がある。Java(登録商標)のような仮想機械や、Perl/Pythonなどに代表される人間が直接読めるような形式で記述された内容をプロセッサが実行可能な命令列に一旦変換した後に実行するようなスクリプト言語の実行系の場合、外部から流入したデータより命令列を生成してデータ領域に格納し、そのデータ領域に実行遷移する。そのため、特許文献1の方法では、予め定義されない関数への実行遷移であるとして、又、非特許文献1では正常な動作であるにもかかわらず、外部より流入したデータから派生したデータへの実行遷移であるとして、誤検出してしまうため、適用することができない。   However, the methods disclosed in Patent Document 1 and Non-Patent Document 2 have a problem that they cannot be applied to software that dynamically generates an execution code. A script that is executed after the contents described in a virtual machine such as Java (registered trademark) or a human-readable format such as Perl / Python are directly converted into an instruction sequence executable by the processor. In the case of a language execution system, an instruction sequence is generated from data flowing in from the outside, stored in the data area, and execution transitions to the data area. For this reason, in the method of Patent Document 1, it is assumed that the execution transition is to a function that is not defined in advance, and even though non-Patent Document 1 is a normal operation, execution to data derived from data that flows from outside Since it is erroneously detected as a transition, it cannot be applied.

そこで、本発明は、上記の課題に鑑み、動的にプロセッサの命令列を生成するようなプログラムにも適用可能であり、バッファオーバフローを検出し、プログラムの動作を監視するプログラム実行監視装置、プログラム実行監視方法及びプログラム作成方法を提供することを目的とする。   Therefore, in view of the above problems, the present invention can be applied to a program that dynamically generates a processor instruction sequence, detects a buffer overflow, and monitors the operation of the program. An object is to provide an execution monitoring method and a program creation method.

上記目的を達成するため、本発明の第1の特徴は、プログラムの実行を監視するプログラム実行監視装置であって、(a)プログラムの実行前に、プログラムの外部からのデータ入力経路と、監視対象となるメモリ領域とを設定する設定手段と、(b)プログラムの実行中に、外部からのデータ入力経路を経て入力された値を用いた処理結果をメモリ領域へ格納する格納手段と、(c)メモリ領域へ実行遷移が発生した場合、当該実行遷移を検出する検出手段とを備えるプログラム実行監視装置であることを要旨とする。   In order to achieve the above object, a first feature of the present invention is a program execution monitoring apparatus for monitoring execution of a program, wherein (a) a data input path from the outside of the program and monitoring are executed before the program is executed. A setting means for setting a target memory area; (b) a storage means for storing a processing result using a value input through an external data input path during execution of the program in the memory area; c) The gist of the present invention is that it is a program execution monitoring device comprising detection means for detecting an execution transition when an execution transition occurs in the memory area.

第1の特徴に係るプログラム実行監視装置によると、動的にプロセッサの命令列を生成するようなプログラムにも適用可能であり、バッファオーバフローを検出し、プログラムの動作を監視することができる。   The program execution monitoring apparatus according to the first feature is applicable to a program that dynamically generates a processor instruction sequence, and can detect a buffer overflow and monitor the operation of the program.

又、第1の特徴に係るプログラム実行監視装置の検出手段は、メモリ領域の大きさが、予め定めていた大きさより大きい場合に、実行遷移を検出してもよい。   The detecting means of the program execution monitoring apparatus according to the first feature may detect an execution transition when the size of the memory area is larger than a predetermined size.

このプログラム実行監視装置によると、攻撃者が送り込む命令列が攻撃者の意図する通りに計算機を操るためには、相応の長さの命令列が必要であることから、プログラム外部からのデータ入力経路より取得した値を格納し、且つ実行を遷移したメモリ領域の大きさが予め定めておいた大きさより小さい場合には誤検出と判断することで、誤検出率を低減することができる。   According to this program execution monitoring device, in order for the instruction sequence sent by the attacker to operate the computer as the attacker intended, a command sequence of a corresponding length is required. If the size of the memory area where the acquired value is stored and the execution has been transitioned is smaller than a predetermined size, it is possible to reduce the false detection rate by determining erroneous detection.

又、第1の特徴に係るプログラム実行監視装置は、メモリ領域内の各アドレスに格納された値が、プログラム外部からの入力経路より入力されたデータから派生した値であるか否かを示す汚染情報を保持するプログラム情報保持部を更に備え、検出手段は、プログラムの実行に従って、汚染情報を更新してもよい。   Further, the program execution monitoring apparatus according to the first feature is a contamination indicating whether or not the value stored at each address in the memory area is a value derived from data input from an input path from outside the program. A program information holding unit that holds information may be further provided, and the detection unit may update the contamination information in accordance with execution of the program.

このプログラム実行監視装置によると、監視対象となるメモリ領域を更新することができ、汚染情報を伝播させることができる。   According to this program execution monitoring apparatus, the memory area to be monitored can be updated, and contamination information can be propagated.

本発明の第2の特徴は、プログラムの実行を監視するプログラム実行監視方法であって、(a)プログラムの実行前に、プログラムの外部からのデータ入力経路と、監視対象となるメモリ領域とを設定するステップと、(b)プログラムの実行中に、外部からのデータ入力経路を経て取得した値を用いた処理結果をメモリ領域へ格納するステップと、(c)メモリ領域へ実行遷移が発生した場合、当該実行遷移を検出するステップとを含むプログラム実行監視方法であることを要旨とする。   A second feature of the present invention is a program execution monitoring method for monitoring execution of a program. (A) Before executing a program, a data input path from the outside of the program and a memory area to be monitored are A setting step; and (b) a step of storing a processing result using a value acquired via an external data input path in a memory area during execution of the program; and (c) an execution transition to the memory area. The gist of the present invention is a program execution monitoring method including a step of detecting the execution transition.

第2の特徴に係るプログラム実行監視方法によると、動的にプロセッサの命令列を生成するようなプログラムにも適用可能であり、バッファオーバフローを検出し、プログラムの動作を監視することができる。   The program execution monitoring method according to the second feature can be applied to a program that dynamically generates an instruction sequence of a processor, and can detect a buffer overflow and monitor the operation of the program.

本発明の第3の特徴は、プログラムの実行中に、プログラムの外部からのデータ入力経路を経て取得した値を用いた処理結果を、監視対象となるメモリ領域へ格納し、メモリ領域へ実行遷移が発生した場合、当該実行遷移を検出するプログラム実行監視装置において実行されるプログラムを作成するプログラム作成方法であって、プログラムの外部からのデータ入力経路と、監視対象となるメモリ領域の更新方法とを予めプログラムファイル内に記述するステップを含むプログラム作成方法であることを要旨とする。   The third feature of the present invention is that, during execution of a program, a processing result using a value obtained through a data input path from the outside of the program is stored in a memory area to be monitored, and execution transition to the memory area is performed. Is a program creation method for creating a program to be executed in the program execution monitoring device that detects the execution transition, the data input path from the outside of the program, and the method for updating the memory area to be monitored; Is a program creation method including a step of previously describing in a program file.

第3の特徴に係るプログラム作成方法によると、プログラムファイルにプログラム外部からのデータ入力経路と、監視対象メモリ領域の更新方法を命令列と同時に格納することができるため、プログラムの実行開始を容易にすることができる。   According to the program creation method according to the third feature, since the data input path from the outside of the program and the updating method of the monitoring target memory area can be stored in the program file simultaneously with the instruction sequence, the program can be easily started. can do.

又、第3の特徴に係るプログラム作成方法において、オペレーティングシステムが提供するシステムコールを用いて、監視対象となるメモリ領域の更新方法を記述してもよい。   In the program creation method according to the third feature, a method for updating a memory area to be monitored may be described using a system call provided by the operating system.

このプログラム作成方法によると、システムコールを利用して、プログラムの実行を監視することができる。   According to this program creation method, the execution of a program can be monitored using a system call.

本発明によると、動的にプロセッサの命令列を生成するようなプログラムにも適用可能であり、バッファオーバフローを検出し、プログラムの動作を監視するプログラム実行監視装置、プログラム実行監視方法及びプログラム作成方法を提供することができる。   According to the present invention, a program execution monitoring apparatus, a program execution monitoring method, and a program creation method that can be applied to a program that dynamically generates an instruction sequence of a processor, detects a buffer overflow, and monitors the operation of the program. Can be provided.

次に、図面を参照して、本発明の実施の形態を説明する。以下の図面の記載において、同一又は類似の部分には、同一又は類似の符号を付している。ただし、図面は模式的なものであることに留意すべきである。   Next, embodiments of the present invention will be described with reference to the drawings. In the following description of the drawings, the same or similar parts are denoted by the same or similar reference numerals. However, it should be noted that the drawings are schematic.

(プログラム実行監視装置)
本実施形態に係るプログラム実行監視装置100は、図1に示すように、命令列を実行するプロセッサ101と、実行するプログラムを格納するメモリ102と、実行中のプログラムの情報を格納するプログラム情報保持部103とを備える。
(Program execution monitoring device)
As shown in FIG. 1, the program execution monitoring apparatus 100 according to the present embodiment includes a processor 101 that executes an instruction sequence, a memory 102 that stores a program to be executed, and a program information holding that stores information on the program being executed. Unit 103.

プロセッサ101は、プログラムの実行前に、プログラムの外部からのデータ入力経路と、監視対象となるメモリ102領域とを設定する設定手段101aと、プログラムの実行中に、外部からのデータ入力経路を経て入力された値を用いた処理結果をメモリ102領域へ格納する格納手段101bと、メモリ102領域へ実行遷移が発生した場合、当該実行遷移を検出する検出手段101cとを備える。   The processor 101 includes a setting unit 101a for setting a data input path from the outside of the program and a memory 102 area to be monitored before the execution of the program, and a data input path from the outside during the execution of the program. A storage unit 101b for storing the processing result using the input value in the memory 102 area and a detection unit 101c for detecting the execution transition when the execution transition occurs in the memory 102 area are provided.

又、検出手段101cは、メモリ領域の大きさが、予め定めていた大きさより大きい場合に、実行遷移を検出してもよい。更に、検出手段101cは、プログラムの実行に従って、後述する汚染情報、保護情報、例外情報を更新する。   The detection unit 101c may detect an execution transition when the size of the memory area is larger than a predetermined size. Furthermore, the detection unit 101c updates contamination information, protection information, and exception information, which will be described later, according to the execution of the program.

メモリ102は、プロセッサ101から、格納するアドレスと読み込み指示を与えられると、そのアドレスに格納された値を出力してプロセッサ101に返す。又、メモリ102は、プロセッサ101から、格納するアドレスと書き込み指示、及び値を与えられると、格納アドレスに値を格納する。メモリ102は、DRAM等の一般的な記憶装置で構成すればよい。   When the memory 102 is given an address to be stored and a read instruction from the processor 101, the memory 102 outputs the value stored at the address and returns it to the processor 101. Further, the memory 102 stores a value at the storage address when given an address to be stored, a write instruction, and a value from the processor 101. The memory 102 may be configured by a general storage device such as a DRAM.

尚、本実施形態においては、32ビットのアドレスを用い、1アドレスにつき1バイト格納できるものとするが、本発明の趣旨はこのアドレス幅や格納データサイズに限定されるものではない。   In the present embodiment, a 32-bit address is used and one byte can be stored per address. However, the gist of the present invention is not limited to this address width and stored data size.

プログラム情報保持部103は、汚染情報104と保護情報105と例外情報106とを保持する。プログラム情報保持部103は、監視中のプログラムから隔離され、その内容を実行中のプログラムより直接参照したり更新したりできないよう、例えばプログラム実行監視装置100全体の実行を制御するオペレーティングシステムの管轄メモリ空間上などに実現するものとする。   The program information holding unit 103 holds contamination information 104, protection information 105, and exception information 106. The program information holding unit 103 is isolated from the program being monitored, and for example, an operating system jurisdiction memory that controls the execution of the entire program execution monitoring apparatus 100 so that the contents cannot be directly referenced or updated by the program being executed. It shall be realized in space.

汚染情報104は、メモリ102内の各アドレスに格納された値が、“プログラム外部からの入力経路より入力されたデータ”から派生した値であるか否かを示す情報である。以下の説明において、“プログラム外部からの入力経路より入力されたデータ”が格納されているメモリアドレスは汚染されていると表現し、汚染情報104内に1を、そうでない場合は0を記述するものとする。   The contamination information 104 is information indicating whether or not the value stored at each address in the memory 102 is a value derived from “data input from an input path from outside the program”. In the following description, the memory address storing “data input from the input path from outside the program” is expressed as being contaminated, and 1 is described in the contamination information 104, and 0 is described otherwise. Shall.

従って、汚染情報104の実現のためには、メモリ102のアドレス毎に汚染されているか否かを表す1ビットを格納できるような領域を用意すればよい。これは、例えば、汚染情報104を連続したメモリ空間上に実現した場合、メモリ102上のアドレスXが汚染されているか否かの情報を、Yを(X) mod 8、Zを(X-Y)/8とすれば、Zバイト目のYビット目に格納することで実現可能である。   Therefore, in order to realize the contamination information 104, it is sufficient to prepare an area that can store 1 bit indicating whether or not the address of the memory 102 is contaminated. For example, when the contamination information 104 is realized in a continuous memory space, information indicating whether or not the address X on the memory 102 is contaminated is expressed as Y (X) mod 8, Z as (XY) / If it is 8, it can be realized by storing in the Y bit of the Z byte.

保護情報105は、メモリ102内の各アドレスが、“プログラム外部からのデータ入力経路より入力されたデータ”を格納することがあってはならないか否かを示す情報である。この保護情報105は、プログラム作成者の意図に従って、設定することができる。各ビットの表す意味を先のように解釈すれば、保護情報105は、汚染情報104と同様の形式で実現可能である。   The protection information 105 is information indicating whether or not each address in the memory 102 should store “data input from the data input path from the outside of the program”. This protection information 105 can be set according to the intention of the program creator. If the meaning represented by each bit is interpreted as described above, the protection information 105 can be realized in the same format as the contamination information 104.

尚、本実施形態では、汚染情報104は、メモリアドレス毎に汚染されている、いないを1ビットで実現しているが、これを複数ビットで表現して伝播させ、プログラム情報保持部103内に別途設けたしきい値を用いて汚染されている、いないを判定してもよい。   In this embodiment, the contamination information 104 is realized by 1 bit indicating whether or not it is contaminated for each memory address, but this is expressed by a plurality of bits and propagated in the program information holding unit 103. You may determine whether it is contaminated using the threshold value provided separately.

例えば、メモリアドレス毎に8ビットで表すとし、外部より直接入力されたメモリアドレスの汚染された度合いを0xffとする。値をそのまま複製した場合は、複製した先の汚染された度合いは複製元の汚染度合いをそのまま用いてもよく、他のメモリアドレスの値と演算し、その演算結果を格納する場合は、両方の汚染度合いの平均を演算結果の汚染度合いとしても用いることも可能である。又、演算の複雑度に応じて、論理和演算の場合は、演算結果の汚染度合いは演算元の汚染度合いの高いほうの値、乗算の場合は、演算元の汚染度合いの平均値などと変えることも可能である。   For example, each memory address is represented by 8 bits, and the degree of contamination of the memory address directly input from the outside is set to 0xff. If the value is copied as it is, the contamination degree of the copy destination may be the same as the contamination degree of the copy source. If the value is calculated with other memory address values and the calculation result is stored, both It is also possible to use the average contamination degree as the contamination degree of the calculation result. Also, depending on the complexity of the operation, in the case of OR operation, the contamination degree of the operation result is changed to a higher value of the operation source contamination degree, and in the case of multiplication, the average value of the operation source contamination degree is changed. It is also possible.

以後、本実施の形態では、外部からのデータ入力経路を経由したデータが格納されることがないと判断されるメモリのアドレスは保護されていると表現し、保護情報105の該当するビットに1をいれ、そうでないときは0をいれるものとする。   Hereinafter, in this embodiment, it is expressed that a memory address that is determined not to store data via a data input path from the outside is protected, and 1 is set to a corresponding bit of the protection information 105. If not, enter 0.

例外情報106は、メモリ102内の各アドレスが“プログラム外部からのデータ入力経路より入力されたデータ”を格納している場合、当該メモリ102領域の実行を許可するか否かを示す情報である。各ビットの表す意味を先のように解釈すれば、例外情報106は、汚染情報104と同様の形式で実現可能である。   The exception information 106 is information indicating whether or not the execution of the area of the memory 102 is permitted when each address in the memory 102 stores “data input from the data input path from outside the program”. . If the meaning represented by each bit is interpreted as described above, the exception information 106 can be realized in the same format as the contamination information 104.

プロセッサ101は、メモリ102に蓄積された命令列を実行する。プログラム実行の過程において、メモリ102の値を更新する際、汚染情報104を更新し、メモリ102のアドレスが汚染されているか否かであるかの情報を伝播させる。非特許文献1に示すような構成をプロセッサ101がとれば、この汚染されているか否かの情報の伝播の実現は容易であるが、ここでは簡単に汚染されているメモリアドレスから複製もしくはその値を利用した演算を新たなアドレスに格納するときに、新に値を格納されたメモリアドレスも汚染されているとする。   The processor 101 executes the instruction sequence stored in the memory 102. In the process of executing the program, when updating the value of the memory 102, the contamination information 104 is updated, and information indicating whether or not the address of the memory 102 is contaminated is propagated. If the processor 101 has a configuration as shown in Non-Patent Document 1, it is easy to realize the propagation of information about whether or not it is tainted, but here it is simply copied from the tainted memory address or its value. Assume that the memory address that newly stores a value is also contaminated when an operation using is stored at a new address.

尚、本実施の形態ではひとつのプログラムの実行を監視する手順を説明するが、複数のプログラムを監視する場合、プログラム情報に実行中のプログラムを特定するIDを含めて複数のプログラム情報を用意し、複数のプログラムの実行を切り替える際にこのIDをもとにプログラム情報を切り替えて利用すればよい。   In this embodiment, the procedure for monitoring the execution of one program will be described. However, when monitoring a plurality of programs, a plurality of program information including an ID for identifying the program being executed is prepared in the program information. When switching the execution of a plurality of programs, the program information may be switched based on this ID.

(プログラム作成方法)
次に、本実施形態に係るプログラム作成方法について、図3及び図4を用いて説明する。上述した、プログラム実行監視装置100上で実行するプログラムは、以下に説明する方法で作成される。
(Program creation method)
Next, a program creation method according to the present embodiment will be described with reference to FIGS. The program to be executed on the program execution monitoring apparatus 100 described above is created by the method described below.

尚、図3及び図4では、プログラムを実行するためにオペレーティングシステムが新たに12のシステムコールを提供することを前提としており、このオペレーティングシステムに追加する12のシステムコールの名称、システムコール番号、機能、実現方法の例を図5に示す。   3 and 4 are based on the premise that the operating system newly provides 12 system calls in order to execute the program. The names of the 12 system calls to be added to the operating system, the system call numbers, Examples of functions and implementation methods are shown in FIG.

図5に示す追加システムコールの名称やシステムコール番号は、これらが一意に特定できればよく、異なる名称やシステム番号を用いて実現してもよい。又、12のシステムコールのうち、sys_startSpuriousRegion()、sys_endSpuriousRegion()、sys_releaseSpuriousRegion()、sys_allocSpuriousRegion()の4つは汚染情報104の更新のために用いるが、例えばネットワーク経由やファイル経由で取得したデータを格納する領域は、汚染情報を1にするといった指定を行うようにすれば、これら4つのシステムコールはなくてもよい。   The name and system call number of the additional system call shown in FIG. 5 need only be able to be uniquely identified, and may be realized using different names and system numbers. Of the 12 system calls, four of sys_startSpuriousRegion (), sys_endSpuriousRegion (), sys_releaseSpuriousRegion (), and sys_allocSpuriousRegion () are used to update the pollution information 104. For example, data acquired via a network or file If the storage area is designated to set the contamination information to 1, these four system calls may not be required.

図2に、本実施形態において説明するプログラムのソースコードの例を示す。本実施形態では、ソースコード中に、各変数の格納メモリ領域が保護されているか否か、又は汚染されているか否か、又は外部からのデータ入力経路を経由したデータが格納されるが実行を許可するか否か、という情報を記述する必要がある。この実現形式は幾通りか考えられるが、図2の例ではC言語のコメント文を用い、変数の宣言前にこれらの情報を記述している。 以後、本実施の形態では、/* protected */、というコメント、及び/* spurious */、/* except */というコメントを付加することをそれぞれ、保護注釈、汚染注釈、例外注釈を付加すると呼ぶ。   FIG. 2 shows an example of the source code of the program described in this embodiment. In the present embodiment, whether or not the storage memory area of each variable is protected or contaminated is stored in the source code, or data via an external data input path is stored. It is necessary to describe information about whether or not to permit. There are several possible forms of this implementation, but in the example of FIG. 2, C language comment statements are used, and this information is described before variable declaration. Hereinafter, in this embodiment, adding the comment / * protected * / and the comments / * spurious * / and / * except * / is called adding the protected annotation, the contamination annotation, and the exception annotation, respectively. .

図3及び図4は一つのソースコードファイルからアセンブラコードを作成する場合の、通常のプログラムの作成方法と本発明のプログラム作成方法の差分のみを示している。本実施の形態において通常のプログラムの作成方法として示す内容や、複数のソースコードから一つのプログラムを作成する方法、アセンブラ言語からバイト列から構成されるプログラムへの変換方法、トークン等の用語については、“Compilers Principles, Techniques, and Tools A.V. Aho, R. Sethi, and J.D. Ullman”(以下において、非特許文献3という。)に詳しい。   3 and 4 show only the difference between the normal program creation method and the program creation method of the present invention when the assembler code is created from one source code file. Regarding the contents shown as a normal program creation method in this embodiment, a method for creating one program from a plurality of source codes, a method for converting from an assembler language to a program composed of byte strings, and terms such as tokens “Compilers Principles, Techniques, and Tools AV Aho, R. Sethi, and JD Ullman” (hereinafter referred to as Non-Patent Document 3).

まず、図3のステップS101において、通常のプログラムの作成と同様に、ソースコードを構文解析していき、ソースコードからトークンを読み込む。   First, in step S101 in FIG. 3, the source code is parsed and a token is read from the source code, as in the case of creating a normal program.

次に、ステップS102において、トークンが空であるか否か判断し、トークンが空である場合、ソースコードの解析が終了したとして、プログラム作成の手続きを終了する。一方、ステップS102において、トークンが空でない場合、ステップS103に進み、トークンが関数宣言であるか否か判断する。   Next, in step S102, it is determined whether or not the token is empty. If the token is empty, it is determined that the analysis of the source code is ended, and the program creation procedure is ended. On the other hand, if the token is not empty in step S102, the process proceeds to step S103 to determine whether the token is a function declaration.

ステップS103において、関数宣言でなく、かつ、ステップS109において、保護注釈又は汚染注釈が付加された大域変数宣言であるとき、図4に示す手続きを実行し、プログラム実行開始時に宣言された大域変数を格納するメモリアドレスに該当する保護情報、又は汚染情報、又は例外情報を1に変更する。   If it is not a function declaration in step S103 and a global variable declaration to which a protection annotation or a contamination annotation is added in step S109, the procedure shown in FIG. 4 is executed, and the global variable declared at the start of program execution is changed. The protection information, contamination information, or exception information corresponding to the memory address to be stored is changed to 1.

具体的には、図4のステップS201において、大域変数をXとし、Xが割り当てられる、メモリ領域における先頭格納アドレスをXa、及びその大きさをXsとする。アドレスXa、大きさXsは、大域変数宣言の型情報から得ることができるため、システムコールsys_allocProtectedRegion(Xa、Xs)やsys_allocSpuriousRegion(Xa、Xs)、sys_allocExceptRegion(Xa、Xs)を呼び出すようにすればよい。つまり、ステップS202において、Xに保護注釈を付加する場合は、ステップS203において、プログラムの初期化処理にシステムコールsys_allocProtectedRegion(Xa、Xs)を呼び出すコードを追加する。又、ステップS204において、Xに汚染注釈を付加する場合は、ステップS205において、プログラムの初期化処理にシステムコールsys_allocSpuriousRegion(Xa、Xs)を呼び出すコードを追加する。又、ステップS206において、Xに例外注釈を付加する場合は、ステップS207において、プログラムの初期化処理にシステムコールsys_allocExceptRegion(Xa、Xs)を呼び出すコードを追加する。   Specifically, in step S201 of FIG. 4, the global variable is set to X, the head storage address in the memory area to which X is allocated is set to Xa, and the size thereof is set to Xs. Since the address Xa and the size Xs can be obtained from the type information of the global variable declaration, the system calls sys_allocProtectedRegion (Xa, Xs), sys_allocSpuriousRegion (Xa, Xs), and sys_allocExceptRegion (Xa, Xs) should be called. . That is, when a protection annotation is added to X in step S202, a code for calling the system call sys_allocProtectedRegion (Xa, Xs) is added to the initialization process of the program in step S203. In step S204, if a taint annotation is added to X, a code for calling the system call sys_allocSpuriousRegion (Xa, Xs) is added to the initialization process of the program in step S205. If an exception annotation is added to X in step S206, a code for calling the system call sys_allocExceptRegion (Xa, Xs) is added to the initialization process of the program in step S207.

図3のステップS103において、トークンが関数宣言でなく、かつ、ステップS109において、注釈が付加された大域変数宣言でない場合、ステップS311において、通常のコード生成を行う。   If the token is not a function declaration in step S103 of FIG. 3 and the annotation is not a global variable declaration with an annotation, normal code generation is performed in step S311.

一方、ステップS103において、トークンが関数宣言であった場合、関数内で宣言された変数に対し順次処理を行うため、先頭に宣言された変数をXとする。   On the other hand, if the token is a function declaration in step S103, the variable declared at the head is set to X in order to sequentially process the variables declared in the function.

次に、ステップS105において、Xが存在するか否か判断し、Xが存在しない、即ち、関数内で宣言された変数がない場合、ステップS112において、関数宣言の終了まで通常のコード生成を行う。そして、ステップS113において、関数宣言が終了する際にシステムコールsys_releaseProtectedRegion()、及びsys_releaseSpuriousRegion()、sys_releaseExeptRegion()を呼び出すコードを生成し、ステップS101へ戻り、次のトークンを読み込んで処理を継続する。   Next, in step S105, it is determined whether or not X exists. If X does not exist, that is, if there is no variable declared in the function, normal code generation is performed until the end of the function declaration in step S112. . In step S113, code for calling the system calls sys_releaseProtectedRegion (), sys_releaseSpuriousRegion (), and sys_releaseExeptRegion () when the function declaration ends is generated, and the process returns to step S101 to read the next token and continue the processing.

一方、ステップS105において、Xが存在する、即ち、関数内に宣言された変数が存在する場合、ステップS106において、その変数に注釈が付加されているか否かを判断する。   On the other hand, if X exists in step S105, that is, if a variable declared in the function exists, it is determined in step S106 whether an annotation is added to the variable.

ステップS106において、注釈が付加されていない場合、変数Xの格納に必要な領域をスタック上に確保するため、ステップS107において、スタックポインタの値をXの大きさ分、減算するコードを生成する。即ち、Xの大きさ分、スタックポインタを移動し、スタック上にXの格納領域を用意するコードを生成する。そして、ステップS108において、関数内の次に宣言された変数をXとして、ステップS105〜108の処理を繰り返す。   If no annotation is added in step S106, a code for subtracting the value of the stack pointer by the size of X is generated in step S107 in order to secure an area necessary for storing the variable X on the stack. That is, the stack pointer is moved by the size of X, and a code for preparing an X storage area on the stack is generated. In step S108, the variable declared next in the function is set as X, and the processing in steps S105 to 108 is repeated.

ステップS106において、保護注釈又は汚染注釈、例外注釈が付加されている場合、ステップS114に進み、注釈の種類に応じ、システムコールsys_startXXXXRegion()を呼び出すコードを生成する。その後、ステップS315において、変数Xの格納に必要な領域をスタック上に確保する。続いて、ステップS116において、システムコールsys_endXXXXRegion()を呼び出すコードを生成し、ステップS108へと処理を移す。この時、変数Xに付加された注釈が保護注釈の場合はProtected、汚染注釈の場合はSpurious、例外注釈の場合はExceptとする。   If a protection annotation, a contamination annotation, or an exception annotation is added in step S106, the process proceeds to step S114, and a code for calling the system call sys_startXXXXRegion () is generated according to the type of annotation. Thereafter, in step S315, an area necessary for storing the variable X is secured on the stack. Subsequently, in step S116, a code for calling the system call sys_endXXXXRegion () is generated, and the process proceeds to step S108. At this time, if the annotation added to the variable X is a protection annotation, it is Protected, if it is a tainted annotation, it is Spurious, and if it is an exception annotation, it is Except.

図3および図4に示す手順に従って、図2のプログラムのソースコードをアセンブラコードに変換した例を図6に示す。図6中、関数fulfillの詳細は示していないが、ここでは変数bの内容を引数で与えられた領域へ複製する関数とする。又、本実施の形態においては、システムコールの呼び出しはレジスタ%eaxにシステムコール番号を代入してソフト割り込み80Hで実現するものとする。   FIG. 6 shows an example in which the source code of the program shown in FIG. 2 is converted into an assembler code in accordance with the procedure shown in FIGS. Although details of the function fullfill are not shown in FIG. 6, it is assumed here that the contents of the variable b are copied to the area given by the argument. In the present embodiment, the system call is implemented by the software interrupt 80H by assigning the system call number to the register% eax.

このようにしてプログラムのソースコードよりアセンブラコードを生成し、アセンブラコードより、非特許文献3が開示するような方法で更にプログラムへと変換する。プログラムは実行していない段階では、例えば図7に示すような単一のファイルとして格納しておく。図7の構成例ではプログラムファイル700はプログラムヘッダ701とテキスト領域702とデータ領域703から構成される。   In this way, an assembler code is generated from the source code of the program, and the assembler code is further converted into a program by a method disclosed in Non-Patent Document 3. When the program is not executed, it is stored as a single file as shown in FIG. In the configuration example of FIG. 7, the program file 700 includes a program header 701, a text area 702, and a data area 703.

プログラムヘッダ701は、テキスト領域702およびデータ領域703がファイル中どのような位置に格納され、どのくらいの大きさを持ち、実行時にどのメモリ領域に格納されるか、といった情報を格納する。プログラムヘッダ701は、例えば、図8に示すように、テキスト領域の先頭が格納されているファイル内のオフセット701a、テキスト領域の大きさ701b、テキスト領域を実行時、メモリにマップしたときの先頭開始アドレス701c、データ領域が格納されているファイル内のオフセット701d、データ領域の大きさ701e、データ領域を実行時、メモリにマップしたときの先頭開始アドレス701fなどから構成される。   The program header 701 stores information such as where the text area 702 and the data area 703 are stored in the file, how large the file is, and in which memory area the data area 703 is stored. For example, as shown in FIG. 8, the program header 701 has an offset 701a in the file in which the head of the text area is stored, the size of the text area 701b, and the start of the head when the text area is mapped to memory at the time of execution. The address 701c, the offset 701d in the file in which the data area is stored, the size 701e of the data area, the start start address 701f when the data area is mapped to the memory at the time of execution, and the like.

テキスト領域702は、図3及び図4に示す手順に従って生成したアセンブラコードより変換された命令列を格納する。   The text area 702 stores an instruction sequence converted from an assembler code generated according to the procedure shown in FIGS.

データ領域703は、静的に格納アドレスが決定され、初期値が代入されている変数を格納する。   The data area 703 stores a variable in which a storage address is statically determined and an initial value is substituted.

(プログラム実行監視方法)
次に、本実施形態に係るプログラム実行監視方法について、図9を用いて説明する。
(Program execution monitoring method)
Next, the program execution monitoring method according to the present embodiment will be described with reference to FIG.

まず、ステップS301において、プログラム実行監視装置100は、プログラムの実行を開始する際、実行を開始しようとするプログラムファイル700より、プログラムファイル内のプログラムヘッダ701の情報をもとにファイル内のテキスト領域702、データ領域703をメモリ上にマッピングする。この時、汚染情報104と保護情報105と例外情報106とは初期化し、すべて0にしておく。   First, in step S301, when the program execution monitoring apparatus 100 starts executing a program, the program execution monitoring apparatus 100 starts from the program file 700 to start execution, and based on the information in the program header 701 in the program file, the text area in the file. 702 and the data area 703 are mapped on the memory. At this time, the contamination information 104, the protection information 105, and the exception information 106 are initialized and set to all zero.

次に、ステップS302において、プログラム実行監視装置100は、メモリ上にマッピングされたテキスト領域702の先頭より、命令列の実行を開始する。テキスト領域702の先頭には、プログラムの初期化処理が格納されているが、データ領域703に汚染注釈や保護注釈、例外注釈が付加された変数を格納する領域がある場合、初期化処理の命令列中に、汚染情報や保護情報、例外情報の更新処理が含まれる。このため、プログラムの初期化処理において、該当するメモリ領域に該当する汚染情報104、および保護情報105、例外情報106の更新処理も行う。   In step S302, the program execution monitoring apparatus 100 starts executing the instruction sequence from the beginning of the text area 702 mapped on the memory. A program initialization process is stored at the head of the text area 702. If there is an area for storing a variable with a taint annotation, a protection annotation, or an exception annotation in the data area 703, an instruction for the initialization process is stored. The column includes the update processing of contamination information, protection information, and exception information. For this reason, in the initialization process of the program, update processing of the contamination information 104 corresponding to the corresponding memory area, the protection information 105, and the exception information 106 is also performed.

初期化処理実行終了後、プログラム実行監視装置100は、プログラム本体の命令列をひとつひとつ取り出して実行する。具体的には、ステップS303において、テキスト領域702の先頭にある命令をXとし、ステップS304において、命令Xが存在するか否か判断する。命令Xが存在する場合は、ステップS305に進み、命令Xを実行する。   After completing the initialization process, the program execution monitoring apparatus 100 extracts and executes each instruction sequence of the program body. Specifically, in step S303, the instruction at the head of the text area 702 is set to X, and in step S304, it is determined whether or not the instruction X exists. If the instruction X exists, the process proceeds to step S305, and the instruction X is executed.

又、ステップS305においては、命令Xの実行とともに、汚染情報104を更新する。汚染情報104の更新を行うには、非特許文献1に示すようなプロセッサ構成を用いればよい。又命令列には、動的に格納アドレスが決定される変数の格納領域を更新するような処理が図3及び図4のプログラム作成方法により含まれているため、保護情報105についても逐次更新する。   In step S305, along with the execution of the instruction X, the contamination information 104 is updated. In order to update the contamination information 104, a processor configuration as shown in Non-Patent Document 1 may be used. Further, since the instruction sequence includes a process for updating the storage area of the variable whose storage address is dynamically determined by the program creation method of FIGS. 3 and 4, the protection information 105 is also updated sequentially. .

次に、ステップS306において、命令Xの実行により、保護領域が汚染されているか否か判断し、汚染されている場合、ステップS308に進み、実行遷移を検出してプログラム実行監視装置100の外部に知らせる。保護領域が汚染されていない場合、ステップS307に進み、命令Xは実行遷移命令であり、実行遷移先は例外領域でなく、汚染されているか否か判断する。該当する場合は、ステップS308に進み、実行遷移を検出してプログラム実行監視装置100の外部に知らせる。ステップS307の条件が成立しなければ、ステップS309において、テキスト領域より次の命令を取り出して新たにXとし、XがなくなるまでステップS304以降の処理を繰り返す。   Next, in step S306, it is determined whether or not the protection area is contaminated by execution of the instruction X. If it is contaminated, the process proceeds to step S308 to detect the execution transition, and outside the program execution monitoring apparatus 100. Inform. If the protected area is not contaminated, the process proceeds to step S307, where it is determined whether the instruction X is an execution transition instruction and the execution transition destination is not an exception area but is contaminated. If applicable, the process proceeds to step S308 to detect an execution transition and notify the outside of the program execution monitoring apparatus 100. If the condition in step S307 is not satisfied, in step S309, the next instruction is taken out from the text area and newly set as X, and the processes in and after step S304 are repeated until X disappears.

又、ステップS307において、例えば実行遷移先のメモリアドレスをXとし、Xよりも小さく最も近い汚染されたメモリアドレスをY、Xよりも大きく最も近い汚染されていないメモリアドレスをZとするとZ-Yが予め定めておいた値Nより大きければ検出するとしてもよい。ここで値Nは、プログラム実行監視装置100が予め保持しておくか、プログラムファイル700の例えばプログラムヘッダ701などに格納しておき、実行時に取得してプログラム情報に加えておけばよい。   Also, in step S307, for example, if the memory address of the execution transition destination is X, the contaminated memory address smaller than X is nearest Y, and the nearest uncontaminated memory address larger than X is Z, ZY is preliminarily set. If it is larger than the predetermined value N, it may be detected. Here, the value N may be held in advance by the program execution monitoring apparatus 100 or stored in, for example, the program header 701 of the program file 700, acquired at the time of execution, and added to the program information.

次に、テキスト領域702として、図6に示すようなアセンブラコードを持つプログラムを図9の手順に基づいて実行したときの正常動作について、具体的に図6および図10〜11を用いて説明する。   Next, a normal operation when a program having an assembler code as shown in FIG. 6 as the text area 702 is executed based on the procedure of FIG. 9 will be specifically described with reference to FIG. 6 and FIGS. .

図10〜12は、プログラム実行時のメモリの様子を表しており、図の上側が若いアドレスを表している。メモリの脇に斜め斜線の印がついていればメモリ領域が汚染されていることを表し、格子模様の印がついていれば、保護されていることを表し、横線の印がついていれば例外領域であることを表す。この印はそれぞれ、汚染情報104や保護情報105、例外情報106を説明のために可視化したものである。   10 to 12 show the state of the memory at the time of program execution, and the upper side of the figure shows a young address. A diagonal diagonal line next to the memory indicates that the memory area is contaminated, a checkered pattern indicates that it is protected, and a horizontal line indicates an exception area. Represents something. Each of these marks is a visualization of the contamination information 104, the protection information 105, and the exception information 106 for explanation.

まず、プログラムヘッダ701の情報にもとづいてメモリ102にテキスト領域702、データ領域703を配置した後、テキスト領域702の先頭にある初期化処理を実行する(図6の601部分)。ここでは静的に確保される変数bの領域を確保し、変数bに対して汚染注釈が指定されていることから、これを汚染情報104に反映する。このときのメモリは図10(a)のようになる。メモリの下層にプログラムスタックが形成され、変数bの格納領域が汚染されていることが汚染情報104に記述される。   First, after arranging the text area 702 and the data area 703 in the memory 102 based on the information of the program header 701, the initialization process at the head of the text area 702 is executed (portion 601 in FIG. 6). Here, an area of the variable b that is statically secured is secured, and since the contamination annotation is designated for the variable b, this is reflected in the contamination information 104. The memory at this time is as shown in FIG. The contamination information 104 describes that a program stack is formed in the lower layer of the memory and the storage area of the variable b is contaminated.

次に、プログラムの本体であるmain関数を実行していく。スタック上にmain関数の呼び出し元のスタックベースアドレスアドレス%ebpを退避し、変数x、変数bufの領域をスタック上に確保する(図6の602、603、604部分)。このとき変数x、および変数bufにはそれぞれ保護注釈、例外注釈が付加されていることから、保護情報105および例外情報106の更新を行い、メモリの様子は図10(b)のようになる。   Next, the main function that is the main body of the program is executed. The stack base address% ebp of the caller of the main function is saved on the stack, and the areas of variable x and variable buf are secured on the stack (portions 602, 603, and 604 in FIG. 6). At this time, since the protection annotation and the exception annotation are added to the variable x and the variable buf, respectively, the protection information 105 and the exception information 106 are updated, and the state of the memory is as shown in FIG.

関数mainの実行を進めると、引数をスタックに積み、関数funcAを呼び出す(図6の605部分)。関数funcA内では自身のスタックフレームを保存し(図6の606部分)、変数用の領域確保を行う(図6の607部分)。関数funcAの中の変数には注釈が付加されていないため、図6の607に示すようなアセンブラコードで変数格納用の領域を確保する。このときのメモリの様子は図11(a)のようになる。   When the execution of the function main is advanced, the arguments are stacked on the stack and the function funcA is called (portion 605 in FIG. 6). In the function funcA, the stack frame is stored (portion 606 in FIG. 6), and an area for a variable is secured (portion 607 in FIG. 6). Since no annotation is added to the variable in the function funcA, an area for storing the variable is secured by an assembler code as indicated by reference numeral 607 in FIG. The state of the memory at this time is as shown in FIG.

関数funcAは、関数fulfillを呼び出すが、関数fulfillは大域変数bより引数が示す領域へと値を複製することより、関数Aの引数として与えたbuf2の格納領域は汚染されていることが汚染情報104に反映される。更にbuf2の値をbuf3へと複製するため、buf3の格納領域も汚染され、メモリの様子は図11(b)のようになる。関数funcAの実行を終了後、スタックから戻りアドレスを取り出して実行遷移する。funcA終了後、bufに格納された命令列を実行する関数runを呼び出す。   The function funcA calls the function fulfill, but by copying the value from the global variable b to the area indicated by the argument, the function fulfill indicates that the storage area of buf2 given as the argument of the function A is contaminated. 104 is reflected. Further, since the value of buf2 is copied to buf3, the storage area of buf3 is also contaminated, and the state of the memory is as shown in FIG. After completing the execution of the function funcA, the return address is extracted from the stack and the execution transition is made. After funcA ends, call the function run that executes the instruction sequence stored in buf.

次に、上述した動作において、関数funcAから関数fulfillを呼び出したとき、関数fulfill内でバッファオーバフローが発生した動作について、具体的に図12を用いて説明する。   Next, in the operation described above, when the function fulfill is called from the function funcA, an operation in which a buffer overflow occurs in the function fulfill will be specifically described with reference to FIG.

上述した動作において、関数funcAから関数fulfillを呼び出したとき、関数fulfill内でバッファオーバフローが発生し、変数ptr3の値が改竄され、変数buf内を指すようになったとする。   In the above-described operation, when the function fulfill is called from the function funcA, it is assumed that a buffer overflow occurs in the function fulfill and the value of the variable ptr3 is falsified to point to the variable buf.

この場合、図12(a)に示すように、メモリの様子は、保護された領域であるにもかかわらず、汚染される。本実施の形態では、これを検知し、例外が発生したとして外部に知らせる。   In this case, as shown in FIG. 12A, the state of the memory is contaminated even though it is a protected area. In the present embodiment, this is detected and notified to the outside that an exception has occurred.

もし、ここで保護領域の汚染を検知しない場合、関数fulfillの終了後、変数ptr2が指す領域から変数ptr3が指す領域へと値の複製が行われるが、これは変数ptr3が変数bufを指していることから、buf2からbufへと値が複製されることになる。変数buf2のデータはfulfill内において大域変数bより複製が行われているため、変数buf2、変数bufの格納領域ともに汚染される。このときのメモリの様子は、図12(b)のようになる。関数fulfillの実行終了後、funcAの処理を終了して、呼び出しに戻り、関数runを実行しようとしても、bufは汚染されているが例外領域であるため実行を継続してしまう。
(作用及び効果)
本実施形態に係るプログラム実行監視装置100及びプログラム実行監視方法によると、仮想機械や、スクリプト言語など実行時に動的にプロセッサの命令列を生成するようなプログラムにも適用可能であり、バッファオーバフローを検出し、プログラム作成者の意図通りにプログラムが動作しているか否かを監視することができる。
If no protection area contamination is detected here, the value is copied from the area pointed to by the variable ptr2 to the area pointed to by the variable ptr3 after the function fulfill is completed. This is because the variable ptr3 points to the variable buf. Therefore, the value is duplicated from buf2 to buf. Since the data of the variable buf2 is duplicated from the global variable b in the fullfill, both the variable buf2 and the storage area of the variable buf are contaminated. The state of the memory at this time is as shown in FIG. After the execution of the function fulfill, when the funcA processing is finished, returning to the call and trying to execute the function run, the buf is contaminated but it continues execution because it is an exception area.
(Action and effect)
According to the program execution monitoring apparatus 100 and the program execution monitoring method according to the present embodiment, it can be applied to a program such as a virtual machine or a program that dynamically generates an instruction sequence of a processor at the time of execution, such as a buffer overflow. It is possible to detect and monitor whether the program is operating as intended by the program creator.

又、プログラム実行監視装置100の検出手段101cは、メモリ領域の大きさが、予め定めていた大きさより大きい場合に、実行遷移を検出することができる。このため、攻撃者が送り込む命令列が攻撃者の意図する通りに計算機を操るためには、相応の長さの命令列が必要であることから、プログラム外部からのデータ入力経路より取得した値を格納し、且つ実行を遷移したメモリ領域の大きさが予め定めておいた大きさより小さい場合には誤検出と判断することで、誤検出率を低減することができる。   The detection unit 101c of the program execution monitoring apparatus 100 can detect an execution transition when the size of the memory area is larger than a predetermined size. For this reason, in order for the command sequence sent by the attacker to operate the computer as the attacker intended, a command sequence of an appropriate length is required, so the value obtained from the data input path from the outside of the program If the size of the memory area that has been stored and the execution has been transitioned is smaller than a predetermined size, it is possible to reduce the false detection rate by determining that it is a false detection.

又、本実施形態に係るプログラム実行監視装置100の検出手段101cは、プログラムの実行に従って、汚染情報、保護情報、例外情報を更新することができる。このため、汚染情報を伝播させることができる。   Further, the detection unit 101c of the program execution monitoring apparatus 100 according to the present embodiment can update the contamination information, the protection information, and the exception information according to the execution of the program. For this reason, contamination information can be propagated.

又、本実施形態に係るプログラム作成方法によると、プログラムファイルにプログラム外部からのデータ入力経路と、監視対象メモリ領域を命令列と同時に格納することができるため、プログラムの実行開始を容易にすることができる。   Further, according to the program creation method according to the present embodiment, the data input path from the outside of the program and the monitored memory area can be stored in the program file at the same time as the instruction sequence, thereby facilitating the start of program execution. Can do.

又、本実施形態に係るプログラム作成方法において、オペレーティングシステムが提供するシステムコールを用いて、監視対象メモリ領域の更新方法を記述することができる。このため、システムコールを利用して、プログラムの実行を監視することができる。   Further, in the program creation method according to the present embodiment, the monitoring target memory area update method can be described using a system call provided by the operating system. Therefore, the execution of the program can be monitored using a system call.

本実施形態に係るプログラム実行監視装置の構成ブロック図である。It is a block diagram of the configuration of the program execution monitoring apparatus according to the present embodiment. 本実施形態に係るプログラムのソースコードの一例である。It is an example of the source code of the program concerning this embodiment. 本実施形態に係るプログラム作成方法を示すフローチャートである(その1)。It is a flowchart which shows the program creation method which concerns on this embodiment (the 1). 本実施形態に係るプログラム作成方法を示すフローチャートである(その2)。It is a flowchart which shows the program creation method which concerns on this embodiment (the 2). 本実施形態に係るオペレーティングシステムが提供するシステムコールの追加例である。It is an additional example of the system call which the operating system which concerns on this embodiment provides. 図2のソースコードをアセンブラコードへ変換した例である。3 is an example in which the source code of FIG. 2 is converted into an assembler code. 本実施形態に係るプログラムファイルの構成例である。It is a structural example of the program file which concerns on this embodiment. 図7のプログラムヘッダの構成例である。It is a structural example of the program header of FIG. 本実施形態に係るプログラム実行監視方法を示すフローチャートである。It is a flowchart which shows the program execution monitoring method which concerns on this embodiment. 本実施形態に係るプログラム実行監視過程のメモリの様子を示す図である(その1)。It is a figure which shows the mode of the memory of the program execution monitoring process which concerns on this embodiment (the 1). 本実施形態に係るプログラム実行監視過程のメモリの様子を示す図である(その2)。It is a figure which shows the mode of the memory of the program execution monitoring process which concerns on this embodiment (the 2). 本実施形態に係るプログラム実行監視過程のメモリの様子を示す図である(その3)。It is a figure which shows the mode of the memory of the program execution monitoring process which concerns on this embodiment (the 3).

符号の説明Explanation of symbols

100…プログラム実行監視装置
101…プロセッサ
101a…設定手段
101b…格納手段
101c…検出手段
102…メモリ
103…プログラム情報保持部
104…汚染情報
105…保護情報
106…例外情報
700…プログラムファイル
701…プログラムヘッダ
702…テキスト領域
703…データ領域
DESCRIPTION OF SYMBOLS 100 ... Program execution monitoring apparatus 101 ... Processor 101a ... Setting means 101b ... Storage means 101c ... Detection means 102 ... Memory 103 ... Program information holding part 104 ... Contamination information 105 ... Protection information 106 ... Exception information 700 ... Program file 701 ... Program header 702 ... Text area 703 ... Data area

Claims (6)

プログラムの実行を監視するプログラム実行監視装置であって、
前記プログラムの実行前に、前記プログラムの外部からのデータ入力経路と、監視対象となるメモリ領域とを設定する設定手段と、
前記プログラムの実行中に、前記外部からのデータ入力経路を経て入力された値を用いた処理結果を前記メモリ領域へ格納する格納手段と、
前記メモリ領域へ実行遷移が発生した場合、当該実行遷移を検出する検出手段と
を備えることを特徴とするプログラム実行監視装置。
A program execution monitoring device for monitoring program execution,
Setting means for setting a data input path from the outside of the program and a memory area to be monitored before execution of the program;
Storage means for storing a processing result using a value input via the data input path from the outside during execution of the program in the memory area;
A program execution monitoring apparatus comprising: a detecting unit that detects an execution transition when an execution transition occurs in the memory area.
前記検出手段は、前記メモリ領域の大きさが、予め定めていた大きさより大きい場合に、前記実行遷移を検出することを特徴とする請求項1に記載のプログラム実行監視装置。   The program execution monitoring apparatus according to claim 1, wherein the detection unit detects the execution transition when the size of the memory area is larger than a predetermined size. 前記メモリ領域内の各アドレスに格納された値が、前記プログラム外部からの入力経路より入力されたデータから派生した値であるか否かを示す汚染情報を保持するプログラム情報保持部を更に備え、
前記検出手段は、前記プログラムの実行に従って、前記汚染情報を更新することを特徴とする請求項1又は2に記載のプログラム実行監視装置。
A program information holding unit for holding contamination information indicating whether or not the value stored at each address in the memory area is a value derived from data input from an input path from outside the program;
The program execution monitoring apparatus according to claim 1, wherein the detection unit updates the contamination information according to the execution of the program.
プログラムの実行を監視するプログラム実行監視方法であって、
前記プログラムの実行前に、前記プログラムの外部からのデータ入力経路と、監視対象となるメモリ領域とを設定するステップと、
前記プログラムの実行中に、前記外部からのデータ入力経路を経て取得した値を用いた処理結果を前記メモリ領域へ格納するステップと、
前記メモリ領域へ実行遷移が発生した場合、当該実行遷移を検出するステップと
を含むことを特徴とするプログラム実行監視方法。
A program execution monitoring method for monitoring program execution,
Before executing the program, setting a data input path from the outside of the program and a memory area to be monitored;
Storing the processing result using the value acquired through the external data input path in the memory area during the execution of the program;
And a step of detecting the execution transition when an execution transition occurs in the memory area.
プログラムの実行中に、プログラムの外部からのデータ入力経路を経て取得した値を用いた処理結果を、監視対象となるメモリ領域へ格納し、前記メモリ領域へ実行遷移が発生した場合、当該実行遷移を検出するプログラム実行監視装置において実行される前記プログラムを作成するプログラム作成方法であって、
前記プログラムの外部からのデータ入力経路と、前記監視対象となるメモリ領域の更新方法とを予めプログラムファイル内に記述するステップを含むことを特徴とするプログラム作成方法。
During execution of the program, the processing result using the value acquired through the data input path from the outside of the program is stored in the memory area to be monitored, and if an execution transition occurs in the memory area, the execution transition A program creation method for creating the program to be executed in a program execution monitoring device for detecting
A method for creating a program, comprising: a step of describing a data input path from the outside of the program and a method for updating a memory area to be monitored in a program file in advance.
オペレーティングシステムが提供するシステムコールを用いて、前記監視対象となるメモリ領域の更新方法を記述することを特徴とする請求項5に記載のプログラム作成方法。

6. The program creation method according to claim 5, wherein a method of updating the memory area to be monitored is described using a system call provided by an operating system.

JP2004361790A 2004-12-14 2004-12-14 Program execution monitoring apparatus, program execution monitoring method, and program creation method Pending JP2006172003A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2004361790A JP2006172003A (en) 2004-12-14 2004-12-14 Program execution monitoring apparatus, program execution monitoring method, and program creation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2004361790A JP2006172003A (en) 2004-12-14 2004-12-14 Program execution monitoring apparatus, program execution monitoring method, and program creation method

Publications (1)

Publication Number Publication Date
JP2006172003A true JP2006172003A (en) 2006-06-29

Family

ID=36672705

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2004361790A Pending JP2006172003A (en) 2004-12-14 2004-12-14 Program execution monitoring apparatus, program execution monitoring method, and program creation method

Country Status (1)

Country Link
JP (1) JP2006172003A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015141718A (en) * 2014-01-27 2015-08-03 イグルー セキュリティ,インク. Aggression detection device and method using vulnerable point of program
CN105229658A (en) * 2013-05-15 2016-01-06 软件营地株式会社 Safety device and safety method for data processing system
JP5954666B2 (en) * 2010-12-08 2016-07-20 パナソニックIpマネジメント株式会社 Information processing apparatus and information processing method
JP2018532187A (en) * 2015-09-17 2018-11-01 クアルコム,インコーポレイテッド Software attack detection for processes on computing devices
JP2021082256A (en) * 2019-11-20 2021-05-27 ▲広▼州大学 Memory analysis method and device based on dynamic stain analysis

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5954666B2 (en) * 2010-12-08 2016-07-20 パナソニックIpマネジメント株式会社 Information processing apparatus and information processing method
CN105229658A (en) * 2013-05-15 2016-01-06 软件营地株式会社 Safety device and safety method for data processing system
JP2016522489A (en) * 2013-05-15 2016-07-28 ソフトキャンプ カンパニー,リミテッド Data processing system security apparatus and security method
JP2015141718A (en) * 2014-01-27 2015-08-03 イグルー セキュリティ,インク. Aggression detection device and method using vulnerable point of program
JP2018532187A (en) * 2015-09-17 2018-11-01 クアルコム,インコーポレイテッド Software attack detection for processes on computing devices
JP2021082256A (en) * 2019-11-20 2021-05-27 ▲広▼州大学 Memory analysis method and device based on dynamic stain analysis

Similar Documents

Publication Publication Date Title
US10242043B2 (en) Software security via control flow integrity checking
JP6185487B2 (en) Keeping secure data isolated from non-secure access when switching between domains
TW201937393A (en) Systems and methods for policy compilation for secure initialization
JP5225003B2 (en) MEMORY PROTECTION METHOD, INFORMATION PROCESSING DEVICE, MEMORY PROTECTION PROGRAM, AND RECORDING MEDIUM CONTAINING MEMORY PROTECTION PROGRAM
JP5582971B2 (en) Memory protection method and information processing apparatus
JP2013507670A (en) System and method for aggressive automatic correction in a dynamic function call system
US6697971B1 (en) System and method for detecting attempts to access data residing outside of allocated memory
CN112585584A (en) Apparatus and method for handling exception-causing events
JP5777843B1 (en) Processor, processing device, and program creation method
JP2006172003A (en) Program execution monitoring apparatus, program execution monitoring method, and program creation method
JP3776302B2 (en) System for detecting hazards in computer programs
JP2001249848A (en) Privileged advancement based on precedent privilege level
US9798651B2 (en) Method of ascertaining primary cause of memory consumption in program, and computer system and computer program for the same
JP5374348B2 (en) Software inspection device and program
CN113536297B (en) Buffer overflow attack defense method and device based on RISC-V and Canary mechanism
EP3522006A1 (en) Method for protecting an executable code
JP2006196002A (en) Software tool including modeling of asynchronous program flow
JP5670269B2 (en) Program diversion detection method
US7191307B1 (en) Memory management unit technique to detect cross-region pointer stores
JP2007066163A (en) Program generation method and program
JP6827244B1 (en) Auditing equipment, auditing methods, auditing programs and auditing systems
JP2006185233A (en) Program conversion method for improving security and compiler program using the same
US20090133124A1 (en) A method for detecting the operation behavior of the program and a method for detecting and clearing the virus program
JP2003288129A (en) Memory management method, memory device, computer system, compiler and program
CN101211388B (en) Device and method for generating and utilizing feature codes to monitor programs