JP5145967B2 - Command statement construction program, processing method, and processing device - Google Patents

Command statement construction program, processing method, and processing device Download PDF

Info

Publication number
JP5145967B2
JP5145967B2 JP2008009562A JP2008009562A JP5145967B2 JP 5145967 B2 JP5145967 B2 JP 5145967B2 JP 2008009562 A JP2008009562 A JP 2008009562A JP 2008009562 A JP2008009562 A JP 2008009562A JP 5145967 B2 JP5145967 B2 JP 5145967B2
Authority
JP
Japan
Prior art keywords
character string
partial character
constant
command
partial
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.)
Expired - Fee Related
Application number
JP2008009562A
Other languages
Japanese (ja)
Other versions
JP2009169846A (en
Inventor
隆夫 大久保
英彦 田中
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.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2008009562A priority Critical patent/JP5145967B2/en
Publication of JP2009169846A publication Critical patent/JP2009169846A/en
Application granted granted Critical
Publication of JP5145967B2 publication Critical patent/JP5145967B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は,コンピュータのアプリケーションプログラムのインジェクション系の攻撃や情報漏洩などの脆弱性を防止するため,プログラム開発において,当該脆弱性に対処した安全なコマンド文の実装および確認を行う処理に関する。   The present invention relates to a process for implementing and confirming a safe command statement that addresses the vulnerability in program development in order to prevent vulnerabilities such as an injection attack and information leakage of an application program of a computer.

Webアプリケーションプログラムでは,SQLやOSコマンドへのインジェクション攻撃やデータ表示時の情報漏洩などの危険性がある。インジェクション攻撃,情報漏洩の脆弱性ついて,プログラム開発時から適切な対策が必要である。   In the Web application program, there is a risk of an injection attack on the SQL or OS command and information leakage at the time of data display. Appropriate countermeasures are required from the time of program development for vulnerabilities of injection attacks and information leaks.

インジェクション攻撃とは,サーバプログラムがクライアントから入力されたデータにもとづいて外部プログラムに何かのコマンドを送信する際に,攻撃者が入力データにコマンドの一部を挿入することにより,外部プログラムに意図しない動作をさせる攻撃をいう。   An injection attack is when an attacker inserts a part of the command into the input data when the server program sends a command to the external program based on the data input from the client. An attack that does not work.

外部プログラムがリレーショナルデータベースである場合に,コマンドはSQLであり,SQL文を利用した攻撃はSQLインジェション攻撃と呼ばれる。同様に,外部プログラムがOS(オペレーティングシステム)で,コマンドがOSコマンドの場合には,OSコマンドインジェクション攻撃と呼ばれる。   When the external program is a relational database, the command is SQL, and an attack using the SQL statement is called a SQL injection attack. Similarly, when the external program is an OS (operating system) and the command is an OS command, this is called an OS command injection attack.

なお,一般的には異なる分類とされているクロスサイトスクリプティング(XSS)攻撃も,外部プログラムをHTMLレンダラ(ブラウザ),コマンドをHTMLと考えれば,本質的な構造はインジェクション攻撃と同じである。   The cross-site scripting (XSS) attack, which is generally classified as different, is essentially the same as the injection attack if the external program is an HTML renderer (browser) and the command is an HTML.

SQLインジェクション攻撃の典型例を説明する。以下のSQL文は,サーバプログラムが,認証時にデータベースに問い合わせを行い,ユーザID,パスワードに一致するデータが存在するときにデータを返すことを想定して構築されたクエリである。   A typical example of the SQL injection attack will be described. The following SQL statement is a query constructed assuming that the server program makes an inquiry to the database at the time of authentication and returns data when there is data matching the user ID and password.


SELECT * FROM utable WHERE user="(userid)" AND pass="(password)"

上記の(userid),(password)の部分には入力データが入る。攻撃者が文字列「" or "a"="a」をパスワードとして入力させると,サーバプログラムが発行するクエリの構文は以下のように変更される。

SELECT * FROM utable WHERE user = "(userid)" AND pass = "(password)"

Input data is entered in the (userid) and (password) parts above. When an attacker enters the string "" or "a" = "a" as a password, the syntax of the query issued by the server program is changed as follows:


SELECT * FROM utable WHERE user="dummy" AND pass="" OR "a"="a"

この変更の結果,「a=a」が常に真になり,(password)への入力が任意データであっても認証条件を満たすため,パスワード認証処理が無意味となってしまう。

SELECT * FROM utable WHERE user = "dummy" AND pass = "" OR "a" = "a"

As a result of this change, “a = a” is always true, and even if the input to (password) is arbitrary data, the authentication condition is satisfied, so the password authentication processing becomes meaningless.

このインジェクション攻撃の防御手法として,バインドメカニズムが知られている。バインドメカニズムでは,動的な値を埋めこむ位置があらかじめ指定された固定のテンプレート(クエリ文字列)を事前に準備しておき,動的な値は,指定位置のパラメータにバインドさせて文字列に組み込む手法である。   A binding mechanism is known as a defense technique for this injection attack. In the binding mechanism, a fixed template (query string) in which the position for embedding dynamic values is specified in advance is prepared in advance, and the dynamic value is bound to the parameter at the specified position and converted to the string. It is a technique to incorporate.

Java(登録商標)のPreparedStatement,PerlのDBI,PHP,PythonのADOdb,VisualBASIC(登録商標)のSQLCommandなどがこれに相当する。   Java (registered trademark) Prepared Statement, Perl DBI, PHP, Python ADOB, VisualBASIC (registered trademark) SQL Command, and the like correspond to this.

図20に,バインドメカニズムによるインジェクション攻撃防止の仕組みを示す。   FIG. 20 shows a mechanism for preventing injection attacks by the bind mechanism.

図20に示すように,予め準備されたSQL文(PreparedStatement)には,予めパラメータ入力位置が設定されている。そして,パラメータを全て入力文字列として扱うサニタイジング(無害化処理)を行い,パラメータによって構文が変化してしまうという脆弱性に対処している。   As shown in FIG. 20, a parameter input position is set in advance in an SQL statement (PreparedStatement) prepared in advance. And, the sanitizing (detoxification process) that treats all parameters as input character strings is performed to cope with the vulnerability that the syntax changes depending on the parameters.

このバインド処理によって,攻撃者が「" or "a"="a」のような不正な値を入力した場合でも,準備されたSQL文の構文が変更せず,安全なクエリであることが保証される。   This binding process ensures that even if an attacker enters an invalid value such as "" or "a" = "a", the syntax of the prepared SQL statement does not change and the query is safe. Is done.

また,インジェクション攻撃に対する防御として,特許文献1に開示されているように,Webサーバ側でパラメータを含むメッセージのチェックポリシーを用意し,脆弱性を生じる入力値を含むメッセージがチェックポリシーに合致するかを判定し,合致するメッセージのみを有効として扱う処理手法もある。
特開2007−4685号公報
In addition, as disclosed in Patent Document 1, as a defense against injection attacks, a check policy for messages including parameters is prepared on the Web server side, and whether a message including an input value that causes a vulnerability matches the check policy. There is also a processing method that determines only the matching messages as valid.
Japanese Patent Laid-Open No. 2007-4685

しかし,従来のバインドメカニズムによる対策には次のような2つの問題点がある。   However, there are the following two problems in the countermeasures using the conventional binding mechanism.

(a)パラメータのバインドメカニズムを利用しないプログラミングが脆弱性を生じる: JavaのPreparedStatementのクエリ文字列を構築する際に,図21に示すように,入力値をパラメータとして指定せずに,通常のクエリの部分(文字列)として構築すると,その部分は,入力値であるにもかかわらずバインドされず,無害化処理が機能しないことになる。その結果,入力値がそのままクエリの一部となり,SQLインジェクション攻撃が可能になるおそれがある。   (A) Programming that does not use the parameter binding mechanism creates a vulnerability: When constructing a PreparedStatement query string in Java, as shown in Fig. 21, an ordinary query is not specified as an input value as a parameter. If it is constructed as a part (character string), the part is not bound despite being an input value, and the detoxification process does not function. As a result, the input value becomes a part of the query as it is, and there is a possibility that the SQL injection attack becomes possible.

以下に,このような脆弱性を生じるJavaプログラムの例を示す。   An example of a Java program that causes such a vulnerability is shown below.


String query = “SELECT * FROM user_info WHERE
user=\”” + userid + “\” AND pass=\”” + password + “\””;
PreparedStatement pstmnt = con.prepareStatement(query);
ResultSet rs = pstmnt.executeQuery();

(b)クエリが動的に変化する場合に静的テンプレートの用意が困難になる: 条件分岐,ループなどによって発行され,その実行ごとに動的に変化するクエリである場合に,分岐やループの組み合わせ数だけ静的クエリのテンプレートを用意しなければならない。そのため,コーディング量とバグ発生率の増加を招き,保守性が低下するという問題が生じる。

String query = “SELECT * FROM user_info WHERE
user = \ ”” + userid + “\” AND pass = \ ”” + password + “\” ”;
PreparedStatement pstmnt = con.prepareStatement (query);
ResultSet rs = pstmnt.executeQuery ();

(B) It becomes difficult to prepare a static template when the query changes dynamically: If the query is issued by a conditional branch, loop, etc., and dynamically changes with each execution, the branch or loop You must prepare as many static query templates as there are combinations. For this reason, the coding amount and the bug occurrence rate are increased, resulting in a problem that maintainability is lowered.

以下のJavaプログラムはキーワード検索の例であるが,キーの種類が6種類であると仮定すると,1から5までのキー組み合わせ総数62通りのSQLクエリのテンプレートを用意する必要がある。   The following Java program is an example of keyword search. However, assuming that there are six types of keys, it is necessary to prepare a total of 62 types of SQL query templates from 1 to 5.


Statement stmnt = con.createStatement();
String query = "SELECT * FROM user_info ";
Set keyset = map.keySet();
Iterator iter = keyset.iterator();
boolean first = true;
while (iter.hasNext()) {
String key =(String) iter.next();
String[] value = (String[]) map.get(key);
if(value[0] != ""){
if(!first) {
query+= " OR ";
} else {
query+= " WHERE ";
}
query+= key + "=\"" + value[0] + "\"";
first = false;
}
}
ResultSet rs = stmnt.executeQuery(query);

(c)情報出力用のコマンドによって出力するべきではない情報の漏洩が生じる: 例えばデータベースから取得した情報を画面に表示するような場合に,取得情報には開示してもよい情報と秘匿すべき情報とが混在していることがあり,これらの情報は区別して扱う必要がある。しかし,不注意やプログラムミスなどによって,表示するべきでない情報(値)が表示され,情報漏洩を生じるおそれがある。このような脆弱性を生じるJavaプログラムの例を下記に示す。

Statement stmnt = con.createStatement ();
String query = "SELECT * FROM user_info";
Set keyset = map.keySet ();
Iterator iter = keyset.iterator ();
boolean first = true;
while (iter.hasNext ()) {
String key = (String) iter.next ();
String [] value = (String []) map.get (key);
if (value [0]! = "") {
if (! first) {
query + = "OR";
} else {
query + = "WHERE";
}
query + = key + "= \""+ value [0] +" \ "";
first = false;
}
}
ResultSet rs = stmnt.executeQuery (query);

(C) Information leakage that should not be output by an information output command occurs: For example, when information acquired from a database is displayed on the screen, the acquired information should be kept secret from information that may be disclosed Information may be mixed, and it is necessary to handle these information separately. However, information (values) that should not be displayed may be displayed due to carelessness or program mistakes, and information leakage may occur. Examples of Java programs that cause such vulnerabilities are shown below.


StringX sx;
sx.add(OutConst.userid); //userID =
sx.add(userid);
sx.add(OutConst.password);// password =
sx.add(password);
String outstr = "userid = " + userid + "password = " + password;
outHTML(outstr);

しかし,システムは,どの情報を秘匿するべきかを判断できないため,プログラムミスによる情報漏洩をシステム的に防止することは困難であった。

StringX sx;
sx.add (OutConst.userid); // userID =
sx.add (userid);
sx.add (OutConst.password); // password =
sx.add (password);
String outstr = "userid =" + userid + "password =" + password;
outHTML (outstr);

However, since the system cannot determine which information should be kept secret, it has been difficult to systematically prevent information leakage due to program mistakes.

本発明は,プログラム上で外部プログラム呼び出しのコマンド文(コマンド文字列)を構築する場合に,コマンド文に含まれる動的な値によって生じる脆弱性を排除した安全なコマンド文の構築処理をコンピュータに実行させるためのプログラム,または,コンピュータが当該コマンド文構築処理を行う処理方法,または,当該コマンド文構築処理を実行する処理装置を提供することを目的とする。   According to the present invention, when a command statement (command character string) for calling an external program is constructed on a program, a safe command statement construction process that eliminates a vulnerability caused by a dynamic value included in the command statement is stored in a computer. It is an object of the present invention to provide a program to be executed, a processing method in which a computer performs the command sentence construction process, or a processing device that executes the command sentence construction process.

本プログラムを実行するコンピュータは,所定のプログラムにおいて使用される,外部プログラムを読み出すためのコマンド文を作成する場合に,部分文字列取得処理として,プログラムのコマンド文に追加される部分文字列を取得する。そして,定数部分判定処理として,コマンド文の静的要素(定数)として複数の単語からなる文字列を定義した定数情報をもとに,コマンド文に追加される部分文字列が定数であるかを判定する。 When a computer that executes this program creates a command statement for reading an external program that is used in a given program , it acquires a partial character string to be added to the program command statement as a partial character string acquisition process. To do. Then, as part of the constant part determination process, based on constant information that defines character strings consisting of multiple words as static elements (constants) of the command sentence, it is determined whether the partial character string added to the command sentence is a constant. judge.

次に,部分文字列情報生成処理として,追加される部分文字列の値,部分文字列が追加される結合位置,および定数部分判定処理の判定結果をもとに部分文字列の属性(定数/非定数)を含む部分文字列情報を生成し,部分文字列情報記憶部に格納する。   Next, as the partial character string information generation process, the partial character string attribute (constant / character string) is determined based on the value of the added partial character string, the coupling position where the partial character string is added, and the determination result of the constant partial determination process. Partial character string information including (non-constant) is generated and stored in the partial character string information storage unit.

その後,前記プログラム実行時など,コマンド文構築が必要になった場合に,コマンド文構築処理として,部分文字列情報記憶部からコマンド文の部分文字列情報を取得し,部分文字列の属性が定数の場合には,部分文字列の値を結合位置に従ってコマンド文の所定のテンプレート文字列にそのまま追加する。または,部分文字列の属性が非定数の場合には,部分文字列に対応する所定の文字を結合位置に従ってテンプレート文字列に追加する。これらの追加処理を行うことによって,前記実行コマンド文を構築する。   After that, when it is necessary to construct a command statement, such as when executing the above program, the command statement construction processing acquires partial character string information of the command statement from the partial character string information storage unit, and the attribute of the partial character string is a constant. In the case of, the value of the partial character string is added as it is to the predetermined template character string of the command sentence according to the coupling position. Alternatively, if the attribute of the partial character string is non-constant, a predetermined character corresponding to the partial character string is added to the template character string according to the coupling position. The execution command statement is constructed by performing these additional processes.

そして,前記コマンド文構築処理において,部分文字列の属性が非定数の場合に,前記プレースホルダをテンプレート文字列の結合位置に追加する。さらに,この非定数の部分文字列の値をパラメータリストに格納し,パラメータリストに格納した部分文字列の値をプレースホルダに設定する処理を行って,前記実行コマンド文を構築する。 Then, in the command statement building process, the attributes of the partial strings in the case of non-constant, add before the Kipu race holder coupling position of the template string. Further, the execution command statement is constructed by storing the value of the non-constant partial character string in the parameter list and setting the value of the partial character string stored in the parameter list in the placeholder.

本プログラムでは,コマンド文の作成時に,不定の要素が全てパラメータとして扱われる安全なコマンド文を生成することができるため,パラメータ以外の文字列部分に動的な値が組み込まれることによってバインドメカニズムによる無害化処理をすり抜ける部分を持つコマンド文を排除することができる。   In this program, when creating a command statement, it is possible to generate a safe command statement in which all undefined elements are treated as parameters. It is possible to eliminate a command sentence having a part that can pass through the detoxification process.

また,プログラム上で動的にコマンド文を構築するため,バインドメカニズムによる対応が困難な構成のコマンド文であっても定数部分と非定数部分とを区別して構築することができ,プログラム実行時のインジェクション攻撃に対する脆弱性を除去することができる。   In addition, since the command statement is dynamically constructed on the program, it is possible to distinguish between the constant part and the non-constant part even if the command statement has a structure that is difficult to handle by the binding mechanism. Vulnerability to injection attacks can be removed.

また,本プログラムでは,前記コマンド文構築処理において,コマンド文が情報出力を行うものである場合に,プレースホルダにパラメータリストの部分文字列の値の代わりに所定の表示文字列をバインドする処理を,前記コンピュータに実行させることができる。   In this program, in the command statement construction process, when the command statement outputs information, a process for binding a predetermined display character string to the placeholder instead of the value of the partial character string of the parameter list is performed. , Can be executed by the computer.

また,本プログラムは,前記コマンド文構築処理において,コマンド文が情報出力を行うものである場合に,属性が非定数の部分文字列について,この部分文字列の値の代わりに所定の表示文字列を結合位置に追加する処理を行うことによって,実行コマンド文を構築する処理を,前記コンピュータに実行させることができる。   In addition, when the command statement outputs information in the command statement construction process, this program uses a predetermined display character string instead of the value of this partial character string for a partial character string whose attribute is non-constant. Can be executed by the computer to build an execution command statement.

さらに,表示文字列として,乱数を発生させて用いてもよい。   Furthermore, a random number may be generated and used as the display character string.

これにより,プログラムミスがある場合でも,出力するべきでない情報が所定の定数値(表示文字列)で設定され,外部プログラムに渡されるため,明示的に定義されない限り非定数の部分はパラメータとみなされて隠蔽される。よって,プログラムミスによる情報漏洩を防止する処理が優先的に行われる安全なコマンド文を構築することができる。   As a result, even if there is a program mistake, information that should not be output is set with a predetermined constant value (display character string) and passed to the external program, so the non-constant part is regarded as a parameter unless explicitly defined. To be concealed. Therefore, it is possible to construct a safe command sentence in which processing for preventing information leakage due to a program mistake is preferentially performed.

また,本プログラムは,さらに,ユーザによって指示された部分文字列の属性を定数とする定数化指定処理を,前記コンピュータに実行させることができる。   In addition, this program can cause the computer to execute a constant designation process using the attribute of the partial character string designated by the user as a constant.

これにより,ユーザ指示などによる明示的な設定によって,パラメータの出力または隠蔽を任意に設定することができるため,情報漏洩の防止を図りつつ柔軟なプログラミングを支援することができる。   As a result, parameter output or concealment can be arbitrarily set by explicit setting based on a user instruction or the like, so that flexible programming can be supported while preventing information leakage.

なお,本プログラムは,コンピュータが読み取り可能な可搬媒体メモリ,半導体メモリ,ハードディスクなどの適当な記録媒体に格納することができ,これらの記録媒体に記録して提供され,または,通信インタフェースを介して種々の通信網を利用した送受信により提供される。   This program can be stored in an appropriate recording medium such as a portable medium readable by a computer, a semiconductor memory, or a hard disk, and is provided by being recorded on these recording media or via a communication interface. Provided by transmission and reception using various communication networks.

本発明によれば,プログラム開発においてコマンド文を生成する場合に,コマンド文に追加される部分文字列の定数/非定数の属性を判断し,部分文字列の属性に応じて異なる処理を行ってコマンド文構築のための情報を生成し,コマンド文構築が必要になった場合に,プログラム上で非定数の部分文字列をパラメータとしてコマンドのテンプレート文に追加することができる。これにより,コマンド文に含まれる動的な値によって生じるインジェクション攻撃に対する脆弱性に対処した安全なコマンド文構築を行うことができる。   According to the present invention, when generating a command sentence in program development, the constant / non-constant attribute of the partial character string added to the command sentence is determined, and different processing is performed according to the attribute of the partial character string. When information for command statement construction is generated and command statement construction becomes necessary, a non-constant substring can be added as a parameter to the command template statement in the program. This makes it possible to construct a safe command statement that addresses the vulnerability to injection attacks caused by dynamic values contained in the command statement.

また,コマンド文が外部からの取得値を出力するものである場合に,取得値を非定数の属性を持つ部分文字列として扱うため,表示用の定数値で置き換えて出力することができる。よって,プログラムミスなどによる情報漏洩の危険性を排除した安全なコマンド文構築を行うことができる。   Also, when the command statement outputs an externally acquired value, the acquired value is handled as a partial character string having a non-constant attribute, so that it can be replaced with a display constant value and output. Therefore, it is possible to construct a safe command sentence that eliminates the risk of information leakage due to a program error or the like.

以下,本発明の最良の実施形態を,コンピュータ・ソフトウェアのJavaプログラムによって実施するコマンド文構築処理装置を例に説明する。   The best embodiment of the present invention will be described below by taking as an example a command sentence construction processing apparatus that is implemented by a Java program of computer software.

コマンド文構築処理装置は,次の特徴を備える。   The command sentence construction processing device has the following features.

(1)コマンド文構築処理装置は,処理手段として,外部プログラム呼び出し用のインタフェースを具備する手続きライブラリを用意する。ここで,外部プログラム呼び出しに,表示画面への表示処理も含む。   (1) The command statement construction processing apparatus prepares a procedure library having an interface for calling an external program as processing means. Here, the display processing on the display screen is also included in the external program call.

なお,プログラミングにおいて,外部プログラム呼び出しでは,コマンド文構築処理装置で用意された手続きライブラリのみを用い,他の手段は用いないというルールのもとで行われる。   In programming, the external program call is performed under the rule that only the procedure library prepared by the command statement construction processing device is used and no other means is used.

(2)コマンド文構築処理装置の各処理手段としての手続きライブラリは,手続き実行の引数として,下記の機能を具備するデータ構造型を受け付ける。   (2) The procedure library as each processing means of the command statement construction processing device accepts a data structure type having the following functions as an argument for procedure execution.

(a)コマンド文への部分文字列追加のための手続きインタフェースを具備する。   (A) A procedure interface for adding a partial character string to a command sentence is provided.

(b)前記(1)のインタフェースの実行時に受け付けた部分文字列が「定数かどうか」を判定し,その判定結果と共に部分文字列の値をそのまま格納する。この時点で,受け付けた部分文字列の結合操作を行う必要がない。   (B) It is determined whether the partial character string received when the interface of (1) is executed is “a constant”, and the value of the partial character string is stored as it is together with the determination result. At this point, it is not necessary to perform a join operation on the received substrings.

(3)前記(1)の各手続きライブラリは,前記(1)のインタフェース実行時に,各部分文字列の構成要素が定数または非定数の場合に分けて,それぞれに応じた処理をコンテキスト(文中の前後関係)に応じて行い,プログラムを実行する。   (3) When executing the interface of (1), each procedure library of (1) is divided into cases where the constituent elements of each partial character string are constants or non-constants, and processing corresponding to each is performed in the context (in the sentence Execute the program according to the context.

これにより,インジェクション防止,情報漏洩防止などが図られ,安全なプログラム実行が実現できる。   As a result, injection prevention, information leakage prevention, and the like can be achieved, and safe program execution can be realized.

図1は,コマンド文構築処理装置1の構成例を示す図である。   FIG. 1 is a diagram illustrating a configuration example of the command sentence construction processing device 1.

コマンド文構築処理装置1は,文字列生成部10,部分文字列情報記憶部20,コマンド文構築部30,および乱数生成部40を備える。   The command sentence construction processing device 1 includes a character string generation unit 10, a partial character string information storage unit 20, a command sentence construction unit 30, and a random number generation unit 40.

文字列生成部10は,利用者のプログラム4において,外部プログラム5を呼び出すためにコマンド文を作成する場合に,コマンド文に追加される文字列を受け付けるインタフェースを備え,追加される部分文字列の定数/非定数の属性を判断し,部分文字列情報を部分文字列情報記憶部20に格納する処理手段である。   The character string generation unit 10 includes an interface that accepts a character string added to a command sentence when the user program 4 creates a command sentence to call the external program 5, and This is a processing means for determining a constant / non-constant attribute and storing partial character string information in the partial character string information storage unit 20.

また,文字列生成部10は,利用者のプログラム4で使用されるコマンド文の静的要素である定数を定義した定数情報を保持しているものとする。   Further, it is assumed that the character string generation unit 10 holds constant information defining constants that are static elements of command statements used in the user's program 4.

文字列生成部10は,文字列追加部11,定数部分判定部13,部分文字列情報生成部15,定数化設定部17を備える。   The character string generation unit 10 includes a character string addition unit 11, a constant partial determination unit 13, a partial character string information generation unit 15, and a constant setting unit 17.

文字列追加部11は,利用者のプログラム4で外部プログラム5の呼び出し用のコマンド文が作成される時に,コマンド文に追加される部分文字列を受け付ける処理部である。   The character string adding unit 11 is a processing unit that receives a partial character string added to a command sentence when a command sentence for calling the external program 5 is created by the user program 4.

定数部分判定部13は,定数情報をもとに,文字列追加部11が受け付けた部分文字列が静的要素(定数)であるかを判定する処理手段である。部分文字列が定義情報に定義された静的要素であれば,その属性を定数と判断する。一方,部分文字列が静的要素でなく動的な値であれば,その属性を非定数と判断する。   The constant part determination unit 13 is processing means for determining whether the partial character string received by the character string addition unit 11 is a static element (constant) based on constant information. If the substring is a static element defined in the definition information, the attribute is determined to be a constant. On the other hand, if the substring is not a static element but a dynamic value, the attribute is determined to be non-constant.

部分文字列情報生成部15は,部分文字列の部分文字列情報を生成し,部分文字列情報記憶部20に格納する処理手段である。   The partial character string information generation unit 15 is processing means for generating partial character string information of the partial character string and storing it in the partial character string information storage unit 20.

部分文字列情報は,追加された部分文字列の値,その部分文字列がコマンド文に追加される位置(結合位置),定数/非定数の属性などを含む。   The partial character string information includes the value of the added partial character string, the position where the partial character string is added to the command statement (binding position), the constant / non-constant attribute, and the like.

定数化設定部17はユーザによって指定された部分文字列について,その属性を定数に設定する処理手段である。この設定によって,部分文字列が定数情報に該当しない要素であっても,部分文字列情報の属性に定数が設定される。   The constant setting unit 17 is processing means for setting the attribute of a partial character string designated by the user to a constant. With this setting, even if the partial character string is an element not corresponding to the constant information, the constant is set in the attribute of the partial character string information.

部分文字列情報記憶部20は,部分文字列情報を記憶する記憶部である。   The partial character string information storage unit 20 is a storage unit that stores partial character string information.

コマンド文構築部30は,外部プログラム5の呼び出しコマンドの実行時など,コマンド文の構築が必要になったときに,コマンドのコンテキストに対応して具備する処理部を起動する処理手段である。   The command statement constructing unit 30 is a processing unit that activates a processing unit provided corresponding to the context of a command when it is necessary to construct a command statement, such as when a call command of the external program 5 is executed.

コマンド文構築部30は,SQL呼び出し部31,OSコマンド呼び出し部33,HTML生成部35,出力情報生成部37,バインド処理部39を備える。   The command statement construction unit 30 includes an SQL call unit 31, an OS command call unit 33, an HTML generation unit 35, an output information generation unit 37, and a bind processing unit 39.

SQL呼び出し部31は,コマンドがSQLである場合に,外部プログラム5(リレーショナルデータベースなど)への呼び出しに対応するコマンド文を構築する処理部である。SQL呼び出し部31は,部分文字列情報にもとづいて,コマンドのテンプレート文(SQL文)に対し,定数の部分文字列を結合位置にそのまま追加する。また,非定数の部分文字列に対応するプレースホルダ(?)を結合位置に追加する。さらに,非定数の部分文字列の値を,パラメータとしてパラメータリスト310に保持する。   The SQL calling unit 31 is a processing unit that constructs a command statement corresponding to a call to the external program 5 (relational database or the like) when the command is SQL. The SQL calling unit 31 adds the constant partial character string as it is to the coupling position to the command template sentence (SQL sentence) based on the partial character string information. In addition, a placeholder (?) Corresponding to the non-constant partial character string is added to the joining position. Further, the value of the non-constant partial character string is held in the parameter list 310 as a parameter.

SQL呼び出し部31によって,SQLインジェクション攻撃へ対処することができる。   The SQL calling unit 31 can cope with the SQL injection attack.

OSコマンド呼び出し部33は,コマンドがOSコマンドである場合に,外部プログラム5(OSなど)への呼び出しに対応するコマンド文を構築する処理部である。OSコマンド呼び出し部33は,部分文字列情報にもとづいて,OSコマンドのテンプレート文に対し,定数の部分文字列を結合位置にそのまま追加する。また,非定数の部分文字列に対応するプレースホルダを結合位置に追加する。さらに,非定数の部分文字列の値をパラメータリスト310に保持する。   The OS command calling unit 33 is a processing unit that constructs a command statement corresponding to a call to the external program 5 (such as an OS) when the command is an OS command. Based on the partial character string information, the OS command calling unit 33 adds a constant partial character string to the combined position as it is for the template sentence of the OS command. In addition, a placeholder corresponding to the non-constant substring is added to the joining position. Further, the value of the non-constant partial character string is held in the parameter list 310.

OSコマンド呼び出し部33によって,OSコマンドインジェクション攻撃へ対処することができる。   The OS command calling unit 33 can cope with an OS command injection attack.

HTML生成部35は,コマンドがHTML生成である場合に,外部プログラム5へのHTML出力に対応するコマンド文を構築する処理部である。HTML生成部35は,HTMLのテンプレート文に対し,定数の部分文字列を結合位置にそのまま追加する。また,非定数の部分文字列に対応するプレースホルダを結合位置に追加する。さらに,非定数の部分文字列の値を,パラメータリスト310に保持する。   The HTML generation unit 35 is a processing unit that constructs a command statement corresponding to the HTML output to the external program 5 when the command is HTML generation. The HTML generation unit 35 adds a constant partial character string to the combination position as it is for the HTML template sentence. In addition, a placeholder corresponding to the non-constant substring is added to the joining position. Further, the value of the non-constant partial character string is held in the parameter list 310.

HTML生成部35によって,クロスサイトスクリプティング攻撃へ対処することができる。   The HTML generation unit 35 can cope with a cross-site scripting attack.

出力情報生成部37は,コマンドが情報出力(例えば,出力画面の生成など)を行うものである場合に,外部プログラム5(例えば,表示装置など)へのコマンドに対応するコマンド文を構築する処理部である。出力情報生成部37は,情報出力コマンドのテンプレート文に対し,定数の部分文字列を結合位置にそのまま追加する。また,非定数の部分文字列の代わりとして所定の表示文字列(例えば,アスタリスク文字列)を結合位置に追加する。   The output information generation unit 37 constructs a command sentence corresponding to a command to the external program 5 (for example, a display device) when the command is to output information (for example, generation of an output screen). Part. The output information generation unit 37 adds the constant partial character string as it is to the coupling position to the template sentence of the information output command. In addition, a predetermined display character string (for example, an asterisk character string) is added to the coupling position instead of the non-constant partial character string.

出力情報生成部37によって,情報漏洩を防止することができる。   The output information generation unit 37 can prevent information leakage.

バインド処理部39は,SQL呼び出し部31,OSコマンド呼び出し部33,またはHTML生成部35によって,コマンドなどのテンプレート文に追加された非定数の部分文字列に対応するプレースホルダへ,パラメータリスト310に記憶された部分文字列の値をパラメータとして設定する処理部である。   The bind processing unit 39 adds a placeholder corresponding to the non-constant partial character string added to the template sentence such as a command to the parameter list 310 by the SQL calling unit 31, the OS command calling unit 33, or the HTML generation unit 35. It is a processing unit that sets the value of the stored partial character string as a parameter.

乱数生成部40は,表示文字列として用いられる乱数を生成する処理手段である。   The random number generation unit 40 is processing means for generating a random number used as a display character string.

図2に,コマンド文構築処理装置1の処理フローを示す。   FIG. 2 shows a processing flow of the command statement construction processing apparatus 1.

コマンド文構築処理装置1は,利用者のプログラム4の作成処理中に,外部プログラム5への呼び出しコマンド文を作成しようとすると(ステップS1のYES),文字列生成部10が,コマンド文に追加される部分文字列を受け付け,部分文字列の属性判定および部分文字列情報作成などを行う処理(部分文字列作成処理)を実行する(ステップS2)。   When the command statement construction processing device 1 tries to create a command statement for calling the external program 5 during the process of creating the user's program 4 (YES in step S1), the character string generator 10 adds it to the command statement. A partial character string is received, and a process of performing partial character string attribute determination and partial character string information creation (partial character string creation process) is executed (step S2).

その後,外部プログラム5の呼び出し実行によってコマンドの構築が必要になると(ステップS3のYES),コマンド文構築部30が,呼び出す外部プログラム5に対応するコマンド文の構築および実行を行う処理(コマンド文構築処理)を実行する(ステップS4)。   Thereafter, when it is necessary to construct a command by calling the external program 5 (YES in step S3), the command statement constructing unit 30 constructs and executes a command statement corresponding to the external program 5 to be called (command statement construction). Process) is executed (step S4).

[部分文字列作成処理]
図3は,部分文字列作成処理(ステップS2)の処理フローを示す図である。
[Partial string creation processing]
FIG. 3 is a diagram showing a process flow of the partial character string creation process (step S2).

文字列生成部10の文字列追加部11は,利用者のプログラム4において,コマンド文が作成されるときに,コマンド文に追加される部分文字列を順に受け付ける(ステップS20)。ここで,利用者のプログラム4において,図4に示すSQLのコマンド文(select)が作成されるものとする。   The character string adding unit 11 of the character string generating unit 10 sequentially receives partial character strings to be added to the command sentence when the command sentence is created in the user program 4 (step S20). Here, it is assumed that the SQL command statement (select) shown in FIG. 4 is created in the user program 4.

定数部分判定部13は,予め保持している定数情報(コマンドの静的要素(定数)の定義)をもとに,追加された部分文字列が定数であるかを判定する(ステップS21)。追加された部分文字列が定数情報に該当する場合は(ステップS21のYES),その部分文字列に定数の属性を付与し(ステップS22),定数情報に該当しない場合は(ステップS21のNO),その部分文字列に非定数の属性を付与する(ステップS23)。   The constant part determination unit 13 determines whether the added partial character string is a constant based on constant information (definition of a static element (constant) of a command) held in advance (step S21). When the added partial character string corresponds to the constant information (YES in step S21), a constant attribute is given to the partial character string (step S22). When the added partial character string does not correspond to the constant information (NO in step S21). , A non-constant attribute is given to the partial character string (step S23).

そして,部分文字列情報生成部15は,追加される部分文字列ごとに,部分文字列の値,部分文字列が追加される位置(結合位置),定数/非定数のいずれかの属性を含む部分文字列情報を生成し,部分文字列情報記憶部20に格納する(ステップS24)。   The partial character string information generation unit 15 includes, for each partial character string to be added, any one of the attributes of the value of the partial character string, the position where the partial character string is added (joining position), and the constant / non-constant Partial character string information is generated and stored in the partial character string information storage unit 20 (step S24).

ここで,図4に示すコマンド文として,追加された文字列のうち,ユーザID(id)とパスワード(password)についてユーザ入力された部分文字列(okubo)と(pass)は,定数情報に定義されていないので,非定数の文字列と判定される。   Here, as the command statement shown in FIG. 4, among the added character strings, the partial character strings (okubo) and (pass) entered by the user for the user ID (id) and password (password) are defined in the constant information. Because it is not, it is determined as a non-constant character string.

図5に,部分文字列情報の例を示す。   FIG. 5 shows an example of partial character string information.

部分文字列情報として,文字列追加部11が受け付けた部分文字列のすべてについて,文字列の値,定数部分判定部13で判定された属性情報,結合のための位置情報が記録される。   As the partial character string information, the value of the character string, the attribute information determined by the constant partial determination unit 13, and the position information for combination are recorded for all of the partial character strings received by the character string adding unit 11.

例えば,1行目の部分文字列「SELECT * FROM utable WHERE id=“」は,定数情報に定義された要素(定数)であり,テンプレート文の第1番目の文字位置から第31番目の文字位置に結合されることを示す。また,2行目の部分文字列「okubo」は,定数情報に定義された要素ではないので,属性が非定数であり,部分文字列がテンプレート文の第32番目から第36番目の文字位置に結合されることを示す。   For example, the partial character string “SELECT * FROM utable WHERE id =“ ”on the first line is an element (constant) defined in the constant information, and the 31st character position from the 1st character position of the template sentence. Indicates that it is bound to In addition, since the partial character string “okubo” on the second line is not an element defined in the constant information, the attribute is non-constant, and the partial character string is located at the 32nd to 36th character positions of the template sentence. Indicates that they will be combined.

[SQLコマンドのコマンド文構築処理]
利用者のプログラム4で外部プログラム5の呼び出しコマンドの構築が必要となった場合に,コマンド文構築部30は,呼び出しコマンドのコンテキストに対応する呼び出し部を選択して起動する。
[Command sentence construction processing of SQL command]
When the user program 4 needs to construct a call command for the external program 5, the command statement construction unit 30 selects and activates the call unit corresponding to the context of the call command.

呼び出しコマンドがSQLに関するものである場合に,SQL呼び出し部31が起動される。   When the calling command is related to SQL, the SQL calling unit 31 is activated.

図6に,コマンドがSQL呼び出しである場合のコマンド文構築処理(ステップS4)の処理フローを示す。   FIG. 6 shows a process flow of the command statement construction process (step S4) when the command is an SQL call.

SQL呼び出し部31は,部分文字列情報記憶部20から,該当するコマンド文の部分文字列情報を取得し(ステップS400),部分文字列を1つずつ取り出す(ステップS401)。   The SQL calling unit 31 acquires partial character string information of the corresponding command sentence from the partial character string information storage unit 20 (step S400), and extracts partial character strings one by one (step S401).

そして,部分文字列の属性を調べて(ステップS402),部分文字列の定数が属性であれば(ステップS402のYES),コマンドのテンプレート文に部分文字列の値をそのまま追加する(ステップS403)。   Then, the attribute of the partial character string is checked (step S402). If the constant of the partial character string is the attribute (YES in step S402), the value of the partial character string is added to the command template sentence as it is (step S403). .

一方,部分文字列の属性が非定数であれば(ステップS402のNO),部分文字列の値をパラメータリスト310に追加し(ステップS404),コマンドのテンプレート文に非定数の部分文字列に対応する文字としてプレースホルダ(?)を追加する(ステップS405)。   On the other hand, if the attribute of the partial character string is non-constant (NO in step S402), the value of the partial character string is added to the parameter list 310 (step S404), and the command template statement corresponds to the non-constant partial character string. A placeholder (?) Is added as a character to be performed (step S405).

例えば,図5に示す部分文字列情報では,2番目の部分文字列「okubo」と4番目の部分文字列「pass」は,ユーザ入力値であり非定数と判定される。したがって,SQL呼び出し部31は,2,4番目の非定数の部分文字列に相当する位置にプレースホルダ「?0」,「?1」を設定し,パラメータリスト310に部分文字列の値を記録する。   For example, in the partial character string information illustrated in FIG. 5, the second partial character string “okubo” and the fourth partial character string “pass” are user input values and are determined to be non-constant. Accordingly, the SQL calling unit 31 sets placeholders “? 0” and “? 1” at positions corresponding to the second and fourth non-constant partial character strings, and records the values of the partial character strings in the parameter list 310. To do.

図7に,パラメータリスト310の例を示す。パラメータリスト310には,プレースホルダのインデックスと部分文字列の値が記録される。   FIG. 7 shows an example of the parameter list 310. In the parameter list 310, placeholder indexes and partial character string values are recorded.

部分文字列情報の部分文字列すべてについてステップS401〜S405の処理を行い,全ての部分文字列に対する処理が終了したら(ステップS406のYES),部分文字列を追加したテンプレート文で,実行コマンド文(PreparedStatement)を初期化する(ステップS407)。   When all the partial character strings of the partial character string information are processed in steps S401 to S405 and the processing for all the partial character strings is completed (YES in step S406), an execution command statement ( PreparedStatement) is initialized (step S407).

次に,バインド処理部39は,図8に示すように,初期化されたコマンド文のプレースホルダにパラメータリスト310の部分文字列の値を設定する(ステップS408)。   Next, as shown in FIG. 8, the bind processing unit 39 sets the value of the partial character string of the parameter list 310 in the placeholder of the initialized command statement (step S408).

そして,コマンド文構築部30によって,部分文字列の値がバインドされたSQLコマンド文(PreparedStatement)が実行される(ステップS409)。   Then, the command statement construction unit 30 executes the SQL command statement (PreparedStatement) to which the value of the partial character string is bound (step S409).

[OSコマンドのコマンド文構築処理]
利用者のプログラム4の外部プログラム5の呼び出しコマンドがOSコマンドに関するものである場合には,OSコマンド呼び出し部33が起動される。本例では,利用者のプログラム4で,図9(A)に示すOSコマンド(ファイル情報表示および検索)が作成されるとする。
[Command sentence construction processing of OS command]
When the calling command for the external program 5 of the user program 4 is related to the OS command, the OS command calling unit 33 is activated. In this example, it is assumed that an OS command (file information display and search) shown in FIG.

図3の処理フローに示すように,文字列追加部11によってOSコマンドに追加される部分文字列が受け付けられ,定数部分判定部13によって受け付けた部分文字列の属性が判定され,文字列生成部10によって,図9(B)に示す部分文字列情報が生成され記憶されているとする。   As shown in the processing flow of FIG. 3, the partial character string added to the OS command is received by the character string adding unit 11, the attribute of the received partial character string is determined by the constant portion determining unit 13, and the character string generating unit 10, the partial character string information shown in FIG. 9B is generated and stored.

図10に,コマンドがOSコマンドである場合のコマンド文構築処理(ステップS4)の処理フローを示す。   FIG. 10 shows a process flow of the command statement construction process (step S4) when the command is an OS command.

図10に示す処理フローのステップS410〜S419の処理は,図6のステップS400〜S409の各処理に対応する。OSコマンド呼び出し部33が,ステップS410〜S417の処理を行い,図11(A)に示すパラメータリスト310が保持される。そして,バインド処理部39が,ステップS418の処理を行い,図11(B)に示すようにプレースホルダに部分文字列をバインドする。これにより,図9(A)のOSコマンドの実行が可能となる。
[HTMLのコマンド文構築処理]
利用者のプログラム4において外部プログラム5へ出力するHTMLが生成される場合に,HTML生成部35が起動される。本例では,図12(A)に示すHTMLが記述され,図3に示す処理フローにしたがって,図12(B)に示す部分文字列情報が生成され記憶されているとする。
The processes in steps S410 to S419 in the process flow shown in FIG. 10 correspond to the processes in steps S400 to S409 in FIG. The OS command calling unit 33 performs the processing of steps S410 to S417, and the parameter list 310 shown in FIG. Then, the bind processing unit 39 performs the process of step S418 and binds the partial character string to the placeholder as shown in FIG. As a result, the OS command shown in FIG. 9A can be executed.
[HTML command statement construction processing]
When HTML to be output to the external program 5 is generated in the user program 4, the HTML generation unit 35 is activated. In this example, it is assumed that the HTML shown in FIG. 12A is described, and the partial character string information shown in FIG. 12B is generated and stored in accordance with the processing flow shown in FIG.

図13に,HTML生成の場合のコマンド文構築処理(ステップS4)の処理フローを示す。   FIG. 13 shows a process flow of the command sentence construction process (step S4) in the case of HTML generation.

図13に示す処理フローのステップS420〜S429の処理は,図6のステップS400〜S409の各処理にほぼ対応する。そして,HTML生成部35が,ステップS420〜S427の処理を行い,バインド処理部39がステップS428の処理を行う。   The processes in steps S420 to S429 in the process flow shown in FIG. 13 substantially correspond to the processes in steps S400 to S409 in FIG. Then, the HTML generation unit 35 performs the processes of steps S420 to S427, and the bind processing unit 39 performs the process of step S428.

ただし,ステップS428の処理において,ステップS408の処理と同様に,プレースホルダに部分文字列の値をバインドするが,さらに,既知の手法によって,パラメータのサニタイジング(無害化処理)を行う。   However, in the process of step S428, as in the process of step S408, the value of the partial character string is bound to the placeholder, but further, the parameter sanitization (detoxification process) is performed by a known method.

また,ステップS429の処理では,コマンド文構築部30が,バインドされたHTMLを外部プログラム5へ出力する。   Further, in the process of step S 429, the command statement construction unit 30 outputs the bound HTML to the external program 5.

[情報出力のコマンド文構築処理]
利用者のプログラム4において,外部プログラム5へ情報出力を行う場合には出力情報生成部37が起動される。
[Information output command statement construction processing]
When the user program 4 outputs information to the external program 5, an output information generation unit 37 is activated.

例えば,表示装置にデータベースから取得した情報を表示させる場合に,データ表示コマンドに,データベースからの取得値が組み込まれる。データベースから「氏名」「年齢」のデータ項目について「(大久保 隆代)」「(28)」を得たときに,通常では,以下のとおり情報がすべて表示される。   For example, when displaying information acquired from a database on a display device, the acquired value from the database is incorporated into the data display command. When “(Takayo Okubo)” and “(28)” are obtained for the data items of “name” and “age” from the database, all information is normally displayed as follows.


氏名=(大久保 隆代);年齢=(28)

プライバシー保護の観点などから,データ項目の情報を非表示/代替表示とするプログラミングが必要な場合でも,プログラムミスによって表示させてしまうおそれがある。

Name = (Takayo Okubo); Age = (28)

From the viewpoint of privacy protection, there is a risk that data items may be displayed due to a program error even when programming to hide / alternate the data item information is necessary.

文字列生成部10では,データベースから取得した情報(値)は定数情報に定義されていないため,属性が非定数となり,図14に示す部分文字列情報を生成する。   In the character string generation unit 10, since the information (value) acquired from the database is not defined in the constant information, the attribute becomes non-constant and the partial character string information shown in FIG. 14 is generated.

そこで,利用者のプログラム4で外部プログラム5(表示装置)へデータベースの取得値を表示するコマンドが実行される場合に,出力情報生成部37は,コマンドのテンプレート文に対し,定数の部分文字列の値「氏名」「年齢」を結合位置でそのまま追加し,非定数の部分文字列の値「(大久保 隆代)」「(28)」の代わりに,表示文字列(アスタリスク文字列)を追加する。   Therefore, when the user program 4 executes a command for displaying the acquired value of the database to the external program 5 (display device), the output information generation unit 37 performs a constant partial character string for the command template sentence. Values "name" and "age" are added as they are at the join position, and display strings (asterisk strings) are added instead of non-constant substring values "(Takayo Okubo)" and "(28)" To do.

また,出力情報生成部37は,乱数生成部40によって生成された乱数を,表示文字列として使用することができる。   Further, the output information generation unit 37 can use the random number generated by the random number generation unit 40 as a display character string.

これにより,データベースの情報が図15(A)に示すように表示され,プログラムミスによる不用意な表示処理から生じる情報漏洩を防止することができる。   As a result, the information in the database is displayed as shown in FIG. 15A, and information leakage resulting from inadvertent display processing due to a program mistake can be prevented.

さらに,アプリケーションによっては,データベースからの取得情報に,表示対象と非表示の対象とが混在する場合がある。一例として,「氏名」の情報を表示し「年齢」の情報を非表示とする場合がある。   Further, depending on the application, there are cases where information to be acquired from the database includes a display target and a non-display target. As an example, “name” information may be displayed and “age” information may be hidden.

この場合に,定数化設定部17によって出力対象とする取得値を設定することができる。定数化設定部17はインタフェースを備え,ユーザ指示によって出力対象として部分文字列情報の2番目の部分文字列「大久保 隆代」が指定されると,この部分文字列の属性を非定数から定数へ変更する。   In this case, the acquisition value to be output can be set by the constant setting unit 17. The constant setting unit 17 has an interface, and when the second partial character string “Takayo Okubo” of the partial character string information is designated as an output target by a user instruction, the attribute of the partial character string is changed from non-constant to constant. change.

この属性変更によって,出力情報生成部37が,属性が定数の部分文字列の値(大久保 隆代)をそのままコマンドのテンプレートに追加するので,図15(B)に示すように,データベースの「氏名」の情報(大久保 隆代)が表示され,また,それ以外の非定数の部分文字列の値は,表示文字列(アスタリスク文字列,乱数)が表示される。   By this attribute change, the output information generation unit 37 adds the value of the partial character string whose attribute is a constant (Takayo Okubo) as it is to the command template. Therefore, as shown in FIG. "(Takayo Okubo)" is displayed, and the display character string (asterisk character string, random number) is displayed for other non-constant substring values.

図16に,コマンドが情報出力である場合のコマンド文構築処理(ステップS4)の処理フローを示す。   FIG. 16 shows a processing flow of command statement construction processing (step S4) when the command is information output.

出力情報生成部37は,部分文字列情報記憶部20から表示対象となる部分文字列情報(データベースのデータ)を取得し(ステップS430),各項目(部分文字列)を1つずつ取り出す(ステップS431)。   The output information generation unit 37 acquires partial character string information (database data) to be displayed from the partial character string information storage unit 20 (step S430), and takes out each item (partial character string) one by one (step S430). S431).

そして,部分文字列の属性を判定し(ステップS432),部分文字列の定数が属性であれば(ステップS432のYES),情報出力コマンドのテンプレート文に部分文字列の値をそのまま追加する(ステップS433)。   Then, the attribute of the partial character string is determined (step S432). If the constant of the partial character string is an attribute (YES in step S432), the value of the partial character string is added to the template sentence of the information output command as it is (step S432). S433).

一方,部分文字列の属性が非定数であれば(ステップS432のNO),表示文字列を生成し(ステップS434),コマンドのテンプレート文に生成した表示文字列を追加する(ステップS435)。   On the other hand, if the attribute of the partial character string is non-constant (NO in step S432), a display character string is generated (step S434), and the generated display character string is added to the command template sentence (step S435).

部分文字列情報の部分文字列すべてについてステップS431〜S435の処理を行い,全ての部分文字列に対する処理が終了したら(ステップS436のYES),部分文字列を追加したコマンドのテンプレート文を引数とした外部プログラム5の呼び出しを実行する(ステップS437)。   When all the partial character strings of the partial character string information are processed in steps S431 to S435 and the processing for all the partial character strings is completed (YES in step S436), the command template sentence to which the partial character string is added is used as an argument. The calling of the external program 5 is executed (step S437).

以下,本発明のより具体的な実施例を示す。   Hereinafter, more specific examples of the present invention will be described.

実施例において,コマンド文構築処理装置1は,文字列生成部10,およびSQL呼び出し部31を備えるコマンド文構築部30を備えるものとする。コマンド文構築処理装置1は,Javaプログラムとして実装される。   In the embodiment, the command statement construction processing device 1 is assumed to include a command statement construction unit 30 including a character string generation unit 10 and an SQL call unit 31. The command statement construction processing device 1 is implemented as a Java program.

[実施例1]
実施例1において防御対象となるインジェクション攻撃を説明する。攻撃の一例として,攻撃者が,ユーザ入力でなく,一旦メモリ上やデータベースに格納された値を利用してインジェクション攻撃(セカンドオーダーSQLインジェクション攻撃)を行う場合が考えられ,以下のような状態が想定される。
[Example 1]
An injection attack that is a defense target in the first embodiment will be described. As an example of an attack, it is conceivable that an attacker performs an injection attack (second order SQL injection attack) using a value temporarily stored in a memory or database instead of a user input. is assumed.

まず,攻撃者が,ユーザ登録時に「’admin’--」というユーザIDで登録しておく。   First, the attacker registers with a user ID of “’ admin ’-” at the time of user registration.

ここで,パスワード変更時に以下のSQL呼び出しを実行するようにプログラムが書かれているとする。   Here, it is assumed that the program is written to execute the following SQL call when the password is changed.


sql="select * from users where username='" + username + "'
and password='" + oldpassword"'";
sql="update users set password='"
+ newpassword + "' where username='" + rso("username") + "'";

すると,登録されたユーザIDにより,上記コードの3,4行目のSQLは以下のように変えられ,“admin”のパスワードが攻撃者によって変更されてしまう。

sql = "select * from users where username = '" + username + "'
and password = '"+ oldpassword"'";
sql = "update users set password = '"
+ newpassword + "'where username ='" + rso ("username") + "'";

Then, the SQL of the third and fourth lines of the above code is changed as follows by the registered user ID, and the password of “admin” is changed by the attacker.


update users set password='passwd2' where username='admin'--'

したがって,ユーザ入力値のみを対象としてサニタイズやバインドメカニズムの適用を行っていると,セキュリティ対策の対象外となっているような値,過去に入力された値やデータベースに格納されている値など,を利用されて攻撃されるおそれがある。前述のコード例では,SQL呼び出しの下段(3,4行目)のSQLの"username"が,データベースに格納された値であるために,サニタイズやバインドメカニズムの対象から漏れてしまうことが原因となっている。

update users set password = 'passwd2' where username = 'admin'-'

Therefore, if sanitization or binding mechanism is applied only to user input values, values that are not subject to security measures, values entered in the past, values stored in the database, etc. There is a risk of being attacked. In the above code example, the SQL “username” in the lower part (3rd and 4th lines) of the SQL call is a value stored in the database, so it is leaked from the sanitization and bind mechanism targets. It has become.

このような攻撃に対処できるコマンド文構築処理装置1の構成と動作を説明する。   The configuration and operation of the command sentence construction processing apparatus 1 that can cope with such an attack will be described.

(1)文字列生成部10は,以下に示すSQLの静的構文要素を定義する定義情報を備える。   (1) The character string generation unit 10 includes definition information that defines the following static syntax elements of SQL.


- select * from users where username=
- and password=
- update users set password=
- where username=

また,文字列生成部10は,以下のインタフェース(文字列追加部11に相当する機能)を持つ。

-select * from users where username =
-and password =
-update users set password =
-where username =

The character string generation unit 10 has the following interface (a function corresponding to the character string addition unit 11).


public class StringX {
public void add(Object o){
}
}

(2)プログラマが,文字列生成部10のインタフェースを用いて,SQLクエリを構築する文字列を以下のように記述する。

public class StringX {
public void add (Object o) {
}
}

(2) A programmer describes a character string for constructing an SQL query using the interface of the character string generation unit 10 as follows.


StringX sx;
...
sx.add{QCOnst.SELECT}; //select * from users where username=
sx.add(username);
sx.add(QConst.AND); //and password=
sx.add(oldpassword);
....
sx.add(QCOnst.UPDATE); //update users set password=
sx.add(newpassword);
sx.add(QConst.WHERE); // where username=
sx.add(username);

(3)前記StringX#add(),すなわち文字列生成部10のインタフェースが実行された場合に,add()内部では以下の処理が実行される。

StringX sx;
...
sx.add {QCOnst.SELECT}; // select * from users where username =
sx.add (username);
sx.add (QConst.AND); // and password =
sx.add (oldpassword);
....
sx.add (QCOnst.UPDATE); // update users set password =
sx.add (newpassword);
sx.add (QConst.WHERE); // where username =
sx.add (username);

(3) When the StringX # add (), that is, the interface of the character string generation unit 10 is executed, the following processing is executed inside add ().

(3a)add()の引数(Object)が,定数かどうかを判定する(定数部分判定部13に相当する機能)。本実施例では,定数かどうかは,そのObjectが指定されたenum型(QConst)であるかどうかで判断する。   (3a) It is determined whether or not the argument (Object) of add () is a constant (function corresponding to the constant portion determination unit 13). In this embodiment, whether or not it is a constant is determined by whether or not the Object is a specified enum type (QConst).

(3b)定数のものには定数フラグを付与し,部分文字列情報記憶部20に格納する。上記(2)の最後4行のコードが実行された時点で,部分文字列情報記憶部20に格納されている部分文字列情報は,図17(A)に示すとおりになる。   (3b) A constant flag is assigned to a constant and stored in the partial character string information storage unit 20. When the last four lines of code (2) are executed, the partial character string information stored in the partial character string information storage unit 20 is as shown in FIG.

(4)プログラマは,コマンド文構築処理装置1の一部として用意された,安全なSQL実行インタフェースSqfeExec#execSQL()を,sxを引数として実行するプログラム4を記述する。そして,execSQL実行時には以下の処理が行われる。   (4) The programmer describes a program 4 that executes the safe SQL execution interface SqfeExec # execSQL () prepared as a part of the command statement construction processing device 1 with sx as an argument. The following processing is performed when execSQL is executed.

(4a)部分文字列を順に調べ,部分文字列が定数であれば,PreparedStatementの構成文字列qに追加する。   (4a) The partial character strings are checked in order, and if the partial character string is a constant, it is added to the PreparedStatement component character string q.

(4b)部分文字列が定数でなければ,部分文字列の値をパラメータリスト310に追加し,上記文字列qにはプレースホルダ(?)を追加する。   (4b) If the partial character string is not a constant, the value of the partial character string is added to the parameter list 310, and a placeholder (?) Is added to the character string q.

(4c)前記(4a),(4b)の処理が完了すると,図17(B)に示すPreparedStatementの初期化文字列と,図17(C)に示すパラメータリスト310が得られる。   (4c) When the processing of (4a) and (4b) is completed, the PreparedStatement initialization character string shown in FIG. 17B and the parameter list 310 shown in FIG. 17C are obtained.

(4d)次に,得られた初期化文字列を用いてPreparedStatementの初期化が行われ,プレースホルダにパラメータリスト310の値(パラメータ)がバインドされる。そして,PreparedStatement.executeQuery()によりSQL実行が行われる。   (4d) Next, the PreparedStatement is initialized using the obtained initialization character string, and the value (parameter) of the parameter list 310 is bound to the placeholder. Then, SQL execution is performed by PreparedStatement.executeQuery ().

以上の処理が実行された場合に,攻撃者によって過去に登録されたユーザID「admin'--」は,値そのものがパラメータとして扱われるため,「'--」(以降を無視する)が構文を変更する要素として機能しない。これにより,セカンドオーダーSQLインジェクション攻撃を防御することができる。   When the above processing is executed, the user ID “admin '-” registered by the attacker in the past is treated as a parameter, so “'-” (ignoring the rest) is the syntax. Does not function as an element to change. Thereby, a second order SQL injection attack can be defended.

また,利用者が定数として定義すべき箇所を誤ってそのまま入力させた場合,例えば,前記コードにおいて「update users set...」の部分を定数として定義しない場合には,その部分文字列が,非定数すなわちパラメータとみなされ,生成されるPreparedStatementの初期化文字列は以下のとおりになる。   In addition, when the user accidentally inputs a part to be defined as a constant, for example, when the part of “update users set ...” is not defined as a constant in the above code, the partial character string is The initialization string of PreparedStatement that is regarded as non-constant, that is, a parameter, is as follows.


?? and where userid=?

このようなコードは,PreparedStatementの構文として不正であってエラーとなるため,プログラムミスとして検出が可能になる。

?? and where userid =?

Since such a code is illegal as an PreparedStatement syntax and results in an error, it can be detected as a program error.

[実施例2]
さらに,実施例2として,プログラマがプログラムミスにより,データベースから取得した非表示とするべき情報を誤って表示させてしまう場合を想定する。例えば,プログラマが,本来表示すべきでないユーザID,パスワードを誤って表示させるプログラムを書くとする。
[Example 2]
Further, as a second embodiment, it is assumed that a programmer erroneously displays information to be hidden acquired from a database due to a program mistake. For example, assume that a programmer writes a program that erroneously displays a user ID and password that should not be displayed.

コマンド文構築処理装置1では,出力に,コマンド構築部30の各手段として用意した出力ライブラリを必ず用いることになる。そこで,プログラマは以下のように記述する。   In the command statement construction processing apparatus 1, an output library prepared as each means of the command construction unit 30 is always used for output. Therefore, the programmer describes as follows.


StringX sx;
sx.add(OutConst.userid); //userID =
sx.add(userid);
sx.add(OutConst.password);// password =
sx.add(password);
SafeExec.outHTML(sx);

前記のコードにおいて,sx.add()では実施例1と同様に,追加された部分文字列が定数かどうかの判別が行われるので,最終的に生成される部分文字列の構造は,図18に示す部分文字列情報のとおりとなる。

StringX sx;
sx.add (OutConst.userid); // userID =
sx.add (userid);
sx.add (OutConst.password); // password =
sx.add (password);
SafeExec.outHTML (sx);

In the above code, sx.add () determines whether or not the added partial character string is a constant, as in the first embodiment. Therefore, the structure of the finally generated partial character string is shown in FIG. The partial character string information shown in FIG.

また,SafeExec.outHTML()(HTML生成部35のインタフェースに相当)の実行時において,部分文字列が非定数の場合には実際の部分文字列の値(文字)の代わりに「*」が出力される。その結果,HTMLに出力される文字列は下記の通りとなる。   Also, when executing SafeExec.outHTML () (corresponding to the interface of the HTML generation unit 35), if the partial character string is non-constant, "*" is output instead of the actual partial character string value (character). Is done. As a result, the character string output to HTML is as follows.


user ID = ***** password = *****

これにより,非表示とする情報を誤って表示させるというプログラムミスがあっても,情報漏洩を防止することができる。

user ID = ***** password = *****

As a result, information leakage can be prevented even if there is a program mistake that erroneously displays information to be hidden.

さらに,データベースからの取得値の一部だけを隠蔽する場合には,部分文字列の追加時に,明示的に「定数」とみなす部分文字列を特定する機能(定数化設定部17に相当)によって,データベースからの取得値のうち表示させる情報を特定することができる。   Furthermore, when only a part of the acquired value from the database is concealed, a function (equivalent to the constantization setting unit 17) that specifies a partial character string that is explicitly regarded as a “constant” when adding the partial character string is used. , It is possible to specify the information to be displayed among the acquired values from the database.

一例として,パスワードは隠したいが,ユーザIDはそのまま表示させたい場合に,プログラマは前記のコードの代わりに下記のように記述する。   As an example, when it is desired to hide the password but to display the user ID as it is, the programmer describes the following instead of the above code.


StringX sx;
sx.add(OutConst.userid); //userID =
sx.addConst(userid);
sx.add(OutConst.password);// password =
sx.add(password);
SafeExec.outHTML(sx);

String#addConst()(定数化設定部17のインタフェース,文字列追加部11に相当)は,文字列が追加された時に,それを強制的に定数とみなして部分文字列に追加する。

StringX sx;
sx.add (OutConst.userid); // userID =
sx.addConst (userid);
sx.add (OutConst.password); // password =
sx.add (password);
SafeExec.outHTML (sx);

String # addConst () (corresponding to the interface of the constantization setting unit 17 and the character string addition unit 11), when a character string is added, is forcibly regarded as a constant and added to the partial character string.

この結果,生成される部分文字列情報は,図19に示すとおりとなり,以下のようなHTML出力となる。   As a result, the generated partial character string information is as shown in FIG. 19, and the following HTML output is obtained.


user ID = admin password = *****

以上,本発明をその実施の形態により説明したが,本発明はその主旨の範囲において種々の変形が可能であることは当然である。

user ID = admin password = *****

Although the present invention has been described above with reference to the embodiments, it is obvious that the present invention can be variously modified within the scope of the gist thereof.

本発明の実施の形態におけるコマンド文構築処理装置の構成例を示す図である。It is a figure which shows the structural example of the command sentence construction processing apparatus in embodiment of this invention. 本発明の実施の形態におけるコマンド文構築処理装置の処理フローを示す図である。It is a figure which shows the processing flow of the command sentence structure processing apparatus in embodiment of this invention. 本発明の実施の形態における部分文字列作成処理の処理フローを示す図である。It is a figure which shows the processing flow of the partial character string preparation process in embodiment of this invention. 本発明の実施の形態において,作成されるSQLコマンド文の例を示す図である。In an embodiment of the invention, it is a figure showing an example of a SQL command sentence created. 本発明の実施の形態における部分文字列情報の例を示す図である。It is a figure which shows the example of the partial character string information in embodiment of this invention. コマンドがSQL呼び出しである場合のコマンド文構築処理の処理フローを示す図である。It is a figure which shows the processing flow of a command sentence construction process in case a command is a SQL call. コマンドがSQL呼び出しである場合のパラメータリストの例を示す図である。It is a figure which shows the example of a parameter list | wrist in case a command is a SQL call. コマンドがSQL呼び出しである場合のバインド例を示す図である。It is a figure which shows the example of a binding when a command is a SQL call. OSコマンドが作成される場合に,作成されるOSコマンドおよび部分文字列情報の例を示す図である。It is a figure which shows the example of OS command produced when an OS command is produced, and partial character string information. コマンドがOSコマンド呼び出しである場合のコマンド文構築処理の処理フローを示す図である。It is a figure which shows the processing flow of a command sentence construction process in case a command is OS command call. コマンドがOSコマンド呼び出しである場合のパラメータリストおよびバインド例を示す図である。It is a figure which shows the parameter list | wrist and binding example when a command is OS command call. HTMLが作成される場合に,作成されるHTMLおよび部分文字列情報の例を示す図である。When HTML is created, it is a figure which shows the example of HTML produced and partial character string information. HTMLが作成される場合のコマンド文構築処理の処理フローを示す図である。It is a figure which shows the processing flow of a command sentence construction process in case HTML is produced. コマンドが情報出力の場合に,作成される部分文字列情報の例を示す図である。It is a figure which shows the example of the partial character string information produced when a command is information output. コマンドが情報出力の場合の情報出力の例を示す図である。It is a figure which shows the example of an information output when a command is information output. コマンドが情報出力である場合のコマンド文構築処理の処理フローを示す図である。It is a figure which shows the processing flow of a command sentence construction process in case a command is information output. コマンドが情報出力である場合の部分文字列情報,情報出力のコマンド,パラメータリスト例を示す図である。It is a figure which shows the partial character string information in case a command is information output, the command of information output, and a parameter list example. 実施例1における部分文字列情報の例を示す図である。It is a figure which shows the example of the partial character string information in Example 1. FIG. 実施例2における情報出力の例を示す図である。10 is a diagram illustrating an example of information output in Embodiment 2. FIG. バインドメカニズムによるインジェクション攻撃防止の仕組みを説明するための図である。It is a figure for demonstrating the mechanism of the injection attack prevention by a bind mechanism. バインドメカニズムが有効でない場合を説明するための図である。It is a figure for demonstrating the case where a binding mechanism is not effective.

符号の説明Explanation of symbols

1 コマンド文構築処理装置
10 文字列生成部
11 文字列追加部
13 定数部分判定部
15 部分文字列情報生成部
17 定数化設定部
20 部分文字列情報記憶部
30 コマンド文構築部
31 SQL呼び出し部
33 OSコマンド呼び出し部
35 HTML生成部
37 出力情報生成部
39 バインド処理部
310 パラメータリスト
4 利用者のプログラム
5 外部プログラム
DESCRIPTION OF SYMBOLS 1 Command sentence construction processing apparatus 10 Character string production | generation part 11 Character string addition part 13 Constant part determination part 15 Partial character string information generation part 17 Constantization setting part 20 Partial character string information storage part 30 Command sentence construction part 31 SQL call part 33 OS command calling unit 35 HTML generating unit 37 Output information generating unit 39 Binding processing unit 310 Parameter list 4 User program 5 External program

Claims (8)

部分文字列情報記憶部を備えるコンピュータに,
所定のプログラムにおいて使用される,外部プログラムを読み出すためのコマンド文に追加される部分文字列を取得する部分文字列取得処理と,
前記コマンド文の静的要素として複数の単語からなる文字列を定義した定数情報をもとに,前記追加される部分文字列が定数であるかを判定する定数部分判定処理と,
前記部分文字列の値,当該部分文字列が追加される結合位置,および前記定数部分判定処理の判定結果をもとに前記部分文字列が定数または非定数のいずれかを示す属性を含む部分文字列情報を生成して前記部分文字列情報記憶部に格納する部分文字列情報生成処理と,
前記コマンド文を構築する場合に,前記部分文字列情報記憶部から前記コマンド文の部分文字列情報を取得し,前記部分文字列の属性が定数の場合に当該部分文字列の値を結合位置に従って前記コマンド文の所定のテンプレート文字列に追加する処理と,または前記部分文字列の属性が非定数の場合に当該部分文字列の値をパラメータリストに保持し,当該部分文字列に対応するプレースホルダを結合位置に従って前記テンプレート文字列に追加し,当該テンプレート文字列に追加したプレースホルダに前記パラメータリストに保持した当該部分文字列の値を設定する処理とを行うことによって,前記実行コマンド文を構築するコマンド文構築処理とを
実行させるためのコマンド文構築プログラム。
In a computer equipped with a partial character string information storage unit,
Partial character string acquisition processing for acquiring a partial character string added to a command statement for reading an external program used in a predetermined program;
A constant part determination process for determining whether the added partial character string is a constant based on constant information defining a character string consisting of a plurality of words as a static element of the command statement;
A partial character including an attribute indicating whether the partial character string is a constant or a non-constant based on a value of the partial character string, a coupling position where the partial character string is added, and a determination result of the constant partial determination process Partial character string information generation processing for generating column information and storing it in the partial character string information storage unit;
When constructing the command sentence, the partial character string information of the command sentence is acquired from the partial character string information storage unit, and when the attribute of the partial character string is a constant, the value of the partial character string is determined according to the coupling position. A placeholder corresponding to the processing to be added to a predetermined template character string of the command statement or the value of the partial character string is stored in the parameter list when the attribute of the partial character string is non-constant. Is added to the template character string according to the combination position, and the execution command statement is constructed by setting the value of the partial character string held in the parameter list to the placeholder added to the template character string. A command statement construction program for executing command statement construction processing.
前記コマンド文構築処理において,前記属性が非定数の部分文字列について,前記プレースホルダを前記テンプレート文字列の結合位置に追加し,当該非定数の部分文字列の値をパラメータリストに格納し,前記パラメータリストの部分文字列の値を前記プレースホルダに設定する処理を行うことによって,前記実行コマンド文を構築する処理を,
前記コンピュータに実行させるための請求項1に記載のコマンド文構築プログラム。
In the command statement building process, the attribute for the partial string of the non-constant, add before Kipu race holder coupling position of the template string, and stores the value of the substring of the non-constant parameter list , A process of constructing the execution command statement by performing a process of setting a value of a partial character string of the parameter list in the placeholder,
The command sentence construction program according to claim 1 for making said computer run.
前記コマンド文構築処理において,前記コマンド文が情報出力を行うものである場合に,前記プレースホルダに前記パラメータリストの部分文字列の値の代わりに所定の表示文字列を設定する処理を,
前記コンピュータに実行させるための請求項2に記載のコマンド文構築プログラム。
In the command statement construction process, when the command statement is to output information, a process of setting a predetermined display character string instead of the value of the partial character string of the parameter list in the placeholder,
The command sentence construction program according to claim 2 for making said computer run.
前記コマンド文構築処理において,前記コマンド文が情報出力を行うものである場合に,前記属性が非定数の部分文字列について,当該部分文字列の値の代わりに所定の表示文字列を結合位置に追加する処理を行うことによって,前記実行コマンド文を構築する処理を,
前記コンピュータに実行させるための請求項1に記載のコマンド文構築プログラム。
In the command statement construction process, when the command statement is for outputting information, for a partial character string whose attribute is non-constant, a predetermined display character string is used as a coupling position instead of the value of the partial character string. The process of constructing the execution command statement by performing the process of adding,
The command sentence construction program according to claim 1 for making said computer run.
ユーザによって指示された部分文字列の属性を定数とする定数化指定処理を,
前記コンピュータに実行させるための請求項3または請求項4に記載のコマンド文構築プログラム。
Constantization specification processing that uses the attribute of the substring specified by the user as a constant,
The command sentence construction program according to claim 3 or 4 for making said computer run.
前記出力コマンド文構築処理において,任意の数列または文字列である乱数を生成し,前記表示文字列として用いる
ことを特徴とする請求項3または請求項4に記載のコマンド文構築プログラム。
5. The command sentence construction program according to claim 3, wherein in the output command sentence construction process, a random number that is an arbitrary number sequence or character string is generated and used as the display character string.
部分文字列情報記憶部を備えるコンピュータが実行する処理方法であって,
所定のプログラムにおいて使用される,外部プログラムを読み出すためのコマンド文に追加される部分文字列を取得する部分文字列取得過程と,
前記コマンド文の静的要素として複数の単語からなる文字列を定義した定数情報をもとに,前記追加される部分文字列が定数であるかを判定する定数部分判定過程と,
前記部分文字列の値,当該部分文字列が追加される結合位置,および前記定数部分判定処理の判定結果をもとに前記部分文字列が定数または非定数のいずれかを示す属性を含む部分文字列情報を生成して前記部分文字列情報記憶部に格納する部分文字列情報生成過程と,
前記コマンド文を構築する場合に,前記部分文字列情報記憶部から前記コマンド文の部分文字列情報を取得し,前記部分文字列の属性が定数の場合に当該部分文字列の値を結合位置に従って前記コマンド文の所定のテンプレート文字列に追加する処理と,または前記部分文字列の属性が非定数の場合に当該部分文字列の値をパラメータリストに保持し,当該部分文字列に対応するプレースホルダを結合位置に従って前記テンプレート文字列に追加し,当該テンプレート文字列に追加したプレースホルダに前記パラメータリストに保持した当該部分文字列の値を設定する処理とを行うことによって,前記実行コマンド文を構築するコマンド文構築過程とを,
備えるコマンド文構築処理方法。
A processing method executed by a computer including a partial character string information storage unit,
A substring acquisition process for acquiring a substring added to a command statement for reading an external program used in a predetermined program;
A constant part determination process for determining whether the added partial character string is a constant based on constant information defining a character string consisting of a plurality of words as a static element of the command statement;
A partial character including an attribute indicating whether the partial character string is a constant or a non-constant based on a value of the partial character string, a coupling position where the partial character string is added, and a determination result of the constant partial determination process Partial character string information generation process for generating column information and storing it in the partial character string information storage unit;
When constructing the command sentence, the partial character string information of the command sentence is acquired from the partial character string information storage unit, and when the attribute of the partial character string is a constant, the value of the partial character string is determined according to the coupling position. A placeholder corresponding to the processing to be added to a predetermined template character string of the command statement or the value of the partial character string is stored in the parameter list when the attribute of the partial character string is non-constant. Is added to the template character string according to the combination position, and the execution command statement is constructed by setting the value of the partial character string held in the parameter list to the placeholder added to the template character string. The command statement construction process to
Provided command sentence construction processing method.
所定のプログラムにおいて使用される,外部プログラムを読み出すためのコマンド文に追加される部分文字列を取得する部分文字列取得部と,
前記コマンド文の静的要素として複数の単語からなる文字列を定義した定数情報をもとに,前記追加される部分文字列が定数であるかを判定する定数部分判定部と,
前記部分文字列の値,当該部分文字列が追加される結合位置,および前記定数部分判定処理の判定結果をもとに前記部分文字列が定数または非定数のいずれかを示す属性を含む部分文字列情報を生成して部分文字列情報記憶部に格納する部分文字列情報生成部と,
前記コマンド文を構築する場合に,前記部分文字列情報記憶部から前記コマンド文の部分文字列情報を取得し,前記部分文字列の属性が定数の場合に当該部分文字列の値を結合位置に従って前記コマンド文の所定のテンプレート文字列に追加する処理と,または前記部分文字列の属性が非定数の場合に当該部分文字列の値をパラメータリストに保持し,当該部分文字列に対応するプレースホルダを結合位置に従って前記テンプレート文字列に追加し,当該テンプレート文字列に追加したプレースホルダに前記パラメータリストに保持した当該部分文字列の値を設定する処理とを行うことによって,前記実行コマンド文を構築するコマンド文構築部とを
備えるコマンド文構築処理装置。
A partial character string acquisition unit for acquiring a partial character string to be added to a command statement for reading an external program used in a predetermined program;
A constant part determination unit for determining whether the added partial character string is a constant based on constant information defining a character string consisting of a plurality of words as a static element of the command statement;
A partial character including an attribute indicating whether the partial character string is a constant or a non-constant based on a value of the partial character string, a coupling position where the partial character string is added, and a determination result of the constant partial determination process A partial character string information generation unit that generates column information and stores it in the partial character string information storage unit;
When constructing the command sentence, the partial character string information of the command sentence is acquired from the partial character string information storage unit, and when the attribute of the partial character string is a constant, the value of the partial character string is determined according to the coupling position. A placeholder corresponding to the processing to be added to a predetermined template character string of the command statement or the value of the partial character string is stored in the parameter list when the attribute of the partial character string is non-constant. Is added to the template character string according to the combination position, and the execution command statement is constructed by setting the value of the partial character string held in the parameter list to the placeholder added to the template character string. A command sentence construction processing device comprising: a command sentence construction unit for performing.
JP2008009562A 2008-01-18 2008-01-18 Command statement construction program, processing method, and processing device Expired - Fee Related JP5145967B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2008009562A JP5145967B2 (en) 2008-01-18 2008-01-18 Command statement construction program, processing method, and processing device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2008009562A JP5145967B2 (en) 2008-01-18 2008-01-18 Command statement construction program, processing method, and processing device

Publications (2)

Publication Number Publication Date
JP2009169846A JP2009169846A (en) 2009-07-30
JP5145967B2 true JP5145967B2 (en) 2013-02-20

Family

ID=40970910

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2008009562A Expired - Fee Related JP5145967B2 (en) 2008-01-18 2008-01-18 Command statement construction program, processing method, and processing device

Country Status (1)

Country Link
JP (1) JP5145967B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110474888A (en) * 2019-07-26 2019-11-19 广东睿江云计算股份有限公司 A kind of free-standing sql injection defence analysis alarm method and its system based on php

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6120129A (en) * 1984-07-06 1986-01-28 Hitachi Ltd Information processing method of plural code systems
JPH0259952A (en) * 1988-08-26 1990-02-28 Nec Corp Protection system for access right information
JPH05298116A (en) * 1992-04-23 1993-11-12 Hokkaido Nippon Denki Software Kk Compiler system
JPH0695890A (en) * 1992-09-10 1994-04-08 Toyo Commun Equip Co Ltd Name replacement system in compiler
JPH08329009A (en) * 1995-05-31 1996-12-13 Puromisu Kk Personal code number registration system
JP2005250530A (en) * 2004-03-01 2005-09-15 Citizen Watch Co Ltd Character input device

Also Published As

Publication number Publication date
JP2009169846A (en) 2009-07-30

Similar Documents

Publication Publication Date Title
US9298924B2 (en) Fixing security vulnerability in a source code
US9128728B2 (en) Locating security vulnerabilities in source code
JP5458184B2 (en) System and method for aggressive automatic correction in a dynamic function call system
US7254586B2 (en) Secure and opaque type library providing secure data protection of variables
EP2575069B1 (en) Security vulnerability correction
US20170116410A1 (en) Software protection
CN110096853B (en) Unity android application reinforcement method based on Mono and storage medium
US9594769B2 (en) Computing device configured with a table network
Abi-Antoun et al. Checking threat modeling data flow diagrams for implementation conformance and security
US20140337639A1 (en) Steganographic embedding of executable code
CN108491235A (en) In conjunction with the DEX guard methods of dynamic load and function Nativeization
US11403372B2 (en) Systems, methods, and storage media for obfuscating a computer program by representing the control flow of the computer program as data
Amirtahmasebi et al. A survey of SQL injection defense mechanisms
JP5145967B2 (en) Command statement construction program, processing method, and processing device
WO2021019341A1 (en) Systems, methods, and storage media for producing verifiable protected code
CN111475168A (en) Code compiling method and device
De Ryck et al. Protected web components: Hiding sensitive information in the shadows
Tamrawi et al. Projected control graph for computing relevant program behaviors
He et al. Tamperproofing a software watermark by encoding constants
Kanani et al. Obfuscation: maze of code
Selvamani et al. A Novel Approach for Prevention of SQL Injection Attacks Using Cryptography and Access Control Policies
Dahse Static detection of complex vulnerabilities in modern PHP applications
Ramasamy et al. Enhancing the security of C/C++ programs using static analysis
Yoo et al. Automatic string deobfuscation scheme for mobile applications based on platform-level code extraction
Singleton Automated Tool Support for Finding and Repairing Security Bugs in Mobile Applications

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20100917

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20120314

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20120417

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20120613

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20120807

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20121009

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20121030

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20121112

R150 Certificate of patent or registration of utility model

Ref document number: 5145967

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20151207

Year of fee payment: 3

LAPS Cancellation because of no payment of annual fees