WO2025224904A1 - 処理装置、処理方法及び処理プログラム - Google Patents

処理装置、処理方法及び処理プログラム

Info

Publication number
WO2025224904A1
WO2025224904A1 PCT/JP2024/016172 JP2024016172W WO2025224904A1 WO 2025224904 A1 WO2025224904 A1 WO 2025224904A1 JP 2024016172 W JP2024016172 W JP 2024016172W WO 2025224904 A1 WO2025224904 A1 WO 2025224904A1
Authority
WO
WIPO (PCT)
Prior art keywords
code
advice
processing device
language model
prompt
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
PCT/JP2024/016172
Other languages
English (en)
French (fr)
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.)
NTT Inc
NTT Inc USA
Original Assignee
Nippon Telegraph and Telephone Corp
NTT Inc USA
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 Nippon Telegraph and Telephone Corp, NTT Inc USA filed Critical Nippon Telegraph and Telephone Corp
Priority to PCT/JP2024/016172 priority Critical patent/WO2025224904A1/ja
Publication of WO2025224904A1 publication Critical patent/WO2025224904A1/ja
Pending legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/57Certifying or maintaining trusted computer platforms, e.g. secure boots or power-downs, version controls, system software checks, secure updates or assessing vulnerabilities

Definitions

  • the present invention relates to a processing device, a processing method, and a processing program.
  • Non-Patent Document 1 Non-Patent Document 1
  • LLM code generated by LLM has high functionality (it is a program that operates according to the user's instructions), it is also known to contain a lot of vulnerabilities.
  • the present invention has been made in consideration of the above, and aims to provide a processing device, processing method, and processing program that can improve the security of code generated by an LLM.
  • the processing device of the present invention is characterized by having a generation instruction unit that causes a large-scale language model to generate code, an evaluation unit that evaluates the security vulnerabilities of the code generated by the large-scale language model, and a generation unit that adds advice for improving security to a prompt that instructs code generation based on the evaluation results by the evaluation unit.
  • the processing method of the present invention is a processing method executed by a processing device, and is characterized by including the steps of: causing a large-scale language model to generate code; evaluating the security vulnerabilities of the code generated by the large-scale language model; and adding advice for improving security to a prompt that instructs code generation based on the evaluation results of the evaluation step.
  • the processing program of the present invention also causes a computer to execute the following steps: causing a large-scale language model to generate code; evaluating the security vulnerabilities of the code generated by the large-scale language model; and adding advice for improving security to a prompt that instructs code generation based on the evaluation results of the evaluation step.
  • This invention makes it possible to improve the security of code generated by LLM.
  • FIG. 1 is a diagram for explaining the processing content proposed in the embodiment.
  • FIG. 2 is a block diagram illustrating an example of the configuration of a processing device according to an embodiment.
  • FIG. 3 is a diagram illustrating a process flow according to the embodiment.
  • FIG. 4 is a diagram showing an example of a method for processing information extracted from an external database (DB).
  • FIG. 5 is a flowchart showing the processing procedure of the processing method according to the embodiment.
  • FIG. 6 is a diagram showing the experimental conditions of the evaluation experiment.
  • FIG. 7 is a diagram showing the experimental results of the evaluation experiment.
  • FIG. 8 is a diagram showing the experimental results of the evaluation experiment.
  • FIG. 9 is a diagram showing the experimental results of the evaluation experiment.
  • FIG. 10 is a diagram showing the experimental results of the evaluation experiment.
  • FIG. 11 is a diagram illustrating an example of a computer that implements a processing device by executing a program.
  • FIG. 1 is a diagram illustrating the processing proposed in the embodiment.
  • appropriate secure coding advice (see box W1) is automatically provided in response to a code generation instruction input to the LLM.
  • a prompt including the instruction and advice shown in FIG. 1 is set in the LLM to instruct code generation. This allows the LLM to generate code taking this advice into consideration, thereby improving the security of the code generated by the LLM.
  • Fig. 2 is a block diagram showing an example of the configuration of a processing device according to an embodiment.
  • the processing device 10 communicates with the generation server 20 and the external DB 30.
  • the generation server 20 has an LLM 21.
  • the LLM 21 is a large-scale language model that generates and outputs data in accordance with prompts set by the processing device 10.
  • a prompt containing coding instructions is set in the LLM 21, and the LLM 21 generates and outputs code in accordance with the prompt.
  • the generation server 20 outputs the code generated by the LLM 21 to the processing device 10.
  • External DB30 is a database that stores vulnerability information. External DB30 holds, for example, information related to CWE (Common Weakness Enumerations). CWE is a standard specification for classifying and identifying security vulnerabilities in software, hardware, and other components of IT (Information Technology) systems, and is often adopted as a common standard for vulnerability classification. External DB30 stores, for example, CWE descriptions (vulnerability information) obtained from the NVD (National Vulnerability Database). The NVD is a database that collects information related to security vulnerabilities in software, IT products, and other products, and is managed and published by the National Institute of Standards and Technology (NIST).
  • NIST National Institute of Standards and Technology
  • the processing device 10 sets a prompt in the LLM 21 and instructs it to generate code. At this time, the processing device 10 has the function of automatically providing appropriate advice on secure coding in response to the code generation instruction input to the LLM 21.
  • the processing device 10 is realized by, for example, loading a predetermined program into a computer or the like including a ROM (Read Only Memory), a RAM (Random Access Memory), a CPU (Central Processing Unit), etc., and having the CPU execute the predetermined program.
  • the processing device 10 is also capable of communicating with other devices connected via a network or the like via a communication interface that transmits and receives various types of information to and from other devices.
  • the processing device 10 has a code generation instruction unit 11 (instruction unit), an evaluation unit 12, and a prompt generation unit 13 (generation unit).
  • the code generation instruction unit 11 sets a prompt instructing the LLM 21 to generate code, and causes the LLM 21 to generate code.
  • the evaluation unit 12 receives the code generated by the LLM 21 and evaluates the security vulnerabilities of the code generated by the LLM 21.
  • the evaluation unit 12 evaluates the security vulnerabilities of the code generated by the LLM 21 using a static analysis tool (for example, SAST (Static Application Security Testing)).
  • the prompt generation unit 13 adds advice for improving security to a prompt that instructs code generation based on the evaluation results by the evaluation unit 12.
  • the prompt generation unit 13 constructs advice based on information output by the static analysis tool.
  • the prompt generation unit 13 searches the external DB 30 based on the information output by the static analysis tool, and constructs advice based on the obtained vulnerability information.
  • the code generation instruction unit 11 uses the instructions given by the user of the processing device 10 as is to instruct the LLM 21 to generate code ((1) in Figure 3).
  • the evaluation unit 12 uses the SAST 12A to analyze the code generated by the LLM 21 ((2) in Figure 3). If the SAST 12A identifies a problem with the code ((3) in Figure 3), the prompt generation unit 13 searches the external DB 30 for advice on improving security in response to that problem.
  • the processing device 10 performs processing such as obtaining vulnerability information from the NVD, and prepares an external DB 30 that stores information related to each CWE ID.
  • the processing device 10 extracts from the external DB 30 countermeasures and points of caution corresponding to the CWE ID output from SAST 12A as information for constructing advice ((4) in Figure 3).
  • the prompt generation unit 13 appropriately processes the extracted information and attaches it to the code generation instructions given by the user as advice, creating a prompt.
  • the code generation instruction unit 11 sets this prompt in the LLM 21 and instructs the LLM 21 to generate code again ((5) in Figure 3), causing the LLM 21 to generate highly secure code ((6) in Figure 3).
  • the processing device 10 first has the LLM 21 generate code based on the instructions, and then has the SAST 12A evaluate it. The processing device 10 then generates coding practices from the CWE detected by the SAST 12A, adds these to the code generation instructions as advice, and generates the code again.
  • Figure 4 shows an example of a method for processing information extracted from the external DB 30.
  • the prompt generation unit 13 processes the vulnerability description corresponding to the CWE ID into secure coding advice (box W22) by having the LLM process it.
  • the prompt generation unit 13 inputs the SAST results (box W21 in Figure 4 (1)) into the LLM along with a prompt that instructs advice conversion.
  • the prompt generation unit 13 then generates a prompt that instructs code generation, as exemplified in Figure 1, by assigning the output from the LLM (box W22) as advice (box W22 in Figure 4 (2)).
  • the prompt generation unit 13 converts the description of the vulnerability corresponding to the CWE ID into coding advice (box W22) and adds the converted advice to the prompt.
  • the code generation instruction unit 11 sets a prompt instructing the LLM 21 to generate code and instructs the LLM 21 to generate code (step S11).
  • the evaluation unit 12 receives the code generated by the LLM 21 (step S12) and evaluates the security vulnerabilities of this code (step S13).
  • the prompt generation unit 13 searches for and obtains an explanation of the vulnerability from the external DB 30 in order to improve security in response to the vulnerability (step S15).
  • the prompt generation unit 13 constructs advice based on the information obtained from the external DB 30 and assigns it to a prompt that instructs the generation of code (step S16).
  • the code generation instruction unit 11 sets the prompt with the advice in the LLM 21, causing the LLM 21 to generate code (step S17).
  • the processing device 10 receives the code generated by the LLM 21 (step S18). If the evaluation unit 12 does not point out any security vulnerabilities in the code (step S14: No), the code generated by the LLM 21 is deemed safe and is provided to the user.
  • Figure 6 shows the experimental conditions for the evaluation experiment. As shown in Figure 6, for the evaluation experiment, 316 vulnerable functions from Python programs were prepared, and natural language instruction prompts for generating these functions were provided. In addition, for each function, functions after the vulnerabilities were fixed and the results of SAST using semgrep were also prepared.
  • GPT3.5 and GPT4 were used to generate code under two conditions: the first and second. Under the first condition, the instruction prompt was set as is, and GPT3.5 and GPT4 were used to generate code. Under the second condition, the processing method according to this embodiment was applied, and advice for improving security was added to the prompt, after which code was generated using GPT3.5 and GPT4.
  • SAST is performed on the generated code, and if no vulnerabilities are detected, it is deemed to have passed.
  • the functionality of the generated code is measured (reference value) by its similarity to the correct function.
  • the rate at which the generated code passes SAST (the rate at which no vulnerabilities are identified) is measured under each of the first and second conditions.
  • the vulnerabilities detected by SAST are CWE IDs
  • the external DB 30 stores CWE descriptions for each CWE ID obtained from the NVD.
  • the advice for improving security that is added to the prompt is converted into advice using GPT3.5 based on the CWE description (i.e., the method shown in Figure 4).
  • Figures 7 to 10 show the results of the evaluation experiments.
  • Figure 7 shows the evaluation results when GPT3.5 was used to generate code under the first condition.
  • Figure 8 shows the evaluation results when GPT3.5 was used to generate code under the second condition.
  • Figure 9 shows the evaluation results when GPT4 was used to generate code under the first condition.
  • Figure 10 shows the evaluation results when GPT4 was used to generate code under the second condition.
  • the rate at which the SAST tool passed was 55% under the first condition, improving to 78% under the second condition. Also, as shown in Figures 9 and 10, for GPT4, the rate at which the SAST tool passed was 55% under the first condition, improving to 85% under the second condition.
  • the processing device 10 automatically provides appropriate advice on secure coding to the prompt. Therefore, the user can have the LLM 21 perform coding that takes security into consideration simply by inputting coding instructions to the LLM 21 as before.
  • the processing device 10 uses a static analysis tool to evaluate security vulnerabilities in the code generated by the large-scale language model, but this is not limited to this.
  • the evaluation unit 12 may use a dynamic analysis tool to evaluate security vulnerabilities in the code generated by the LLM 21, and the prompt generation unit 13 may construct advice based on information output by the dynamic analysis tool.
  • the processing device 10 is a functional concept and does not necessarily have to be physically configured as shown in the figure.
  • the specific form of distribution and integration of the functions of the processing device 10 is not limited to that shown in the figure, and all or part of it can be functionally or physically distributed or integrated in any unit depending on various loads, usage conditions, etc.
  • each process performed by the processing device 10 may be realized, in whole or in part, by a CPU (Central Processing Unit), a GPU (Graphics Processing Unit), and a program analyzed and executed by the CPU and GPU (Graphics Processing Unit). Furthermore, each process performed by the processing device 10 may be realized as hardware using wired logic.
  • a CPU Central Processing Unit
  • GPU Graphics Processing Unit
  • a program analyzed and executed by the CPU and GPU Graphics Processing Unit
  • each process performed by the processing device 10 may be realized as hardware using wired logic.
  • [program] 11 is a diagram showing an example of a computer in which a program is executed to realize the processing device 10.
  • the computer 1000 has, for example, a memory 1010 and a CPU 1020.
  • the computer 1000 also has a hard disk drive interface 1030, a disk drive interface 1040, a serial port interface 1050, a video adapter 1060, and a network interface 1070. These components are connected by a bus 1080.
  • Memory 1010 includes ROM 1011 and RAM 1012.
  • ROM 1011 stores a boot program such as BIOS (Basic Input Output System).
  • Hard disk drive interface 1030 is connected to hard disk drive 1090.
  • Disk drive interface 1040 is connected to disk drive 1100.
  • a removable storage medium such as a magnetic disk or optical disk is inserted into disk drive 1100.
  • Serial port interface 1050 is connected to, for example, a mouse 1110 and a keyboard 1120.
  • Video adapter 1060 is connected to, for example, a display 1130.
  • the hard disk drive 1090 stores, for example, an OS (Operating System) 1091, application programs 1092, program modules 1093, and program data 1094.
  • OS Operating System
  • the programs that define each process of the processing device 10 are implemented as program modules 1093 that contain code that can be executed by the computer 1000.
  • the program modules 1093 are stored, for example, on the hard disk drive 1090.
  • a program module 1093 for executing processes similar to the functional configuration of the processing device 10 is stored on the hard disk drive 1090.
  • the hard disk drive 1090 may be replaced by an SSD (Solid State Drive).
  • the setting data used in the processing of the above-described embodiment is stored as program data 1094, for example, in memory 1010 or hard disk drive 1090.
  • the CPU 1020 reads the program module 1093 or program data 1094 stored in memory 1010 or hard disk drive 1090 into RAM 1012 as needed and executes them.
  • the program module 1093 and program data 1094 do not necessarily have to be stored on the hard disk drive 1090; they may instead be stored on a removable storage medium and read by the CPU 1020 via the disk drive 1100 or the like.
  • the program module 1093 and program data 1094 may be stored in another computer connected via a network (such as a LAN (Local Area Network) or WAN (Wide Area Network)).
  • the program module 1093 and program data 1094 may then be read by the CPU 1020 from the other computer via the network interface 1070.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

処理装置(10)は、LLM(Large Language Models)に、コードを生成させるコード生成指示部(11)と、LLMが生成したコードのセキュリティ上の脆弱性を評価する評価部(12)と、評価部(12)による評価結果を基に、セキュリティ向上のためのアドバイスを、コードの生成を指示するプロンプトに付与するプロンプト生成部(13)と、を有する。

Description

処理装置、処理方法及び処理プログラム
 本発明は、処理装置、処理方法及び処理プログラムに関する。
 近年、大規模言語モデル(Large Language Models:LLM)の進歩が目覚ましく、様々な分野で利用されている。特に、LLMを利用したコード生成は、github Copilot(非特許文献1)の普及等からもわかるように強力なユースケースの1つとなっており、エンジニアの生産性を大きく向上させている。
GitHub Copilot, [令和6年4月1日検索],インターネット<URL:https://github.com/features/copilot> Hammond Pearce, Baleegh Ahmad, Benjamin Tan, Brendan Dolan-Gavitt, Ramesh Karri, "Asleep at the Keyboard? Assessing the Security of GitHub Copilot’s Code Contributions," IEEE Symposium on Security and Privacy 2022.
 しかしながら、LLMによって生成されたコードは、高い機能性(ユーザの指示通りに動作するプログラムであること)を持つが、脆弱なコードも多いことが知られている。
 本発明は、上記に鑑みてなされたものであって、LLMの生成するコードの安全性を向上させることができる処理装置、処理方法及び処理プログラムを提供することを目的とする。
 上述した課題を解決し、目的を達成するために、本発明の処理装置は、大規模言語モデルに、コードを生成させる生成指示部と、前記大規模言語モデルが生成したコードのセキュリティ上の脆弱性を評価する評価部と、前記評価部による評価結果を基に、セキュリティ向上のためのアドバイスを、コードの生成を指示するプロンプトに付与する生成部と、を有することを特徴とする。
 また、本発明の処理方法は、処理装置が実行する処理方法であって、大規模言語モデルに、コードを生成させる工程と、前記大規模言語モデルが生成したコードのセキュリティ上の脆弱性を評価する工程と、前記評価する工程における評価結果を基に、セキュリティ向上のためのアドバイスを、コードの生成を指示するプロンプトに付与する工程と、を含んだことを特徴とする。
 また、本発明の処理プログラムは、大規模言語モデルに、コードを生成させるステップと、前記大規模言語モデルが生成したコードのセキュリティ上の脆弱性を評価するステップと、前記評価するステップにおける評価結果を基に、セキュリティ向上のためのアドバイスを、コードの生成を指示するプロンプトに付与するステップと、をコンピュータに実行させる。
 本発明によれば、LLMの生成するコードの安全性を向上させることができる。
図1は、実施の形態において提案する処理内容を説明する図である。 図2は、実施の形態に係る処理装置の構成の一例を示すブロック図である。 図3は、実施の形態に係る処理の流れを説明する図である。 図4は、外部データベース(DB)から抽出した情報の加工方法の一例を示す図である。 図5は、実施の形態に係る処理方法の処理手順を示すフローチャートである。 図6は、評価実験の実験条件を示す図である。 図7は、評価実験の実験結果を示す図である。 図8は、評価実験の実験結果を示す図である。 図9は、評価実験の実験結果を示す図である。 図10は、評価実験の実験結果を示す図である。 図11は、プログラムが実行されることにより、処理装置が実現されるコンピュータの一例を示す図である。
 以下、図面を参照して、本発明の一実施形態を詳細に説明する。なお、この実施形態により本発明が限定されるものではない。また、図面の記載において、同一部分には同一の符号を付して示している。
[実施の形態]
 図1は、実施の形態において提案する処理内容を説明する図である。図1に示すように、実施の形態では、LLMに入力するコード生成の指示に対して、セキュアコーディング上の適切なアドバイス(枠W1参照)を自動的に付与する。実施の形態では、図1に示す指示及びアドバイスを含むフロンプトをLLMに設定し、コード生成を指示する。これによって、実施の形態では、LLMが、このアドバイスを考慮してコードを生成することができ、LLMが生成するコードの安全性の向上を図ることができる。
[処理装置]
 まず、実施の形態に係る処理装置について説明する。図2は、実施の形態に係る処理装置の構成の一例を示すブロック図である。
 図2に示すように、実施の形態に係る処理装置10は、生成サーバ20と、外部DB30と通信を行う。
 生成サーバ20は、LLM21を有する。LLM21は、大規模言語モデルであり、処理装置10によって設定されたプロンプトにしたがって、データを生成して、出力する。本実施の形態では、LLM21には、コーディングの指示を含むプロンプトが設定され、そのプロンプトにしたがって、コードを生成し、出力する。生成サーバ20は、LLM21が生成したコードを、処理装置10に出力する。
 外部DB30は、脆弱性情報を格納したDBである。外部DB30は、例えば、CWE(Common Weakness Enumerations)に関連する情報を保持する。CWEは、IT(Information Technology)システムを構成するソフトウェアやハードウェアなどのセキュリティ上の脆弱性を分類、識別する標準仕様の一つであり、脆弱性分類の共通基準として採用させることが多い。外部DB30は、例えば、NVD(National Vulnerability Database)から取得したCWEの説明(脆弱性情報)を格納する。NVDは、米国立標準技術研究所(NIST(National Institute of Standards and Technology))が管理・公開している、ソフトウェアやIT製品などのセキュリティ上の脆弱性に関する情報を収集したDBである。
 処理装置10は、フロンプトをLLM21に設定し、コード生成を指示する。この際、処理装置10は、LLM21に入力するコード生成の指示に対して、セキュアコーディング上の適切なアドバイスを自動的に付与する機能を有する。
[処理装置]
 次に、処理装置10について説明する。処理装置10は、例えば、ROM(Read Only Memory)、RAM(Random Access Memory)、CPU(Central Processing Unit)等を含むコンピュータ等に所定のプログラムが読み込まれて、CPUが所定のプログラムを実行することで実現される。また、処理装置10は、ネットワーク等を介して接続された他の装置との間で、各種情報を送受信する通信インタフェースを介して、他の装置との通信が可能である。
 処理装置10は、コード生成指示部11(指示部)、評価部12及びプロンプト生成部13(生成部)を有する。
 コード生成指示部11は、コードの生成を指示するプロンプトを、LLM21に設定し、LLM21にコードを生成させる。
 評価部12は、LLM21が生成したコードを受信し、LLM21が生成したコードのセキュリティ上の脆弱性を評価する。評価部12は、静的解析ツール(例えば、SAST(Static Application Security Testing))を用いて、LLM21が生成したコードのセキュリティ上の脆弱性を評価する。
 プロンプト生成部13は、評価部12による評価結果を基に、セキュリティ向上のためのアドバイスを、コードの生成を指示するプロンプトに付与する。プロンプト生成部13は、静的解析ツールが出力する情報を基に、アドバイスを構築する。プロンプト生成部13は、静的解析ツールが出力する情報に基づいて、外部DB30を検索し、得られた脆弱性情報を基にアドバイスを構築する。
[処理の流れ]
 次に、実施の形態に係る処理の流れについて説明する。図3は、実施の形態に係る処理の流れを説明する図である。
 図3に示すように、例えば、コード生成指示部11は、処理装置10のユーザから与えられた指示をそのまま用いて、LLM21にコード生成を指示する(図3の(1))。
 評価部12は、LLM21が生成したコード(図3の(2))を、SAST12Aを用いて分析する。そして、SAST12Aから、コードの問題点が指摘された場合(図3の(3))、プロンプト生成部13は、その問題点に応じたセキュリティ向上のためのアドバイスを外部DB30から検索して取得する。
 例えば、SAST12Aが問題点として、CWEのIDを出力する場合について説明する。この場合、処理装置10は、NVDから脆弱性情報を取得する等の処理を行うことで、CWEのIDごとに、CWEに関連する情報を保持する外部DB30を用意する。処理装置10は、外部DB30から、SAST12Aから出力されたCWEのIDに応じた対処方法や注意点を、アドバイス構築用の情報として抽出する(図3の(4))。
 プロンプト生成部13は、抽出した情報を適切に加工し、アドバイスとして、ユーザから与えられコード生成の指示に付与し、プロンプトとする。コード生成指示部11は、このプロンプトをLLM21に設定し、LLM21にコードの生成を再度指示することで(図3の(5))、LLM21に、セキュリティ性の高いコードを生成させる(図3の(6))。
 このように、処理装置10は、指示に基づき一度LLM21にコードを生成させた後、SAST12Aにて評価する。そして、処理装置10は、SAST12Aに検知されたCWEからコーディングプラクティスを生成して、コード生成指示にアドバイスとして付与して、再度コードを生成させる。
 図4は、外部DB30から抽出した情報の加工方法の一例を示す図である。図4に示すように、例えば、プロンプト生成部13は、CWEのIDに対応する脆弱性の説明文をLLMに処理させることで、セキュアコーディング上のアドバイス(枠W22)として加工する。
 具体的には、プロンプト生成部13は、SASTの結果(図4の(1)、枠W21)を、アドバイス変換を指示するプロンプトとともに、LLMに入力する。そして、プロンプト生成部13は、LLMからの出力(枠W22)をアドバイスとして付与することで(図4の(2))、図1に例示するコード生成を指示するプロンプトを生成する。このように、プロンプト生成部13は、CWEのIDに対応する脆弱性の説明文を踏まえて、コーディングの際のアドバイス(枠W22)に変換し、変換したアドバイスをプロンプトに追加する。
[処理手順]
 次に、実施の形態に係る処理方法の処理手順について説明する。図5は、実施の形態に係る処理方法の処理手順を示すフローチャートである。
 処理装置10では、コード生成指示部11が、コードの生成を指示するプロンプトを、LLM21に設定し、LLM21にコード生成を指示する(ステップS11)。
 続いて、評価部12は、LLM21が生成したコードを受信し(ステップS12)、このコードのセキュリティ上の脆弱性を評価する(ステップS13)。
 評価部12によって、コードのセキュリティ上の脆弱性に対する問題点の指摘があった場合(ステップS14:Yes)、プロンプト生成部13は、その問題点に応じたセキュリティ向上のために、脆弱性に関する説明を、外部DB30から検索して取得する(ステップS15)。
 プロンプト生成部13は、外部DB30から得られた情報を基に、アドバイスを構築し、コードの生成を指示するプロンプトに付与する(ステップS16)。
 そして、コード生成指示部11は、アドバイスが付与されたプロンプトを、LLM21に設定し、LLM21にコードを生成させる(ステップS17)。これによって、処理装置10は、LLM21が生成したコードを受信する(ステップS18)。評価部12によって、コードのセキュリティ脆弱性に対する問題点の指摘がなかった場合(ステップS14:No)、LLM21によって生成されたコードは安全であるとして、ユーザに提供する。
[評価実験]
 本実施の形態の処理方法について評価実験を行った。
 図6は、評価実験の実験条件を示す図である。図6に示すように、評価実験では、316件のpythonプログラムの脆弱な関数を用意し、その関数を生成するための自然言語での指示プロンプトを用意する。また、それぞれの関数と対応する形で、脆弱性の修正後の関数、及び、semgrepを用いたSASTの結果も用意する。
 上記のデータセット(316件のpython)を用いて、第1の条件、第2の条件に分けて、GPT3.5及びGPT4にコードを生成させる。第1の条件では、指示プロンプトをそのまま設定して、GPT3.5及びGPT4にコードを生成させる。第2の条件では、本実施の形態に係る処理方法を適用して、プロンプトにセキュリティ向上のためのアドバイスを付与した後にGPT3.5およびGPT4を用いてコードを生成させる。
 そして、生成後のコードにSASTを行い、脆弱性が検知されなければPassとする。なお、生成されたコードの機能性については正解関数との類似度で測定(参考値)する。このように、第1の条件、第2の条件のそれぞれにおいて、生成されたコードがSASTをPassする割合(脆弱性が指摘されない割合)を計測する。なお、本実施の形態において、SASTで検知する脆弱性は、CWEのIDとし、外部DB30にはNVDより取得したCWEのIDごとのCWEの説明を格納しているものとする。また、プロンプトに付与するセキュリティ向上のためのアドバイスは、CWEの説明を基に、GPT3.5でアドバイスに変換した(つまり、図4に示した方法)ものを用いるものとする。
 図7~図10は、評価実験の実験結果を示す図である。図7は、第1の条件で、GPT3.5にコードを生成させた場合の評価結果である。図8は、第2の条件で、GPT3.5にコードを生成させた場合の評価結果である。図9は、第1の条件で、GPT4にコードを生成させた場合の評価結果である。図10は、第2の条件で、GPT4にコードを生成させた場合の評価結果である。
 図7及び図8に示すように、GPT3.5の場合、SASTツールをPassする割合が、第1の条件では55%であるところ、第2の条件では78%に改善している。また、図9及び図10に示すように、GPT4の場合、SASTツールをPassする割合が、第1の条件では55%であるところ、第2の条件では85%に改善している。
 このように、GPT3.5、GPT4を用いたどちらの場合においても、第2の条件(本実施の形態に係る処理方法)を適用した方が、SASTツールをPassする割合が大きく向上していることがわかる。また、GPT3.5、GPT4のうち、精度が高いGPT4ほどセキュアであるという結果が得られた。
[実施の形態の効果]
 実施の形態では、LLM21に入力するコード生成の指示に対して、評価結果を基に、セキュアコーディング上の適切なアドバイスを自動的に付与するフローを構築した。評価実験の結果からも分かるように、この実施の形態によって、LLM21が生成するコードの安全性を向上させることができる。
 そして、実施の形態では、処理装置10が、セキュアコーディング上の適切なアドバイスをプロンプトに自動付与する。このため、ユーザは、これまで通りのコーディングの指示をLLM21に入力するだけで、セキュリティを考慮したコーディングをLLM21に実行させることができる。
 なお、実施の形態では、処理装置10が、静的解析ツールを用いて、前記大規模言語モデルが生成したコードのセキュリティ脆弱性を評価した場合を例に説明したが、これに限らない。処理装置10では、評価部12が、動的解析ツールを用いて、LLM21が生成したコードのセキュリティ脆弱性を評価し、プロンプト生成部13が、動的解析ツールが出力する情報を基に、アドバイスを構築してもよい。
[実施の形態のシステム構成について]
 処理装置10は機能概念的なものであり、必ずしも物理的に図示のように構成されていることを要しない。すなわち、処理装置10の機能の分散及び統合の具体的形態は図示のものに限られず、その全部または一部を、各種の負荷や使用状況などに応じて、任意の単位で機能的または物理的に分散または統合して構成することができる。
 また、処理装置10においておこなわれる各処理は、全部または任意の一部が、CPU(Central Processing Unit)、GPU(Graphics Processing Unit)、及び、CPU、GPU(Graphics Processing Unit)により解析実行されるプログラムにて実現されてもよい。また、処理装置10において行われる各処理は、ワイヤードロジックによるハードウェアとして実現されてもよい。
 また、実施の形態において説明した各処理のうち、自動的におこなわれるものとして説明した処理の全部または一部を手動的に行うこともできる。もしくは、手動的におこなわれるものとして説明した処理の全部または一部を公知の方法で自動的に行うこともできる。この他、上述及び図示の処理手順、制御手順、具体的名称、各種のデータやパラメータを含む情報については、特記する場合を除いて適宜変更することができる。
[プログラム]
 図11は、プログラムが実行されることにより、処理装置10が実現されるコンピュータの一例を示す図である。コンピュータ1000は、例えば、メモリ1010、CPU1020を有する。また、コンピュータ1000は、ハードディスクドライブインタフェース1030、ディスクドライブインタフェース1040、シリアルポートインタフェース1050、ビデオアダプタ1060、ネットワークインタフェース1070を有する。これらの各部は、バス1080によって接続される。
 メモリ1010は、ROM1011及びRAM1012を含む。ROM1011は、例えば、BIOS(Basic Input Output System)等のブートプログラムを記憶する。ハードディスクドライブインタフェース1030は、ハードディスクドライブ1090に接続される。ディスクドライブインタフェース1040は、ディスクドライブ1100に接続される。例えば磁気ディスクや光ディスク等の着脱可能な記憶媒体が、ディスクドライブ1100に挿入される。シリアルポートインタフェース1050は、例えばマウス1110、キーボード1120に接続される。ビデオアダプタ1060は、例えばディスプレイ1130に接続される。
 ハードディスクドライブ1090は、例えば、OS(Operating System)1091、アプリケーションプログラム1092、プログラムモジュール1093、プログラムデータ1094を記憶する。すなわち、処理装置10の各処理を規定するプログラムは、コンピュータ1000により実行可能なコードが記述されたプログラムモジュール1093として実装される。プログラムモジュール1093は、例えばハードディスクドライブ1090に記憶される。例えば、処理装置10における機能構成と同様の処理を実行するためのプログラムモジュール1093が、ハードディスクドライブ1090に記憶される。なお、ハードディスクドライブ1090は、SSD(Solid State Drive)により代替されてもよい。
 また、上述した実施の形態の処理で用いられる設定データは、プログラムデータ1094として、例えばメモリ1010やハードディスクドライブ1090に記憶される。そして、CPU1020が、メモリ1010やハードディスクドライブ1090に記憶されたプログラムモジュール1093やプログラムデータ1094を必要に応じてRAM1012に読み出して実行する。
 なお、プログラムモジュール1093やプログラムデータ1094は、ハードディスクドライブ1090に記憶される場合に限らず、例えば着脱可能な記憶媒体に記憶され、ディスクドライブ1100等を介してCPU1020によって読み出されてもよい。あるいは、プログラムモジュール1093及びプログラムデータ1094は、ネットワーク(LAN(Local Area Network)、WAN(Wide Area Network)等)を介して接続された他のコンピュータに記憶されてもよい。そして、プログラムモジュール1093及びプログラムデータ1094は、他のコンピュータから、ネットワークインタフェース1070を介してCPU1020によって読み出されてもよい。
 以上、本発明者によってなされた発明を適用した実施の形態について説明したが、本実施の形態による本発明の開示の一部をなす記述及び図面により本発明は限定されることはない。すなわち、本実施の形態に基づいて当業者等によりなされる他の実施の形態、実施例及び運用技術等は全て本発明の範疇に含まれる。
 10 処理装置
 11 コード生成指示部
 12 評価部
 12A SAST
 13 プロンプト生成部
 20 生成サーバ
 21 LLM
 30 外部DB
 1000 コンピュータ 

Claims (6)

  1.  大規模言語モデルに、コードを生成させる生成指示部と、
     前記大規模言語モデルが生成したコードのセキュリティ上の脆弱性を評価する評価部と、
     前記評価部による評価結果を基に、セキュリティ向上のためのアドバイスを、コードの生成を指示するプロンプトに付与する付与部と、
     を有することを特徴とする処理装置。
  2.  前記評価部は、静的解析ツールを用いて、前記大規模言語モデルが生成したコードのセキュリティ脆弱性を評価し、
     前記付与部は、前記静的解析ツールが出力する情報を基に、前記アドバイスを構築することを特徴とする請求項1に記載の処理装置。
  3.  前記付与部は、前記静的解析ツールが出力する情報に基づいて、脆弱性情報を格納したデータベースを検索し、得られた脆弱性情報を基に前記アドバイスを構築することを特徴とする請求項2に記載の処理装置。
  4.  前記評価部は、動的解析ツールを用いて、前記大規模言語モデルが生成したコードのセキュリティ脆弱性を評価し、
     前記付与部は、前記動的解析ツールが出力する情報を基に、前記アドバイスを構築することを特徴とする請求項1に記載の処理装置。
  5.  処理装置が実行する処理方法であって、
     大規模言語モデルに、コードを生成させる工程と、
     前記大規模言語モデルが生成したコードのセキュリティ上の脆弱性を評価する工程と、
     前記評価する工程における評価結果を基に、セキュリティ向上のためのアドバイスを、コードの生成を指示するプロンプトに付与する工程と、
     を含んだことを特徴とする処理方法。
  6.  大規模言語モデルに、コードを生成させるステップと、
     前記大規模言語モデルが生成したコードのセキュリティ上の脆弱性を評価するステップと、
     前記評価するステップにおける評価結果を基に、セキュリティ向上のためのアドバイスを、コードの生成を指示するプロンプトに付与するステップと、
     をコンピュータに実行させるための処理プログラム。
PCT/JP2024/016172 2024-04-24 2024-04-24 処理装置、処理方法及び処理プログラム Pending WO2025224904A1 (ja)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/JP2024/016172 WO2025224904A1 (ja) 2024-04-24 2024-04-24 処理装置、処理方法及び処理プログラム

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2024/016172 WO2025224904A1 (ja) 2024-04-24 2024-04-24 処理装置、処理方法及び処理プログラム

Publications (1)

Publication Number Publication Date
WO2025224904A1 true WO2025224904A1 (ja) 2025-10-30

Family

ID=97489718

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2024/016172 Pending WO2025224904A1 (ja) 2024-04-24 2024-04-24 処理装置、処理方法及び処理プログラム

Country Status (1)

Country Link
WO (1) WO2025224904A1 (ja)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116991467A (zh) * 2023-08-01 2023-11-03 苏州蜚语信息科技有限公司 一种基于大型语言模型的代码修复系统及修复方法

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116991467A (zh) * 2023-08-01 2023-11-03 苏州蜚语信息科技有限公司 一种基于大型语言模型的代码修复系统及修复方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
ANONYMOUS: "Fixing security vulnerabilities with AI", GITHUB.BLOG, 14 February 2024 (2024-02-14), XP093365888, Retrieved from the Internet <URL:https://github.blog/2024-02-14-fixing-security-vulnerabilities-with-ai/> *

Similar Documents

Publication Publication Date Title
JP6926429B2 (ja) データ処理装置、データ処理方法、およびプログラム
US8387017B2 (en) Black box testing optimization using information from white box testing
US20200089873A1 (en) DYNAMIC CODE EXTRACTION-based AUTOMATIC ANTI-ANALYSIS EVASION AND CODE LOGIC ANALYSIS APPARATUS
US8099781B2 (en) Method of managing and mitigating security risks through planning
CN110728328B (zh) 分类模型的训练方法和装置
US10261767B2 (en) Data integration job conversion
EP3908925A1 (en) Microapp functionality recommendations with cross-application activity correlation
JPWO2019189249A1 (ja) 学習装置、学習方法、及びプログラム
US20170337056A1 (en) Method and computer program stored in computer-readable medium for converting sort script to reuse jcl in different encoding environment
CN115455430B (zh) 一种基于Kyverno安全策略的安全防护方法及系统
EP3901808A1 (en) Analysis query response system, analysis query execution device, analysis query verification device, analysis query response method, and program
KR102386330B1 (ko) 표준 프로세스를 기반으로 한 사용자 프로세스 분석 장치 및 방법
CN114819553A (zh) 基于工作流引擎的动态配置方法、装置、设备及存储介质
Zhou et al. Srdc: Semantics-based ransomware detection and classification with llm-assisted pre-training
CN116529034B (zh) 生成数字孪生、方法、系统、计算机程序产品
US20120151600A1 (en) Method and system for protecting intellectual property in software
US20140279828A1 (en) Control data driven modifications and generation of new schema during runtime operations
JP7351399B2 (ja) ログ生成装置、ログ生成方法、及びプログラム
KR20200110881A (ko) 비음수 행렬 인수분해를 이용하는 데이터 증강 방법 및 장치
US8229903B2 (en) Suggesting data interpretations and patterns for updating policy documents
Wrench et al. Detecting derivative malware samples using deobfuscation-assisted similarity analysis
JP6674048B2 (ja) 判定装置、判定方法及び判定プログラム
WO2021171524A1 (ja) シグネチャ生成装置、シグネチャ生成方法およびシグネチャ生成プログラム
CN114611114A (zh) 代码审计方法、装置、设备及存储介质
WO2025248740A1 (ja) 処理装置、処理方法及び処理プログラム

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 24937019

Country of ref document: EP

Kind code of ref document: A1