KR20240030078A - Blockchain smart contract vulnerability location detection method and device - Google Patents

Blockchain smart contract vulnerability location detection method and device Download PDF

Info

Publication number
KR20240030078A
KR20240030078A KR1020220108645A KR20220108645A KR20240030078A KR 20240030078 A KR20240030078 A KR 20240030078A KR 1020220108645 A KR1020220108645 A KR 1020220108645A KR 20220108645 A KR20220108645 A KR 20220108645A KR 20240030078 A KR20240030078 A KR 20240030078A
Authority
KR
South Korea
Prior art keywords
smart contract
vulnerability
deep learning
learning model
byte code
Prior art date
Application number
KR1020220108645A
Other languages
Korean (ko)
Inventor
최윤호
황선진
Original Assignee
주식회사 폭씨
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 주식회사 폭씨 filed Critical 주식회사 폭씨
Priority to KR1020220108645A priority Critical patent/KR20240030078A/en
Publication of KR20240030078A publication Critical patent/KR20240030078A/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/55Detecting local intrusion or implementing counter-measures
    • G06F21/56Computer malware detection or handling, e.g. anti-virus arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • G06F21/577Assessing vulnerabilities and evaluating computer system security
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Virology (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Medical Informatics (AREA)
  • Mathematical Physics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Image Analysis (AREA)

Abstract

블록체인 스마트 컨트랙트 취약점 위치 탐지 방법 및 장치가 개시된다. 본 발명의 일실시예에 따른, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법은, 스마트 컨트랙트를, 바이트 코드(Bytecode)로 변환하여 데이터 전처리(Data Preprocessing)하는 단계; 상기 바이트 코드를 딥러닝 모델에 입력하여 취약점 탐지(Vulnerability Detection)하는 단계; 및 상기 딥러닝 모델로부터의 출력으로서 '취약점 발생'이 탐지되면, 상기 스마트 컨트랙트 내 취약점 위치를 특정하기 위한 코드 매핑(Code Mapping)하는 단계를 포함 할 수 있다.A method and device for detecting the location of blockchain smart contract vulnerabilities are disclosed. According to an embodiment of the present invention, a method for detecting the location of a vulnerability in a blockchain smart contract includes converting a smart contract into bytecode and performing data preprocessing; Vulnerability detection by inputting the byte code into a deep learning model; And when 'vulnerability occurrence' is detected as an output from the deep learning model, it may include a code mapping step to specify the location of the vulnerability within the smart contract.

Description

블록체인 스마트 컨트랙트 취약점 위치 탐지 방법 및 장치{BLOCKCHAIN SMART CONTRACT VULNERABILITY LOCATION DETECTION METHOD AND DEVICE}Blockchain smart contract vulnerability location detection method and device {BLOCKCHAIN SMART CONTRACT VULNERABILITY LOCATION DETECTION METHOD AND DEVICE}

본 발명은 추가적인 데이터나 학습 없이 딥러닝의 결과에 대한 설명을 제공해주기 위해, 대표적인 XAI 기법 중 Grad-CAM을 사용하고, XAI 기반의 스마트 컨트랙트 취약점 위치 탐지율을 높이기 위해 전처리 기법을 통한 이미지 변환과 딥러닝 모델 구조를 제공하는, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법 및 장치에 관한 것입니다.The present invention uses Grad-CAM among representative XAI techniques to provide an explanation of the results of deep learning without additional data or learning, and uses image conversion and deep learning through preprocessing techniques to increase the detection rate of XAI-based smart contract vulnerability locations. This is about a blockchain smart contract vulnerability location detection method and device that provides a learning model structure.

또한, 본 발명은 데이터 전처리(Data Preprocessing), 취약점 탐지(Vulnerability Detection), 코드 매핑(Code Mapping)을 수행하여, 스마트 컨트랙트의 취약점 위치를 정확하게 파악할 수 있게 하는, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법 및 장치를 제공한다.In addition, the present invention provides a blockchain smart contract vulnerability location detection method that performs data preprocessing, vulnerability detection, and code mapping to accurately identify the location of vulnerabilities in the smart contract, and Provides a device.

이더리움의 스마트 컨트랙트는, 프로그래밍 언어로서, 블록체인의 활용 분야를 유통, 보험, 의학, 에너지, 게임 등 다양한 산업분야로 확대하였다.Ethereum's smart contract, as a programming language, has expanded the use of blockchain to various industrial fields such as distribution, insurance, medicine, energy, and games.

하지만, 스마트 컨트랙트는, 종래의 프로그래밍 언어에서 발생하지 않았던 다양한 취약점들이 발생하고 있다.However, smart contracts have various vulnerabilities that do not occur in conventional programming languages.

대표적인 취약점인 reentrancy 취약점은, 스마트 컨트랙트의 취약점을 활용하여, 스마트 컨트랙트 사용자들에게 1000억원 이상의 손실을 초래하였다.The reentrancy vulnerability, a representative vulnerability, took advantage of a vulnerability in smart contracts and caused a loss of more than 100 billion won to smart contract users.

Reentracy는, 동시에 여러 거래를 스마트 컨트랙트에 실행시켜 헷갈리게 한 다음, 일정 거래가 순차적으로 실행되기 전에 다른 거래로 자금을 빼내는 해킹 수법 일 수 있다.Reentracy can be a hacking method that confuses smart contracts by executing multiple transactions at the same time, and then extracts funds through other transactions before certain transactions are sequentially executed.

Reentrancy와 같은 스마트 컨트랙트 취약점은, 암호화폐와 같은 자산의 유출과 직접적으로 연결되어 있으므로, 개발자는 이러한 취약점을 사전에 탐지하고 취약점을 수정 할 수 있어야 한다.Smart contract vulnerabilities such as reentrancy are directly linked to the leakage of assets such as cryptocurrency, so developers must be able to detect and correct these vulnerabilities in advance.

취약점을 탐지하기 위해 다양한 취약점 분석 도구들이 제안되었으나, 취약점 탐지 규칙 및 패턴을 사전에 직접 지정해주어야 하는 정적 분석(Static Analysis), 및 동적 분석(Dynamic Analysis) 도구들은, 사전에 정의한 패턴을 조금만 벗어나도 취약점 탐지가 되지 않는다는 문제가 존재하였다.Various vulnerability analysis tools have been proposed to detect vulnerabilities, but static analysis and dynamic analysis tools, which require vulnerability detection rules and patterns to be specified in advance, can be used even if they deviate slightly from the predefined patterns. There was a problem that vulnerabilities were not detected.

이러한 문제점을 해결하기 위해, 최근에는, 머신러닝 기반의 스마트 컨트랙트 탐지 기술들이 제안되고 있다.To solve this problem, machine learning-based smart contract detection technologies have recently been proposed.

대표적인 머신러닝 기법인 딥러닝 기법은, 취약점 탐지에서 강력한 탐지 성능을 보여주고 있으나, 딥러닝을 구성하고 있는 수백 개의 복잡한 레이어와 수백 만개의 뉴런은, 딥러닝의 탐지 결과를 설명하기 어렵게 만드는 단점이 존재한다.Deep learning, a representative machine learning technique, shows strong detection performance in vulnerability detection, but the hundreds of complex layers and millions of neurons that make up deep learning have the disadvantage of making it difficult to explain the detection results of deep learning. exist.

이러한 딥러닝의 특성으로 인해, 일반적인 딥러닝 기반의 스마트 컨트랙트 탐지 모델은, 단순히 취약점 여부에 대한 결과 여부 만을 제공해 줄 수 있으며, 탐지 결과(취약점 위치 등)에 대한 원인을 설명해주기 어렵다.Due to these characteristics of deep learning, a general deep learning-based smart contract detection model can only provide results regarding vulnerabilities, and it is difficult to explain the cause of the detection results (vulnerability location, etc.).

취약점 탐지에 있어서, 결과에 대한 설명의 어려움은, 개발자에게 취약점 위치를 알려주지 못하는 유용성 문제와 탐지 결과에 대한 신뢰성 문제를 발생시킨다.In vulnerability detection, the difficulty in explaining the results causes usability problems that do not inform developers of the location of vulnerabilities, and reliability problems with the detection results.

따라서, 취약점의 탐지 및 탐지 결과에 대해 원인 설명이 가능한, 개선된 스마트 컨트랙트 내 취약점의 탐지 모델이 절실히 요구되고 있다.Therefore, there is an urgent need for an improved detection model for vulnerabilities in smart contracts that can detect vulnerabilities and explain the causes of detection results.

본 발명의 실시예는, eXplainable AI(XAI)를 통한 취약점 위치를 탐지하는, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법 및 장치를 제공하는 것을 해결과제로 한다.An embodiment of the present invention aims to provide a blockchain smart contract vulnerability location detection method and device that detects the vulnerability location through eXplainable AI (XAI).

또한, 본 발명의 실시예는, XAI 기법 중 Grad-CAM을 사용하여, 추가적인 데이터나 학습 없이 딥러닝의 결과에 대한 설명을 제공하는 것을 목적으로 한다.Additionally, the embodiment of the present invention aims to provide an explanation of the results of deep learning without additional data or learning, using Grad-CAM among the XAI techniques.

또한 본 발명의 실시예는, 전처리 기법을 통한 이미지 변환과 딥러닝 모델 구조를 제안 함으로써, XAI 기반의 스마트 컨트랙트 취약점 위치 탐지율을 높이는 것을 목적으로 한다.Additionally, the embodiment of the present invention aims to increase the XAI-based smart contract vulnerability location detection rate by proposing image conversion and deep learning model structure through preprocessing techniques.

본 발명의 일실시예에 따른, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법은, 스마트 컨트랙트를, 바이트 코드(Bytecode)로 변환하여 데이터 전처리(Data Preprocessing)하는 단계; 상기 바이트 코드를 딥러닝 모델에 입력하여 취약점 탐지(Vulnerability Detection)하는 단계; 및 상기 딥러닝 모델로부터의 출력으로서 '취약점 발생'이 탐지되면, 상기 스마트 컨트랙트 내 취약점 위치를 특정하기 위한 코드 매핑(Code Mapping)하는 단계를 포함 할 수 있다.According to an embodiment of the present invention, a method for detecting the location of a vulnerability in a blockchain smart contract includes converting a smart contract into bytecode and performing data preprocessing; Vulnerability detection by inputting the byte code into a deep learning model; And when 'vulnerability occurrence' is detected as an output from the deep learning model, it may include a code mapping step to specify the location of the vulnerability within the smart contract.

또한, 본 발명의 실시예에 따른, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치는, 스마트 컨트랙트를, 바이트 코드(Bytecode)로 변환하여 데이터 전처리(Data Preprocessing)하는 데이터 전처리부; 상기 바이트 코드를 딥러닝 모델에 입력하여 취약점 탐지(Vulnerability Detection)하는 취약점 탐지부; 및 상기 딥러닝 모델로부터의 출력으로서 '취약점 발생'이 탐지되면, 상기 스마트 컨트랙트 내 취약점 위치를 특정하기 위한 코드 매핑(Code Mapping)하는 코드 매핑부를 포함하여 구성할 수 있다.In addition, a blockchain smart contract vulnerability location detection device according to an embodiment of the present invention includes a data preprocessing unit that converts a smart contract into bytecode and performs data preprocessing; A vulnerability detection unit that detects vulnerabilities by inputting the byte code into a deep learning model; And when 'occurrence of vulnerability' is detected as an output from the deep learning model, it can be configured to include a code mapping unit that performs code mapping to specify the location of the vulnerability in the smart contract.

본 발명의 일실시예에 따르면, eXplainable AI(XAI)를 통한 취약점 위치를 탐지하는, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법 및 장치를 제공 할 수 있다.According to an embodiment of the present invention, it is possible to provide a blockchain smart contract vulnerability location detection method and device that detects the vulnerability location through eXplainable AI (XAI).

또한, 본 발명에 의해서는, XAI 기법 중 Grad-CAM을 사용하여, 추가적인 데이터나 학습 없이 딥러닝의 결과에 대한 설명을 제공 할 수 있다.In addition, according to the present invention, an explanation of the results of deep learning can be provided without additional data or learning by using Grad-CAM among the XAI techniques.

또한, 본 발명에 의해서는, 전처리 기법을 통한 이미지 변환과 딥러닝 모델 구조를 제안 함으로써, XAI 기반의 스마트 컨트랙트 취약점 위치 탐지율을 높일 수 있다.In addition, the present invention can increase the XAI-based smart contract vulnerability location detection rate by proposing image conversion and deep learning model structure through preprocessing techniques.

도 1은 본 발명의 일실시예에 따른 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치의 구성을 도시한 블록도이다.
도 2는 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치의 동작 순서를 설명하는 도이다.
도 3은 Transforming을 통한 바이트 코드의 변환을 예시하여 설명하기 위한 도이다.
도 4는 본 발명의 일실시예에 따른, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법을 도시한 흐름도이다.
Figure 1 is a block diagram showing the configuration of a blockchain smart contract vulnerability location detection device according to an embodiment of the present invention.
Figure 2 is a diagram explaining the operation sequence of the blockchain smart contract vulnerability location detection device.
Figure 3 is a diagram for explaining byte code conversion through Transforming.
Figure 4 is a flowchart showing a method for detecting the location of a blockchain smart contract vulnerability according to an embodiment of the present invention.

이하에서, 첨부된 도면을 참조하여 실시예들을 상세하게 설명한다. 그러나, 실시예들에는 다양한 변경이 가해질 수 있어서 특허출원의 권리 범위가 이러한 실시예들에 의해 제한되거나 한정되는 것은 아니다. 실시예들에 대한 모든 변경, 균등물 내지 대체물이 권리 범위에 포함되는 것으로 이해되어야 한다.Hereinafter, embodiments will be described in detail with reference to the attached drawings. However, various changes can be made to the embodiments, so the scope of the patent application is not limited or limited by these embodiments. It should be understood that all changes, equivalents, or substitutes for the embodiments are included in the scope of rights.

실시예에서 사용한 용어는 단지 설명을 목적으로 사용된 것으로, 한정하려는 의도로 해석되어서는 안된다. 단수의 표현은 문맥상 명백하게 다르게 뜻하지 않는 한, 복수의 표현을 포함한다. 본 명세서에서, "포함하다" 또는 "가지다" 등의 용어는 명세서 상에 기재된 특징, 숫자, 단계, 동작, 구성요소, 부품 또는 이들을 조합한 것이 존재함을 지정하려는 것이지, 하나 또는 그 이상의 다른 특징들이나 숫자, 단계, 동작, 구성요소, 부품 또는 이들을 조합한 것들의 존재 또는 부가 가능성을 미리 배제하지 않는 것으로 이해되어야 한다.The terms used in the examples are for descriptive purposes only and should not be construed as limiting. Singular expressions include plural expressions unless the context clearly dictates otherwise. In this specification, terms such as “comprise” or “have” are intended to designate the presence of features, numbers, steps, operations, components, parts, or combinations thereof described in the specification, but are not intended to indicate the presence of one or more other features. It should be understood that this does not exclude in advance the possibility of the existence or addition of elements, numbers, steps, operations, components, parts, or combinations thereof.

다르게 정의되지 않는 한, 기술적이거나 과학적인 용어를 포함해서 여기서 사용되는 모든 용어들은 실시예가 속하는 기술 분야에서 통상의 지식을 가진 자에 의해 일반적으로 이해되는 것과 동일한 의미를 가지고 있다. 일반적으로 사용되는 사전에 정의되어 있는 것과 같은 용어들은 관련 기술의 문맥 상 가지는 의미와 일치하는 의미를 가지는 것으로 해석되어야 하며, 본 출원에서 명백하게 정의하지 않는 한, 이상적이거나 과도하게 형식적인 의미로 해석되지 않는다.Unless otherwise defined, all terms used herein, including technical or scientific terms, have the same meaning as generally understood by a person of ordinary skill in the technical field to which the embodiments belong. Terms defined in commonly used dictionaries should be interpreted as having a meaning consistent with the meaning in the context of the related technology, and unless explicitly defined in the present application, should not be interpreted in an ideal or excessively formal sense. No.

또한, 첨부 도면을 참조하여 설명함에 있어, 도면 부호에 관계없이 동일한 구성 요소는 동일한 참조부호를 부여하고 이에 대한 중복되는 설명은 생략하기로 한다. 실시예를 설명함에 있어서 관련된 공지 기술에 대한 구체적인 설명이 실시예의 요지를 불필요하게 흐릴 수 있다고 판단되는 경우 그 상세한 설명을 생략한다.In addition, when describing with reference to the accompanying drawings, identical components will be assigned the same reference numerals regardless of the reference numerals, and overlapping descriptions thereof will be omitted. In describing the embodiments, if it is determined that detailed descriptions of related known technologies may unnecessarily obscure the gist of the embodiments, the detailed descriptions are omitted.

도 1은 본 발명의 일실시예에 따른 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치의 구성을 도시한 블록도이다.Figure 1 is a block diagram showing the configuration of a blockchain smart contract vulnerability location detection device according to an embodiment of the present invention.

도 1을 참조하면, 본 발명의 일실시예에 따른, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 데이터 전처리부(110), 취약점 탐지부(120), 및 코드 매핑부(130)를 포함하여 구성할 수 있다.Referring to FIG. 1, the blockchain smart contract vulnerability location detection device 100 according to an embodiment of the present invention includes a data preprocessing unit 110, a vulnerability detection unit 120, and a code mapping unit 130. It can be configured to include.

우선, 데이터 전처리부(110)는 스마트 컨트랙트를, 바이트 코드(Bytecode)로 변환하여 데이터 전처리(Data Preprocessing)한다. 즉, 데이터 전처리부(110)는 스마트 컨트랙트에 취약점이 있는지를 탐지하는 것과 관련되는 딥러닝 모델로의 입력이 가능한 형태로, 상기 스마트 컨트랙트를 전처리하는 역할을 할 수 있다.First, the data preprocessing unit 110 converts the smart contract into bytecode and performs data preprocessing. In other words, the data preprocessing unit 110 can serve to preprocess the smart contract in a form that allows input into a deep learning model related to detecting whether there are vulnerabilities in the smart contract.

데이터 전처리부(110)에 의한 데이터 전처리는, Compile 단계, Transforming 단계, Mapping 단계로 구성될 수 있다.Data pre-processing by the data pre-processing unit 110 may consist of a Compile step, a Transforming step, and a Mapping step.

상기 Compile 단계에 있어, 데이터 전처리부(110)는, 고수준 언어(High-level Language)인 상기 스마트 컨트랙트를, 저수준 언어(Low-level Language)인 상기 바이트 코드로 컴파일(Compile) 할 수 있다.In the Compile step, the data preprocessor 110 can compile the smart contract, which is a high-level language, into the byte code, which is a low-level language.

스마트 컨트랙트는 분산원장기술(DLT: Distributed Ledger Technology)을 기반으로 하는 환경에서 일정 조건을 충족시키면 당사자 간에 거래가 자동으로 체결되는 소프트웨어 프로그램을 이용한 컨트랙트를 지칭할 수 있다.A smart contract can refer to a contract using a software program in which a transaction is automatically concluded between parties when certain conditions are met in an environment based on Distributed Ledger Technology (DLT).

후술하는 도 2에는 소프트웨어 프로그램의 고수준 언어(High-level Language)로 기술되는 스마트 컨트랙트(contract SimpleDAO {~})가 예시되고 있다.Figure 2, described later, illustrates a smart contract (contract SimpleDAO {~}) described in the high-level language of a software program.

바이트 코드(Bytecode)는 특정 하드웨어가 아닌 가상 컴퓨터에서 돌아가는 실행 프로그램을 위한 이진 표현일 수 있다.Bytecode can be a binary representation for an executable program that runs on a virtual computer rather than on specific hardware.

도 2에는 상술의 스마트 컨트랙트(contract SimpleDAO {~})를, 바이트 코드(Bytecodes : 0x608062~)로 컴파일되는 것이 예시되고 있다.Figure 2 illustrates that the above-described smart contract (contract SimpleDAO {~}) is compiled into bytecodes (Bytecodes: 0x608062~).

상기 Transforming 단계에 있어, 데이터 전처리부(110)는, 컴파일된 상기 바이트 코드를, 상기 딥러닝 모델에서 규정하는 입력 형태로 변환(Transforming) 할 수 있다.In the Transforming step, the data preprocessor 110 may transform the compiled byte code into an input form specified in the deep learning model.

즉, 데이터 전처리부(110)는 바이트 코드의 구조를 딥러닝 모델로의 입력 가능한 형태로 통일시키는 역할을 한다.In other words, the data preprocessor 110 serves to unify the structure of the byte code into a form that can be input into a deep learning model.

변환은 Operand의 제거 작업과 제로패딩의 추가 자업으로 이루어질 수 있다.Transformation can be accomplished by removing operands and adding zero padding.

데이터 전처리부(110)는, 상기 바이트 코드 내 각 Opcode에 할당되는 Operand의 개수를 확인할 수 있다.The data preprocessor 110 can check the number of operands assigned to each opcode in the byte code.

예컨대, 이미지 기반 딥러닝 모델(CNN)에서 요구되는 크기의 바이트 코드를, Opcode 각각으로 2개의 Operand가 할당되는 것을 예시할 수 있다.For example, in an image-based deep learning model (CNN), two operands may be allocated to each opcode for a byte code of the size required.

바이트 코드 Original Opcode가'60(Opcode)-80(Operand)/62(Opcode)-40,50,78(Operand)/52(Opcode)'로 구성되어 있는 경우, 데이터 전처리부(110)는, '60(Opcode)-Operand 1개 할당'/62(Opcode)-Operand 3개 할당)/52(Opcode)- Operand 할당 없음'을 확인할 수 있다.If the byte code Original Opcode consists of '60(Opcode)-80(Operand)/62(Opcode)-40,50,78(Operand)/52(Opcode)', the data preprocessor 110 You can check '60(Opcode)-1 Operand allocated'/62(Opcode)-3 Operand allocated)/52(Opcode)-No Operand allocated'.

확인된 상기 Operand의 개수가, 상기 딥러닝 모델에서 규정하는 개수 보다 많으면, 데이터 전처리부(110)는, 초과하는 개수의 Operand를 제거할 수 있다.If the number of confirmed operands is greater than the number specified in the deep learning model, the data preprocessor 110 may remove the exceeding number of operands.

Operand 3개 할당된 '62(Opcode)-40,50,78(Operand)'에 대해, 데이터 전처리부(110)는, 규정된 2개를 초과하는 마지막 Operand 78을 제거 할 수 있다. 이에 따라, '62(Opcode)'는 2개의 Operand 40,50이, 규정에 맞게 할당될 수 있다.For '62(Opcode)-40, 50, 78(Operand)' to which three operands are allocated, the data preprocessor 110 can remove the last operand 78 that exceeds the specified two. Accordingly, '62(Opcode)' can be assigned two Operands 40 and 50 according to regulations.

만약, 확인된 상기 Operand의 개수가, 상기 딥러닝 모델에서 규정하는 개수 보다 적으면, 부족한 개수 만큼의 제로패딩을 추가할 수 있다.If the number of confirmed operands is less than the number specified in the deep learning model, zero padding equal to the insufficient number can be added.

Operand 1개 할당된 '60(Opcode)-80(Operand)'에 대해, 데이터 전처리부(110)는, 규정된 2개를 맞추기 위해 부족한 1개분의 제로패딩 00을 추가 할 수 있다. 이에 따라, '60(Opcode)'는 2개의 Operand 80,00이, 규정에 맞게 할당될 수 있다.For '60(Opcode)-80(Operand)' assigned to one Operand, the data pre-processing unit 110 may add zero padding 00 for one insufficient number to match the specified two. Accordingly, '60(Opcode)' can be assigned two Operands 80,00 in accordance with regulations.

또한, Operand가 할당되지 않는 '52(Opcode)'에 대해, 데이터 전처리부(110)는, 규정된 2개를 맞추기 위해 부족한 2개분의 제로패딩 00 00을 추가 할 수 있다. 이에 따라, '52(Opcode)'는 2개의 Operand 00,00이, 규정에 맞게 할당될 수 있다.In addition, for '52 (Opcode)' for which no operand is assigned, the data preprocessor 110 may add two insufficient zero paddings, 00 00, to match the specified two. Accordingly, '52(Opcode)' can be assigned two Operands 00,00 in accordance with regulations.

최종적으로 데이터 전처리부(110)는, '60(Opcode)-80,00(Operand)/62(Opcode)-40,50(Operand)/52(Opcode)-00,00(Operand)'로, 바이트 코드 Original Opcode를 이미지 기반 딥러닝 모델(CNN)에 적합한 형태로 변환할 수 있다.Finally, the data preprocessor 110 sets the byte to '60(Opcode)-80,00(Operand)/62(Opcode)-40,50(Operand)/52(Opcode)-00,00(Operand)'. The original opcode can be converted into a form suitable for an image-based deep learning model (CNN).

상기 Mapping 단계에 있어, 데이터 전처리부(110)는, 상기 변환된 바이트 코드를 RGB 이미지로 맵핑(Mapping) 할 수 있다. 즉, 데이터 전처리부(110)는 바이트 코드와 RGB 이미지를 1:1 매핑 함으로써, 바이트 코드가, 딥러닝 모델로서의 이미지 기반 딥러닝 모델(CNN)에 입력되어 학습 가능하도록 할 수 있다.In the mapping step, the data preprocessor 110 may map the converted byte code to an RGB image. That is, the data preprocessor 110 can map the byte code and the RGB image 1:1, allowing the byte code to be input to an image-based deep learning model (CNN) as a deep learning model and learn.

취약점 탐지부(120)는 상기 바이트 코드를 딥러닝 모델에 입력하여 취약점 탐지(Vulnerability Detection) 한다. 즉, 취약점 탐지부(120)는 이미지 화 한 바이트 코드에 대한 딥러닝 모델에서의 학습에 근거하여, 궁극적으로 스마트 컨트랙트에 취약점이 있는지의 여부를 탐지해내는 역할을 할 수 있다.The vulnerability detection unit 120 inputs the byte code into a deep learning model to detect vulnerabilities. In other words, the vulnerability detection unit 120 can ultimately serve to detect whether there is a vulnerability in the smart contract based on learning from a deep learning model for the imaged byte code.

취약점 탐지부(120)는 데이터 전처리에서 얻은 RGB 이미지를, 딥러닝 모델의 입력으로 사용하여 취약점 유무를 탐지할 수 있다.The vulnerability detection unit 120 can detect the presence or absence of vulnerabilities by using the RGB image obtained from data preprocessing as an input to a deep learning model.

취약점 유무의 탐지를 위해, 본 발명에 따른 딥러닝 모델은, 최소화된 pooling 및 Non-stride 구조, Depthwise Separable Convolution 구조, Global Max Pooling 레이어를 포함할 수 있다.To detect the presence or absence of vulnerabilities, the deep learning model according to the present invention may include a minimized pooling and non-stride structure, a Depthwise Separable Convolution structure, and a Global Max Pooling layer.

즉, 취약점 탐지부(120)는, 상기 딥러닝 모델에서의, 풀링(Pooling) 연산 및 스트라이드(Stride) 연산을 사용하지 않을 수 있다.That is, the vulnerability detection unit 120 may not use the pooling operation and stride operation in the deep learning model.

pooling 및 stride 구조는, 일반적인 딥러닝 모델에서, 연산량을 줄이고 학습 효율을 높이기 위해 사용될 수 있다.Pooling and stride structures can be used in general deep learning models to reduce computation and increase learning efficiency.

Pooling은 예컨대 여러 개의 픽셀을, 하나의 픽셀(영향력이 가장 센 픽셀 또는 영향력이 가장 작은 픽셀)로 대표 시킴으로써 연산량을 줄이는 기법일 수 있다.Pooling, for example, can be a technique to reduce the amount of computation by representing multiple pixels as one pixel (the pixel with the most influence or the pixel with the least influence).

stride 구조는 임의 복수의 데이터를, 하나의 데이터를 줄여, 데이터의 크기를 줄이는 기법일 수 있다.The stride structure can be a technique to reduce the size of data by arbitrarily reducing a plurality of data by one piece of data.

하지만, pooling 및 stride 연산은 학습 및 탐지 과정에서 취약점 위치 정보(Spatial Information)를 소실시키는 문제가 야기 될 수 있다.However, pooling and stride operations may cause the problem of losing vulnerability spatial information during the learning and detection process.

이에 따라, 취약점 탐지부(120)는, 취약점 위치 정보를 보존하기 위해, 최소한의 pooling 및 Non-stride 구조의 딥러닝 모델에 의해, 풀링 연산 및 스트라이드 연산이 사용되지 않도록 할 수 있다.Accordingly, the vulnerability detection unit 120 can prevent pooling operations and stride operations from being used by using a deep learning model with a minimal pooling and non-stride structure in order to preserve vulnerability location information.

취약점 탐지부(120)는, 상기 풀링 연산 및 상기 스트라이드 연산 대신에, 상기 딥러닝 모델에서 Depthwise Separable Convolution 연산을 사용하여, 컨볼루션 연산에 소모되는 파라미터 수를 줄일 수 있다.The vulnerability detection unit 120 can reduce the number of parameters consumed in the convolution operation by using the Depthwise Separable Convolution operation in the deep learning model instead of the pooling operation and the stride operation.

풀링이나 스트라이드 연산을 사용하지 않는 딥러닝 모델의 사용으로 인해, 학습 과정에는 많은 양의 연산이 요구될 수 있다.Due to the use of deep learning models that do not use pooling or stride operations, the learning process may require a large amount of computation.

이를 해결하기 위해, 취약점 탐지부(120)는, Depthwise Separable Convolution 구조의 딥러닝 모델에 의해, 컨볼루션 연산에 소모되는 파라미터 수를 줄일 수 있는 Depthwise Separable Convolution 연산을 사용할 수 있다.To solve this, the vulnerability detection unit 120 can use a Depthwise Separable Convolution operation that can reduce the number of parameters consumed in the convolution operation by using a deep learning model with a Depthwise Separable Convolution structure.

RGB 이미지에 대한 Depthwise Separable Convolution 연산은, 매개 변수인 파라미터의 수를 최적화하여 메모리 사용량을 줄이고, 학습 속도를 높일 수 있다. Depthwise Separable Convolution 연산에서는, 예컨대 채널을 기준으로 각각 ‘필터 높이, 필터 너비, 1’과 ‘1, 1, 채널 수’로 분리한 두 종류의 필터로 Depthwise Separable Convolution 연산을 진행 할 수 있다.Depthwise Separable Convolution operation for RGB images can reduce memory usage and increase learning speed by optimizing the number of parameters. In the Depthwise Separable Convolution operation, for example, the Depthwise Separable Convolution operation can be performed with two types of filters separated into ‘filter height, filter width, 1’ and ‘1, 1, number of channels’, respectively, based on the channel.

Depthwise Separable Convolution 연산은 depth를 분해해서, 여러 개의 Convolution 연산을 수행하는 방식일 수 있다. Depthwise Separable Convolution operation may be a method of decomposing depth and performing multiple convolution operations.

또한, 취약점 탐지부(120)는, 상기 딥러닝 모델의 마지막 레이어를, Global Max Pooling 레이어를 사용 함으로써, 상기 제로패딩의 추가에 따른 연산 효율 저하를 보상 할 수 있다.In addition, the vulnerability detection unit 120 can compensate for the decrease in computational efficiency caused by the addition of the zero padding by using the Global Max Pooling layer as the last layer of the deep learning model.

일반적으로는, 딥러닝의 마지막 레이어에서 취약점 여부를 탐지하기 위해, Fully Connected Layer, Global Average Pooling 등을 사용할 수 있다.In general, Fully Connected Layer, Global Average Pooling, etc. can be used to detect vulnerabilities in the last layer of deep learning.

하지만, 앞서 데이터 전처리의 Transforming 단계에서 제로패딩의 가산이 이루어졌으므로, Fully Connected Layer나 Global Average Pooling 사용 시에는, 연산의 효율이 저하될 수 있다.However, since zero padding was added in the transforming stage of data preprocessing, the efficiency of calculation may be reduced when using Fully Connected Layer or Global Average Pooling.

연산 효율의 저하 문제를 해결하기 위해, 취약점 탐지부(120)는, 딥러닝 모델의 마지막 레이어를 Global Max Pooling 레이어로 사용할 수 있다.To solve the problem of reduced computational efficiency, the vulnerability detection unit 120 can use the last layer of the deep learning model as a Global Max Pooling layer.

pooling은 주로 컨볼루션 연산 후에 수행하며, Global Max Pooling 은, Depthwise Separable Convolution 연산에 따른 결과의 window에서 최댓값을 뽑아내기 위한 레이어 일 수 있다.Pooling is mainly performed after the convolution operation, and Global Max Pooling can be a layer for extracting the maximum value from the window of the result of the Depthwise Separable Convolution operation.

또한, 코드 매핑부(130)는 상기 딥러닝 모델로부터의 출력으로서 '취약점 발생'이 탐지되면, 상기 스마트 컨트랙트 내 취약점 위치를 특정하기 위한 코드 매핑(Code Mapping)한다. 즉, 코드 매핑부(130)는 탐지된 취약점에 대해 위치 식별 후, 취약점 위치를 설명할 수 있도록 코드 매핑을 통해, 고수준 언어인 스마트 컨트랙트로 복원하는 역할을 할 수 있다.In addition, when 'occurrence of vulnerability' is detected as an output from the deep learning model, the code mapping unit 130 performs code mapping to specify the location of the vulnerability within the smart contract. That is, the code mapping unit 130 can serve to identify the location of the detected vulnerability and then restore it to a smart contract, a high-level language, through code mapping to explain the location of the vulnerability.

코드 매핑에 있어, 코드 매핑부(130)는, Grad-CAM의 적용을 통해, 상기 RGB 이미지에서 취약점 위치를 찾아낼 수 있다. 즉, 코드 매핑부(130)는 Grad-CAM의 적용을 통해, 입력으로 사용된 바이트 코드에서 취약점이 어디있는지를 찾을 수 있다.In code mapping, the code mapping unit 130 can find the location of vulnerabilities in the RGB image through the application of Grad-CAM. In other words, the code mapping unit 130 can find vulnerabilities in the byte code used as input through the application of Grad-CAM.

Grad-CAM은 gradient에 따른 activation mapping 기법일 수 있다.Grad-CAM can be an activation mapping technique based on gradient.

코드 매핑부(130)는, Grad-CAM을 사용하여, RGB 이미지에 대해 클래스를 구분하고 RGB 이미지에서의 취약점 예측 위치를 국소화하여 표현 할 수 있다. 즉, 코드 매핑부(130)는, 취약점 위치를 Grad-CAM을 통해 localization하여 표현 함으로써, 취약점의 정확한 위치를 정확하게 찾아낼 수 있다.The code mapping unit 130 can use Grad-CAM to classify RGB images into classes and localize and express predicted vulnerabilities in the RGB images. In other words, the code mapping unit 130 can accurately find the exact location of the vulnerability by localizing and expressing the location of the vulnerability through Grad-CAM.

또한, 코드 매핑부(130)는, 바이트 코드 매핑에 의해, 상기 찾은 취약점 위치를 상기 바이트 코드의 명령어로 매핑할 수 있다. 즉, 코드 매핑부(130)는, RGB 이미지 내에서 찾은 취약점 위치를, 바이트 코드의 언어로 매핑 전환할 수 있다.Additionally, the code mapping unit 130 may map the found vulnerability location to an instruction of the byte code through byte code mapping. That is, the code mapping unit 130 can convert the vulnerability location found in the RGB image into a byte code language.

이후, 코드 매핑부(130)는 스마트 컨트랙트 코드 매핑을 통해, 상기 바이트 코드의 명령어를, 상기 스마트 컨트랙트의 명령어로 매핑할 수 있다. 즉, 코드 매핑부(130)는, 저수준 언어인 바이트 코드를, 고수준 언어인 스마트 컨트랙트로 매핑 전환 함으로써, 찾은 취약점 위치가 최종적으로 사용자가 인지할 수 있는 언어로 표현되도록 할 수 있다.Thereafter, the code mapping unit 130 may map the commands of the byte code to the commands of the smart contract through smart contract code mapping. In other words, the code mapping unit 130 can convert the byte code, which is a low-level language, into a smart contract, which is a high-level language, so that the location of the discovered vulnerability is finally expressed in a language that the user can recognize.

본 발명의 일실시예에 따르면, eXplainable AI(XAI)를 통한 취약점 위치를 탐지하는, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법 및 장치를 제공 할 수 있다.According to an embodiment of the present invention, it is possible to provide a blockchain smart contract vulnerability location detection method and device that detects the vulnerability location through eXplainable AI (XAI).

또한, 본 발명에 의해서는, XAI 기법 중 Grad-CAM을 사용하여, 추가적인 데이터나 학습 없이 딥러닝의 결과에 대한 설명을 제공 할 수 있다.In addition, according to the present invention, an explanation of the results of deep learning can be provided without additional data or learning by using Grad-CAM among the XAI techniques.

또한, 본 발명에 의해서는, 전처리 기법을 통한 이미지 변환과 딥러닝 모델 구조를 제안 함으로써, XAI 기반의 스마트 컨트랙트 취약점 위치 탐지율을 높일 수 있다.In addition, the present invention can increase the XAI-based smart contract vulnerability location detection rate by proposing image conversion and deep learning model structure through preprocessing techniques.

기존의 딥러닝 기반의 스마트 컨트랙트 탐지 기법은, 취약점 위치의 탐지를 제공해주기 어렵다는 단점을 가지고 있다.Existing deep learning-based smart contract detection techniques have the disadvantage of being difficult to detect vulnerability locations.

취약점 위치의 탐지를 제공해주기 위한 시도 연구들이 일부 있었으나, 이들 시도 연구들은, 학습 단계에서 취약점 위치 데이터나 레이어 등의 추가적인 구조가 요구된다는 단점이 존재 한다.There have been some attempts to provide detection of vulnerability locations, but these studies have the disadvantage of requiring additional structures such as vulnerability location data or layers in the learning stage.

이러한 문제를 해결하기 위해, 본 발명의 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, eXplainable AI(XAI)를 통한 취약점 위치 탐지의 방안을 제안한다.To solve this problem, the blockchain smart contract vulnerability location detection device 100 of the present invention proposes a method of detecting vulnerability locations through eXplainable AI (XAI).

블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 추가적인 데이터나 학습 없이 딥러닝의 결과에 대한 설명을 제공해주기 위해, 대표적인 XAI 기법 중 Grad-CAM을 사용한다.The blockchain smart contract vulnerability location detection device 100 uses Grad-CAM, one of the representative XAI techniques, to provide an explanation of the results of deep learning without additional data or learning.

또한, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, XAI 기반의 스마트 컨트랙트 취약점 위치 탐지율을 높이기 위해, 전처리 기법을 통한 이미지 변환과 딥러닝 모델 구조를 제안한다.In addition, the blockchain smart contract vulnerability location detection device 100 proposes image conversion and a deep learning model structure through preprocessing techniques to increase the XAI-based smart contract vulnerability location detection rate.

도 2는 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치의 동작 순서를 설명하는 도이다.Figure 2 is a diagram explaining the operation sequence of the blockchain smart contract vulnerability location detection device.

블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 데이터 전처리(STEP1. Data Preprocessing), 취약점 탐지(STEP2. Vulnerability Detection), 코드 매핑(STEP3. Code Mapping)을 순차적으로 수행할 수 있다.The blockchain smart contract vulnerability location detection device 100 can sequentially perform data preprocessing (STEP1. Data Preprocessing), vulnerability detection (STEP2. Vulnerability Detection), and code mapping (STEP3. Code Mapping).

블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 스마트 컨트랙트 소스코드(Smart Contract Code)를 입력으로 받아, 이를 딥러닝 모델에 적합한 입력 형태로 변환하는 데이터 전처리를 수행할 수 있다.The blockchain smart contract vulnerability location detection device 100 can receive smart contract source code as input and perform data preprocessing to convert it into an input form suitable for a deep learning model.

블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 데이터 전처리 된 스마트 컨트랙트 소스코드를 이용하여, 딥러닝 모델에서 취약점 탐지를 진행할 수 있다.The blockchain smart contract vulnerability location detection device 100 can detect vulnerabilities in a deep learning model using data preprocessed smart contract source code.

블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 취약점 발생 시, 취약점 위치를 찾아주는 코드 매핑을 수행하여 취약점 위치를 탐지할 수 있다.The blockchain smart contract vulnerability location detection device 100 can detect the vulnerability location by performing code mapping to find the vulnerability location when a vulnerability occurs.

도 2에서와 같이, 데이터 전처리는, Compile 단계, Transforming 단계, Mapping 단계로 구성될 수 있다.As shown in Figure 2, data preprocessing may consist of a Compile step, a Transforming step, and a Mapping step.

데이터 전처리는, 고수준 언어(High-level Language)인 솔리디티(Solidity) 스마트 컨트랙트를, 컴파일을 통해 저수준 언어(Low-level Language)인 바이트 코드(Bytecode)로 변환 후, 딥러닝 모델에서의 학습에 적합한 형태로 변환할 수 있다.Data preprocessing converts the Solidity smart contract, a high-level language, into bytecode, a low-level language, through compilation, and then uses it for learning in a deep learning model. It can be converted into a suitable form.

이후, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 딥러닝 모델의 입력으로 사용하기 위해, 이미지 기반 컨트랙트로 변환 함으로써 데이터 전처리를 마무리 할 수 있다.Afterwards, the blockchain smart contract vulnerability location detection device 100 can complete data preprocessing by converting it into an image-based contract to use it as input to a deep learning model.

데이터 전처리의 Compile 단계는, 스마트 컨트랙트를 저수준 언어인 바이트 코드로 변환하는 과정일 수 있다.The Compile stage of data preprocessing may be the process of converting a smart contract into byte code, a low-level language.

데이터 전처리의 Transforming 단계는, 바이트 코드를 학습에 적합한 형태로 변환해주는 과정일 수 있다. 이미지 기반 딥러닝 모델(CNN)은, 고정된 크기의 바이트 코드를 연산에 사용할 수 있고, 예컨대 후술하는 도 3과 같이, 딥러닝 학습에 적합한 크기로서, 바이트 코드 연산 당 최대 2개의 인자(Operand) 만을 받을 수 있게 변환할 수 있다.The transforming step of data preprocessing may be a process of converting byte code into a form suitable for learning. An image-based deep learning model (CNN) can use bytecodes of a fixed size for calculation, for example, as shown in Figure 3 described later, a size suitable for deep learning learning, and requires up to two arguments (Operand) per bytecode operation. It can be converted to receive only .

인자를 받지 않는 바이트 코드 연산은, 제로패딩(Zero Padding)을 더해줄 수 있다.For bytecode operations that take no arguments, zero padding can be added.

도 3은 Transforming을 통한 바이트 코드의 변환을 예시하여 설명하기 위한 도이다.Figure 3 is a diagram for explaining byte code conversion through Transforming.

도 3에서는, 이미지 기반 딥러닝 모델(CNN)에서 요구되는 크기의 바이트 코드로, Opcode와 2개의 Operand로 구성되는 것이 예시되고 있다.In Figure 3, a byte code of the size required for an image-based deep learning model (CNN) is illustrated, consisting of an Opcode and two Operands.

도 3에 도시한 바와 같이, Original Opcode가 '60(Opcode)-80(Operand)/62(Opcode)-40,50,78(Operand)/52(Opcode)'로 이루어지는 경우, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, '62(Opcode)-40,50,78(Operand)'에서, 2개를 초과하는 Operand 78을 제거 할 수 있다.As shown in Figure 3, when the Original Opcode consists of '60(Opcode)-80(Operand)/62(Opcode)-40,50,78(Operand)/52(Opcode)', there is a blockchain smart contract vulnerability. The location detection device 100 can remove more than two Operands 78 from '62(Opcode)-40,50,78(Operand)'.

또한, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, '60(Opcode)-80(Operand)'와 '52(Opcode)' 각각에 대해 필요한 자릿수 만큼 제로패딩을 더해 줄 수 있다.Additionally, the blockchain smart contract vulnerability location detection device 100 can add zero padding to each of '60(Opcode)-80(Operand)' and '52(Opcode)' as required.

최종적으로 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, Operand 제거와 제로패딩의 가산에 의해, Opcode와 2개의 Operand로 구성되는, '60(Opcode)-80,00(Operand)/62(Opcode)-40,50(Operand)/52(Opcode)-00,0(Operand)'의, 이미지 기반 딥러닝 모델(CNN)에서 요구되는 크기의 바이트 코드로 변환할 수 있다.Finally, the blockchain smart contract vulnerability location detection device 100 is composed of an opcode and two operands by removing the operand and adding zero padding, '60(Opcode)-80,00(Operand)/62(Opcode )-40,50(Operand)/52(Opcode)-00,0(Operand)' can be converted to a byte code of the size required by the image-based deep learning model (CNN).

데이터 전처리의 Mapping 단계는, 변환된 바이트 코드를 이미지화 하는 과정일 수 있다.The mapping step of data preprocessing may be a process of imaging the converted byte code.

바이트 코드는, 0 ~ 255까지의 숫자 중 하나를 가질 수 있고, RGB 이미지 또한 0 ~ 255까지의 하나의 숫자를 가질 수 있으므로, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 바이트 코드와 RGB 이미지를 1:1로 매핑 할 수 있다.The byte code can have one of the numbers from 0 to 255, and the RGB image can also have one number from 0 to 255, so the blockchain smart contract vulnerability location detection device 100 uses the byte code and RGB Images can be mapped 1:1.

취약점 탐지는, 최소화된 pooling 및 Non-stride 구조, Depthwise Separable Convolution 구조, Global Max Pooling 레이어를 갖는 딥러닝 모델을 통해, 취약점의 발생을 탐지하는 과정일 수 있다.Vulnerability detection may be the process of detecting the occurrence of a vulnerability through a deep learning model with a minimized pooling and non-stride structure, a Depthwise Separable Convolution structure, and a Global Max Pooling layer.

취약점 탐지에 있어, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 데이터 전처리에서 얻은 RGB 이미지를, 딥러닝 모델의 입력으로 사용하여 취약점의 유무를 탐지 할 수 있다.In detecting vulnerabilities, the blockchain smart contract vulnerability location detection device 100 can detect the presence or absence of vulnerabilities by using the RGB image obtained from data preprocessing as an input to a deep learning model.

취약점이 발견된다면, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 발견된 취약점에 대해, 후속의 취약점 위치 탐지를 진행할 수 있다.If a vulnerability is discovered, the blockchain smart contract vulnerability location detection device 100 can perform subsequent vulnerability location detection for the discovered vulnerability.

취약점이 발견되지 않았다면, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 처리를 종료할 수 있다.If no vulnerability is found, the blockchain smart contract vulnerability location detection device 100 may terminate processing.

딥러닝 모델은 최소화된 pooling 및 Non-stride 구조를 가지고 있다.Deep learning models have minimized pooling and non-stride structures.

일반적인 딥러닝 모델에서는 연산량을 줄이고 학습 효율을 높이기 위해 풀링 연산(Pooling)이나 스트라이드(Stride) 연산을 사용할 수 있다.In general deep learning models, pooling or stride operations can be used to reduce the amount of computation and increase learning efficiency.

하지만, 이러한 연산들은 학습 및 탐지 과정에서 취약점 위치 정보(Spatial Information)를 소실시키는 문제가 존재한다.However, these operations have the problem of losing vulnerability spatial information during the learning and detection process.

따라서, 본 발명에서 사용되는 딥러닝 모델은, 취약점 위치 정보를 보존하기 위해, 최소한의 pooling 및 Non-stride 구조를 사용할 수 있다.Therefore, the deep learning model used in the present invention can use minimal pooling and non-stride structures to preserve vulnerability location information.

딥러닝 모델은 Depthwise Separable Convolution 구조를 가지고 있다.Deep learning models have a Depthwise Separable Convolution structure.

본 발명에서 사용되는 딥러닝 모델은, 풀링이나 스트라이드 연산을 사용하지 않았기 때문에, 딥러닝 과정에서 많은 양의 연산이 요구된다.Because the deep learning model used in the present invention does not use pooling or stride operations, a large amount of calculations are required during the deep learning process.

이러한 문제를 해결하기 위해, 딥러닝 모델은, 컨볼루션 연산에 소모되는 파라미터 수를 줄일 수 있는 Depthwise Separable Convolution 연산을 사용할 수 있다.To solve this problem, deep learning models can use Depthwise Separable Convolution operation, which can reduce the number of parameters consumed in convolution operation.

딥러닝 모델은, Global Max Pooling 레이어를 가지고 있다.The deep learning model has a Global Max Pooling layer.

일반적으로는, 딥러닝의 마지막 레이어에서 취약점 여부를 탐지하기 위해, Fully Connected Layer, Global Average Pooling 등을 사용할 수 있다.In general, Fully Connected Layer, Global Average Pooling, etc. can be used to detect vulnerabilities in the last layer of deep learning.

하지만, 앞서 데이터 전처리의 Transforming 단계에서 제로패딩의 가산이 이루어졌으므로, Fully Connected Layer나 Global Average Pooling 사용 시에는, 연산의 효율이 저하될 수 있다.However, since zero padding was added in the transforming stage of data preprocessing, the efficiency of calculation may be reduced when using Fully Connected Layer or Global Average Pooling.

연산 효율의 저하 문제를 해결하기 위해, 딥러닝 모델은, Global Max Pooling 레이어를 마지막 레이어로 사용할 수 있다.To solve the problem of reduced computational efficiency, deep learning models can use the Global Max Pooling layer as the last layer.

코드 매핑은, Grad-CAM 기반의 취약점 위치 탐지, 바이트 코드 매핑, 및 스마트 컨트랙트 코드 매핑(Solidity)을 수행할 수 있다.Code mapping can perform Grad-CAM-based vulnerability location detection, byte code mapping, and smart contract code mapping (Solidity).

코드 매핑은, RGB 이미지에서 취약점 위치를 XAI 기술인 Grad-CAM을 통해 찾고, 찾은 취약점 위치를 저수준 언어인 바이트 코드와 고수준 언어인 스마트 컨트랙트 코드로 각각 변환하여 표현하는 과정일 수 있다.Code mapping can be a process of finding vulnerability locations in an RGB image through Grad-CAM, an XAI technology, and converting and expressing the found vulnerability locations into byte code, a low-level language, and smart contract code, a high-level language.

코드 매핑(Code Mapping)의 Grad-CAM 기반의 취약점 위치 탐지는, Grad-CAM의 적용을 통해, 입력으로 사용된 RGB 이미지에서 취약점이 어디있는지를 찾는 과정이다.Code Mapping's Grad-CAM-based vulnerability location detection is the process of finding where vulnerabilities are in the RGB image used as input through the application of Grad-CAM.

코드 매핑(Code Mapping)의 바이트 코드 매핑은, 찾은 취약점 위치를, 바이트 코드 상의 명령어로 매핑시키는 과정이다.Code Mapping's byte code mapping is the process of mapping the discovered vulnerability location to instructions on the byte code.

코드 매핑(Code Mapping)의 스마트 컨트랙트 코드 매핑(Solidity)은 매핑한 바이트 코드의 명령어를, 기존의 고수준 언어인 솔리디티 언어로 매핑하는 과정이다.Code Mapping's smart contract code mapping (Solidity) is the process of mapping the commands of the mapped byte code into the Solidity language, an existing high-level language.

본 발명에 의해서는, 기존의 단순 딥러닝(CNN) 기반 스마트 컨트랙트 탐지 기법과는 다르게, 딥러닝 모델을 통해 취약점 위치까지 탐지 가능하다. According to the present invention, unlike existing simple deep learning (CNN)-based smart contract detection techniques, it is possible to detect vulnerability locations through a deep learning model.

본 발명에 의해서는, 추가적인 데이터의 학습이나 레이어 등의 소모없이 취약점 위치 탐지를 할 수 있다.According to the present invention, vulnerability locations can be detected without learning additional data or consuming layers.

본 발명에 의해서는, Code Mapping을 통해 딥러닝 모델의 결과에 대한 설명을 제공할 수 있으며, 딥러닝 모델의 성능 개선을 위한 정보를 제공해줄 수 있다.According to the present invention, an explanation of the results of a deep learning model can be provided through code mapping, and information for improving the performance of the deep learning model can be provided.

이하, 도 4에서는 본 발명의 실시예들에 따른 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)의 작업 흐름을 상세히 설명한다.Hereinafter, in FIG. 4, the work flow of the blockchain smart contract vulnerability location detection device 100 according to embodiments of the present invention will be described in detail.

도 4는 본 발명의 일실시예에 따른, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법을 도시한 흐름도이다.Figure 4 is a flowchart showing a method for detecting the location of a blockchain smart contract vulnerability according to an embodiment of the present invention.

본 실시예에 따른 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법은 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)에 의해 수행될 수 있다.The blockchain smart contract vulnerability location detection method according to this embodiment can be performed by the blockchain smart contract vulnerability location detection device 100.

우선, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는 스마트 컨트랙트를, 바이트 코드(Bytecode)로 변환하여 데이터 전처리(Data Preprocessing)한다(410). 단계(410)는 스마트 컨트랙트에 취약점이 있는지를 탐지하는 것과 관련되는 딥러닝 모델로의 입력이 가능한 형태로, 상기 스마트 컨트랙트를 전처리하는 과정일 수 있다.First, the blockchain smart contract vulnerability location detection device 100 converts the smart contract into bytecode and performs data preprocessing (410). Step 410 may be a process of preprocessing the smart contract in a form that allows input to a deep learning model related to detecting whether there is a vulnerability in the smart contract.

블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)에 의한 데이터 전처리는, Compile 단계, Transforming 단계, Mapping 단계로 구성될 수 있다.Data preprocessing by the blockchain smart contract vulnerability location detection device 100 may consist of a Compile step, a Transforming step, and a Mapping step.

상기 Compile 단계에 있어, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 고수준 언어(High-level Language)인 상기 스마트 컨트랙트를, 저수준 언어(Low-level Language)인 상기 바이트 코드로 컴파일(Compile) 할 수 있다.In the Compile step, the blockchain smart contract vulnerability location detection device 100 compiles the smart contract, which is a high-level language, into the byte code, which is a low-level language. can do.

스마트 컨트랙트는 분산원장기술(DLT: Distributed Ledger Technology)을 기반으로 하는 환경에서 일정 조건을 충족시키면 당사자 간에 거래가 자동으로 체결되는 소프트웨어 프로그램을 이용한 컨트랙트를 지칭할 수 있다.A smart contract can refer to a contract using a software program that automatically concludes a transaction between parties when certain conditions are met in an environment based on Distributed Ledger Technology (DLT).

도 2에는 소프트웨어 프로그램의 고수준 언어(High-level Language)로 기술되는 스마트 컨트랙트(contract SimpleDAO {~})가 예시되고 있다.Figure 2 illustrates a smart contract (contract SimpleDAO {~}) described in the high-level language of a software program.

바이트 코드(Bytecode)는 특정 하드웨어가 아닌 가상 컴퓨터에서 돌아가는 실행 프로그램을 위한 이진 표현일 수 있다.Bytecode can be a binary representation for an executable program that runs on a virtual computer rather than on specific hardware.

도 2에는 상술의 스마트 컨트랙트(contract SimpleDAO {~})를, 바이트 코드(Bytecodes : 0x608062~)로 컴파일되는 것이 예시되고 있다.Figure 2 illustrates that the above-described smart contract (contract SimpleDAO {~}) is compiled into bytecodes (Bytecodes: 0x608062~).

상기 Transforming 단계에 있어, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 컴파일된 상기 바이트 코드를, 상기 딥러닝 모델에서 규정하는 입력 형태로 변환(Transforming) 할 수 있다.In the Transforming step, the blockchain smart contract vulnerability location detection device 100 can transform the compiled byte code into an input form specified in the deep learning model.

즉, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는 바이트 코드의 구조를 딥러닝 모델로의 입력 가능한 형태로 통일시키는 역할을 한다.In other words, the blockchain smart contract vulnerability location detection device 100 serves to unify the structure of the byte code into a form that can be input into a deep learning model.

변환은 Operand의 제거 작업과 제로패딩의 추가 자업으로 이루어질 수 있다.Transformation can be accomplished by removing operands and adding zero padding.

블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 상기 바이트 코드 내 각 Opcode에 할당되는 Operand의 개수를 확인할 수 있다.The blockchain smart contract vulnerability location detection device 100 can check the number of Operands assigned to each Opcode in the byte code.

예컨대, 이미지 기반 딥러닝 모델(CNN)에서 요구되는 크기의 바이트 코드를, Opcode 각각으로 2개의 Operand가 할당되는 것을 예시할 수 있다.For example, in an image-based deep learning model (CNN), two operands may be allocated to each opcode for a byte code of the size required.

바이트 코드 Original Opcode가'60(Opcode)-80(Operand)/62(Opcode)-40,50,78(Operand)/52(Opcode)'로 구성되어 있는 경우, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, '60(Opcode)-Operand 1개 할당'/62(Opcode)-Operand 3개 할당)/52(Opcode)- Operand 할당 없음'을 확인할 수 있다.If the byte code Original Opcode is composed of '60(Opcode)-80(Operand)/62(Opcode)-40,50,78(Operand)/52(Opcode)', the blockchain smart contract vulnerability location detection device ( 100), you can check '60(Opcode)-1 Operand allocated'/62(Opcode)-3 Operand allocated)/52(Opcode)-No Operand allocated'.

확인된 상기 Operand의 개수가, 상기 딥러닝 모델에서 규정하는 개수 보다 많으면, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 초과하는 개수의 Operand를 제거할 수 있다.If the number of confirmed operands is greater than the number specified in the deep learning model, the blockchain smart contract vulnerability location detection device 100 can remove the exceeding number of operands.

Operand 3개 할당된 '62(Opcode)-40,50,78(Operand)'에 대해, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 규정된 2개를 초과하는 마지막 Operand 78을 제거 할 수 있다. 이에 따라, '62(Opcode)'는 2개의 Operand 40,50이, 규정에 맞게 할당될 수 있다.For '62(Opcode)-40, 50, 78(Operand)' assigned to 3 operands, the blockchain smart contract vulnerability location detection device 100 can remove the last operand 78 that exceeds the specified 2. there is. Accordingly, '62(Opcode)' can be assigned two Operands 40 and 50 according to regulations.

만약, 확인된 상기 Operand의 개수가, 상기 딥러닝 모델에서 규정하는 개수 보다 적으면, 부족한 개수 만큼의 제로패딩을 추가할 수 있다.If the number of confirmed operands is less than the number specified in the deep learning model, zero padding equal to the insufficient number can be added.

Operand 1개 할당된 '60(Opcode)-80(Operand)'에 대해, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 규정된 2개를 맞추기 위해 부족한 1개분의 제로패딩 00을 추가 할 수 있다. 이에 따라, '60(Opcode)'는 2개의 Operand 80,00이, 규정에 맞게 할당될 수 있다.For '60(Opcode)-80(Operand)' assigned to one Operand, the blockchain smart contract vulnerability location detection device (100) can add zero padding 00 for one insufficient number to match the specified two. there is. Accordingly, '60(Opcode)' can be assigned two Operands 80,00 in accordance with regulations.

또한, Operand가 할당되지 않는 '52(Opcode)'에 대해, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 규정된 2개를 맞추기 위해 부족한 2개분의 제로패딩 00 00을 추가 할 수 있다. 이에 따라, '52(Opcode)'는 2개의 Operand 00,00이, 규정에 맞게 할당될 수 있다.In addition, for '52 (Opcode)' for which no operand is assigned, the blockchain smart contract vulnerability location detection device 100 can add the insufficient two zero paddings 00 00 to match the specified two. Accordingly, '52(Opcode)' can be assigned two Operands 00,00 in accordance with regulations.

최종적으로 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, '60(Opcode)-80,00(Operand)/62(Opcode)-40,50(Operand)/52(Opcode)-00,00(Operand)'로, 바이트 코드 Original Opcode를 이미지 기반 딥러닝 모델(CNN)에 적합한 형태로 변환할 수 있다.Finally, the blockchain smart contract vulnerability location detection device 100 is '60(Opcode)-80,00(Operand)/62(Opcode)-40,50(Operand)/52(Opcode)-00,00(Operand )', the byte code Original Opcode can be converted into a form suitable for an image-based deep learning model (CNN).

상기 Mapping 단계에 있어, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 상기 변환된 바이트 코드를 RGB 이미지로 맵핑(Mapping) 할 수 있다. 즉, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는 바이트 코드와 RGB 이미지를 1:1 매핑 함으로써, 바이트 코드가, 딥러닝 모델로서의 이미지 기반 딥러닝 모델(CNN)에 입력되어 학습 가능하도록 할 수 있다.In the Mapping step, the blockchain smart contract vulnerability location detection device 100 can map the converted byte code to an RGB image. In other words, the blockchain smart contract vulnerability location detection device 100 maps the byte code and RGB image 1:1, allowing the byte code to be input into an image-based deep learning model (CNN) as a deep learning model and learn. there is.

또한, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는 상기 바이트 코드를 딥러닝 모델에 입력하여 취약점 탐지(Vulnerability Detection) 한다(420). 단계(420)는 이미지 화 한 바이트 코드에 대한 딥러닝 모델에서의 학습에 근거하여, 궁극적으로 스마트 컨트랙트에 취약점이 있는지의 여부를 탐지해내는 과정일 수 있다.In addition, the blockchain smart contract vulnerability location detection device 100 inputs the byte code into a deep learning model to detect vulnerabilities (420). Step 420 may be a process of ultimately detecting whether there is a vulnerability in the smart contract based on learning in a deep learning model for the imaged byte code.

블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는 데이터 전처리에서 얻은 RGB 이미지를, 딥러닝 모델의 입력으로 사용하여 취약점 유무를 탐지할 수 있다.The blockchain smart contract vulnerability location detection device 100 can detect the presence or absence of vulnerabilities by using the RGB image obtained from data preprocessing as an input to a deep learning model.

취약점 유무의 탐지를 위해, 본 발명에 따른 딥러닝 모델은, 최소화된 pooling 및 Non-stride 구조, Depthwise Separable Convolution 구조, Global Max Pooling 레이어를 포함할 수 있다.To detect the presence or absence of vulnerabilities, the deep learning model according to the present invention may include a minimized pooling and non-stride structure, a Depthwise Separable Convolution structure, and a Global Max Pooling layer.

즉, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 상기 딥러닝 모델에서의, 풀링(Pooling) 연산 및 스트라이드(Stride) 연산을 사용하지 않을 수 있다.In other words, the blockchain smart contract vulnerability location detection device 100 may not use the pooling operation and stride operation in the deep learning model.

pooling 및 stride 구조는, 일반적인 딥러닝 모델에서, 연산량을 줄이고 학습 효율을 높이기 위해 사용될 수 있다.Pooling and stride structures can be used in general deep learning models to reduce computation and increase learning efficiency.

하지만, pooling 및 stride 연산은 학습 및 탐지 과정에서 취약점 위치 정보(Spatial Information)를 소실시키는 문제가 야기 될 수 있다.However, pooling and stride operations may cause the problem of losing vulnerability spatial information during the learning and detection process.

이에 따라, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 취약점 위치 정보를 보존하기 위해, 최소한의 pooling 및 Non-stride 구조의 딥러닝 모델에 의해, 풀링 연산 및 스트라이드 연산이 사용되지 않도록 할 수 있다.Accordingly, the blockchain smart contract vulnerability location detection device 100 can prevent pooling operations and stride operations from being used by a deep learning model with a minimal pooling and non-stride structure in order to preserve vulnerability location information. there is.

블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 상기 풀링 연산 및 상기 스트라이드 연산 대신에, 상기 딥러닝 모델에서 Depthwise Separable Convolution 연산을 사용하여, 컨볼루션 연산에 소모되는 파라미터 수를 줄일 수 있다.The blockchain smart contract vulnerability location detection device 100 can reduce the number of parameters consumed in the convolution operation by using the Depthwise Separable Convolution operation in the deep learning model instead of the pooling operation and the stride operation.

풀링이나 스트라이드 연산을 사용하지 않는 딥러닝 모델의 사용으로 인해, 학습 과정에는 많은 양의 연산이 요구될 수 있다.Due to the use of deep learning models that do not use pooling or stride operations, the learning process may require a large amount of computation.

이를 해결하기 위해, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, Depthwise Separable Convolution 구조의 딥러닝 모델에 의해, 컨볼루션 연산에 소모되는 파라미터 수를 줄일 수 있는 Depthwise Separable Convolution 연산을 사용할 수 있다.To solve this, the blockchain smart contract vulnerability location detection device 100 can use a Depthwise Separable Convolution operation that can reduce the number of parameters consumed in the convolution operation by using a deep learning model with a Depthwise Separable Convolution structure.

RGB 이미지에 대한 Depthwise Separable Convolution 연산은, 매개 변수인 파라미터의 수를 최적화하여 메모리 사용량을 줄이고, 학습 속도를 높일 수 있다. Depthwise Separable Convolution 연산에서는, 예컨대 채널을 기준으로 각각 ‘필터 높이, 필터 너비, 1’과 ‘1, 1, 채널 수’로 분리한 두 종류의 필터로 Depthwise Separable Convolution 연산을 진행 할 수 있다.Depthwise Separable Convolution operation for RGB images can reduce memory usage and increase learning speed by optimizing the number of parameters. In the Depthwise Separable Convolution operation, for example, the Depthwise Separable Convolution operation can be performed with two types of filters separated into ‘filter height, filter width, 1’ and ‘1, 1, number of channels’, respectively, based on the channel.

또한, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 상기 딥러닝 모델의 마지막 레이어를, Global Max Pooling 레이어를 사용 함으로써, 상기 제로패딩의 추가에 따른 연산 효율 저하를 보상 할 수 있다.In addition, the blockchain smart contract vulnerability location detection device 100 can compensate for the decrease in computational efficiency caused by the addition of the zero padding by using the Global Max Pooling layer as the last layer of the deep learning model.

일반적으로는, 딥러닝의 마지막 레이어에서 취약점 여부를 탐지하기 위해, Fully Connected Layer, Global Average Pooling 등을 사용할 수 있다.In general, Fully Connected Layer, Global Average Pooling, etc. can be used to detect vulnerabilities in the last layer of deep learning.

하지만, 앞서 데이터 전처리의 Transforming 단계에서 제로패딩의 가산이 이루어졌으므로, Fully Connected Layer나 Global Average Pooling 사용 시에는, 연산의 효율이 저하될 수 있다.However, since zero padding was added in the transforming stage of data preprocessing, the efficiency of calculation may be reduced when using Fully Connected Layer or Global Average Pooling.

연산 효율의 저하 문제를 해결하기 위해, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 딥러닝 모델의 마지막 레이어를 Global Max Pooling 레이어로 사용할 수 있다.To solve the problem of reduced computational efficiency, the blockchain smart contract vulnerability location detection device 100 can use the last layer of the deep learning model as the Global Max Pooling layer.

pooling은 주로 컨볼루션 연산 후에 수행하며, Global Max Pooling 은, Depthwise Separable Convolution 연산에 따른 결과의 window에서 최댓값을 뽑아내기 위한 레이어 일 수 있다.Pooling is mainly performed after the convolution operation, and Global Max Pooling can be a layer for extracting the maximum value from the window of the result of the Depthwise Separable Convolution operation.

계속해서, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는 상기 딥러닝 모델로부터의 출력으로서 '취약점 발생'이 탐지되면, 상기 스마트 컨트랙트 내 취약점 위치를 특정하기 위한 코드 매핑(Code Mapping)한다(430). 단계(430)는 탐지된 취약점에 대해 위치 식별 후, 취약점 위치를 설명할 수 있도록 코드 매핑을 통해, 고수준 언어인 스마트 컨트랙트로 복원하는 과정일 수 있다.Continuing, when the blockchain smart contract vulnerability location detection device 100 detects 'vulnerability occurrence' as an output from the deep learning model, code mapping is performed to specify the location of the vulnerability within the smart contract (430) ). Step 430 may be a process of identifying the location of the detected vulnerability and then restoring it to a smart contract, a high-level language, through code mapping to explain the location of the vulnerability.

코드 매핑에 있어, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, Grad-CAM의 적용을 통해, 상기 RGB 이미지에서 취약점 위치를 찾아낼 수 있다. 즉, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는 Grad-CAM의 적용을 통해, 입력으로 사용된 바이트 코드에서 취약점이 어디있는지를 찾을 수 있다.In code mapping, the blockchain smart contract vulnerability location detection device 100 can find the vulnerability location in the RGB image through the application of Grad-CAM. In other words, the blockchain smart contract vulnerability location detection device 100 can find where the vulnerability is in the byte code used as input through the application of Grad-CAM.

Grad-CAM은 gradient에 따른 activation mapping 기법일 수 있다.Grad-CAM can be an activation mapping technique based on gradient.

블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, Grad-CAM을 사용하여, RGB 이미지에 대해 클래스를 구분하고 RGB 이미지에서의 취약점 예측 위치를 국소화하여 표현 할 수 있다. 즉, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 취약점 위치를 Grad-CAM을 통해 localization하여 표현 함으로써, 취약점의 정확한 위치를 정확하게 찾아낼 수 있다.The blockchain smart contract vulnerability location detection device 100 can use Grad-CAM to distinguish classes for RGB images and localize and express the predicted vulnerability location in the RGB image. In other words, the blockchain smart contract vulnerability location detection device 100 can accurately find the exact location of the vulnerability by localizing and expressing the vulnerability location through Grad-CAM.

또한, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 바이트 코드 매핑에 의해, 상기 찾은 취약점 위치를 상기 바이트 코드의 명령어로 매핑할 수 있다. 즉, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, RGB 이미지 내에서 찾은 취약점 위치를, 바이트 코드의 언어로 매핑 전환할 수 있다.Additionally, the blockchain smart contract vulnerability location detection device 100 can map the found vulnerability location to an instruction of the byte code through byte code mapping. In other words, the blockchain smart contract vulnerability location detection device 100 can convert the vulnerability location found in the RGB image into a byte code language.

이후, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는 스마트 컨트랙트 코드 매핑을 통해, 상기 바이트 코드의 명령어를, 상기 스마트 컨트랙트의 명령어로 매핑할 수 있다. 즉, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치(100)는, 저수준 언어인 바이트 코드를, 고수준 언어인 스마트 컨트랙트로 매핑 전환 함으로써, 찾은 취약점 위치가 최종적으로 사용자가 인지할 수 있는 언어로 표현되도록 할 수 있다.Afterwards, the blockchain smart contract vulnerability location detection device 100 can map the commands of the byte code to the commands of the smart contract through smart contract code mapping. In other words, the blockchain smart contract vulnerability location detection device 100 converts the byte code, which is a low-level language, into a smart contract, which is a high-level language, so that the discovered vulnerability location is finally expressed in a language that the user can recognize. there is.

본 발명의 일실시예에 따르면, eXplainable AI(XAI)를 통한 취약점 위치를 탐지하는, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법 및 장치를 제공 할 수 있다.According to an embodiment of the present invention, it is possible to provide a blockchain smart contract vulnerability location detection method and device that detects the vulnerability location through eXplainable AI (XAI).

또한, 본 발명에 의해서는, XAI 기법 중 Grad-CAM을 사용하여, 추가적인 데이터나 학습 없이 딥러닝의 결과에 대한 설명을 제공 할 수 있다.In addition, according to the present invention, an explanation of the results of deep learning can be provided without additional data or learning by using Grad-CAM among the XAI techniques.

또한, 본 발명에 의해서는, 전처리 기법을 통한 이미지 변환과 딥러닝 모델 구조를 제안 함으로써, XAI 기반의 스마트 컨트랙트 취약점 위치 탐지율을 높일 수 있다.In addition, the present invention can increase the XAI-based smart contract vulnerability location detection rate by proposing image conversion and deep learning model structure through preprocessing techniques.

실시예에 따른 방법은 다양한 컴퓨터 수단을 통하여 수행될 수 있는 프로그램 명령 형태로 구현되어 컴퓨터 판독 가능 매체에 기록될 수 있다. 상기 컴퓨터 판독 가능 매체는 프로그램 명령, 데이터 파일, 데이터 구조 등을 단독으로 또는 조합하여 포함할 수 있다. 상기 매체에 기록되는 프로그램 명령은 실시예를 위하여 특별히 설계되고 구성된 것들이거나 컴퓨터 소프트웨어 당업자에게 공지되어 사용 가능한 것일 수도 있다. 컴퓨터 판독 가능 기록 매체의 예에는 하드 디스크, 플로피 디스크 및 자기 테이프와 같은 자기 매체(magnetic media), CD-ROM, DVD와 같은 광기록 매체(optical media), 플롭티컬 디스크(floptical disk)와 같은 자기-광 매체(magneto-optical media), 및 롬(ROM), 램(RAM), 플래시 메모리 등과 같은 프로그램 명령을 저장하고 수행하도록 특별히 구성된 하드웨어 장치가 포함된다. 프로그램 명령의 예에는 컴파일러에 의해 만들어지는 것과 같은 기계어 코드뿐만 아니라 인터프리터 등을 사용해서 컴퓨터에 의해서 실행될 수 있는 고급 언어 코드를 포함한다. 상기된 하드웨어 장치는 실시예의 동작을 수행하기 위해 하나 이상의 소프트웨어 모듈로서 작동하도록 구성될 수 있으며, 그 역도 마찬가지이다.The method according to the embodiment may be implemented in the form of program instructions that can be executed through various computer means and recorded on a computer-readable medium. The computer-readable medium may include program instructions, data files, data structures, etc., singly or in combination. Program instructions recorded on the medium may be specially designed and configured for the embodiment or may be known and available to those skilled in the art of computer software. Examples of computer-readable recording media include magnetic media such as hard disks, floppy disks, and magnetic tapes, optical media such as CD-ROMs and DVDs, and magnetic media such as floptical disks. -Includes optical media (magneto-optical media) and hardware devices specifically configured to store and execute program instructions, such as ROM, RAM, flash memory, etc. Examples of program instructions include machine language code, such as that produced by a compiler, as well as high-level language code that can be executed by a computer using an interpreter, etc. The hardware devices described above may be configured to operate as one or more software modules to perform the operations of the embodiments, and vice versa.

소프트웨어는 컴퓨터 프로그램(computer program), 코드(code), 명령(instruction), 또는 이들 중 하나 이상의 조합을 포함할 수 있으며, 원하는 대로 동작하도록 처리 장치를 구성하거나 독립적으로 또는 결합적으로(collectively) 처리 장치를 명령할 수 있다. 소프트웨어 및/또는 데이터는, 처리 장치에 의하여 해석되거나 처리 장치에 명령 또는 데이터를 제공하기 위하여, 어떤 유형의 기계, 구성요소(component), 물리적 장치, 가상 장치(virtual equipment), 컴퓨터 저장 매체 또는 장치, 또는 전송되는 신호 파(signal wave)에 영구적으로, 또는 일시적으로 구체화(embody)될 수 있다. 소프트웨어는 네트워크로 연결된 컴퓨터 시스템 상에 분산되어서, 분산된 방법으로 저장되거나 실행될 수도 있다. 소프트웨어 및 데이터는 하나 이상의 컴퓨터 판독 가능 기록 매체에 저장될 수 있다.Software may include a computer program, code, instructions, or a combination of one or more of these, which may configure a processing unit to operate as desired, or may be processed independently or collectively. You can command the device. Software and/or data may be used on any type of machine, component, physical device, virtual equipment, computer storage medium or device to be interpreted by or to provide instructions or data to a processing device. , or may be permanently or temporarily embodied in a transmitted signal wave. Software may be distributed over networked computer systems and stored or executed in a distributed manner. Software and data may be stored on one or more computer-readable recording media.

이상과 같이 실시예들이 비록 한정된 도면에 의해 설명되었으나, 해당 기술분야에서 통상의 지식을 가진 자라면 상기를 기초로 다양한 기술적 수정 및 변형을 적용할 수 있다. 예를 들어, 설명된 기술들이 설명된 방법과 다른 순서로 수행되거나, 및/또는 설명된 시스템, 구조, 장치, 회로 등의 구성요소들이 설명된 방법과 다른 형태로 결합 또는 조합되거나, 다른 구성요소 또는 균등물에 의하여 대치되거나 치환되더라도 적절한 결과가 달성될 수 있다.Although the embodiments have been described with limited drawings as described above, those skilled in the art can apply various technical modifications and variations based on the above. For example, the described techniques are performed in a different order than the described method, and/or components of the described system, structure, device, circuit, etc. are combined or combined in a different form than the described method, or other components are used. Alternatively, appropriate results may be achieved even if substituted or substituted by an equivalent.

그러므로, 다른 구현들, 다른 실시예들 및 특허청구범위와 균등한 것들도 후술하는 청구범위의 범위에 속한다.Therefore, other implementations, other embodiments, and equivalents of the claims also fall within the scope of the following claims.

100 : 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치
110 : 데이터 전처리부
120 : 취약점 탐지부
130 : 코드 매핑부
100: Blockchain smart contract vulnerability location detection device
110: data preprocessing unit
120: Vulnerability detection unit
130: Code mapping unit

Claims (11)

스마트 컨트랙트를, 바이트 코드(Bytecode)로 변환하여 데이터 전처리(Data Preprocessing)하는 단계;
상기 바이트 코드를 딥러닝 모델에 입력하여 취약점 탐지(Vulnerability Detection)하는 단계; 및
상기 딥러닝 모델로부터의 출력으로서 '취약점 발생'이 탐지되면, 상기 스마트 컨트랙트 내 취약점 위치를 특정하기 위한 코드 매핑(Code Mapping)하는 단계
를 포함하는, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법.
Data preprocessing by converting the smart contract into bytecode;
Vulnerability detection by inputting the byte code into a deep learning model; and
When 'vulnerability occurrence' is detected as an output from the deep learning model, code mapping is performed to specify the location of the vulnerability within the smart contract.
Method for detecting location of blockchain smart contract vulnerabilities, including.
제1항에 있어서,
상기 데이터 전처리하는 단계는,
고수준 언어(High-level Language)인 상기 스마트 컨트랙트를, 저수준 언어(Low-level Language)인 상기 바이트 코드로 컴파일(Compile)하는 단계;
컴파일된 상기 바이트 코드를, 상기 딥러닝 모델에서 규정하는 입력 형태로 변환(Transforming)하는 단계; 및
상기 변환된 바이트 코드를 RGB 이미지로 맵핑(Mapping)하는 단계
를 포함하는, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법.
According to paragraph 1,
The data preprocessing step is,
Compiling the smart contract, which is a high-level language, into the byte code, which is a low-level language;
Transforming the compiled byte code into an input form defined by the deep learning model; and
Mapping the converted byte code into an RGB image
Method for detecting location of blockchain smart contract vulnerabilities, including.
제2항에 있어서,
상기 변환하는 단계는,
상기 바이트 코드 내 각 Opcode에 할당되는 Operand의 개수를 확인하는 단계; 및
확인된 상기 Operand의 개수가, 상기 딥러닝 모델에서 규정하는 개수 보다 많으면, 초과하는 개수의 Operand를 제거하는 단계; 또는
확인된 상기 Operand의 개수가, 상기 딥러닝 모델에서 규정하는 개수 보다 적으면, 부족한 개수 만큼의 제로패딩을 추가하는 단계
를 포함하는, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법.
According to paragraph 2,
The conversion step is,
Checking the number of operands assigned to each opcode in the byte code; and
If the number of confirmed operands is greater than the number specified in the deep learning model, removing the exceeding number of operands; or
If the confirmed number of Operands is less than the number specified in the deep learning model, adding zero padding equal to the insufficient number.
Method for detecting location of blockchain smart contract vulnerabilities, including.
제3항에 있어서,
상기 취약점 탐지하는 단계는,
상기 딥러닝 모델에서의, 풀링(Pooling) 연산 및 스트라이드(Stride) 연산을 사용하지 않는 단계;
상기 풀링 연산 및 상기 스트라이드 연산 대신에, 상기 딥러닝 모델에서 Depthwise Separable Convolution 연산을 사용하여, 컨볼루션 연산에 소모되는 파라미터 수를 줄이는 단계; 및
상기 딥러닝 모델의 마지막 레이어를, Global Max Pooling 레이어를 사용 함으로써, 상기 제로패딩의 추가에 따른 연산 효율 저하를 보상하는 단계
를 포함하는, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법.
According to paragraph 3,
The step of detecting the vulnerability is,
Not using pooling and stride operations in the deep learning model;
Reducing the number of parameters consumed in a convolution operation by using a Depthwise Separable Convolution operation in the deep learning model instead of the pooling operation and the stride operation; and
Compensating for the decrease in computational efficiency due to the addition of the zero padding by using the Global Max Pooling layer as the last layer of the deep learning model.
Method for detecting location of blockchain smart contract vulnerabilities, including.
제2항에 있어서,
상기 코드 매핑하는 단계는,
Grad-CAM의 적용을 통해, 상기 RGB 이미지에서 취약점 위치를 찾아내는 단계;
바이트 코드 매핑에 의해, 상기 찾은 취약점 위치를 상기 바이트 코드의 명령어로 매핑하는 단계; 및
스마트 컨트랙트 코드 매핑을 통해, 상기 바이트 코드의 명령어를, 상기 스마트 컨트랙트의 명령어로 매핑하는 단계
를 포함하는, 블록체인 스마트 컨트랙트 취약점 위치 탐지 방법.
According to paragraph 2,
The code mapping step is,
Finding the location of vulnerabilities in the RGB image through application of Grad-CAM;
mapping the found vulnerability location to an instruction of the byte code by byte code mapping; and
Mapping the commands of the byte code to the commands of the smart contract through smart contract code mapping.
Method for detecting location of blockchain smart contract vulnerabilities, including.
스마트 컨트랙트를, 바이트 코드(Bytecode)로 변환하여 데이터 전처리(Data Preprocessing)하는 데이터 전처리부;
상기 바이트 코드를 딥러닝 모델에 입력하여 취약점 탐지(Vulnerability Detection)하는 취약점 탐지부; 및
상기 딥러닝 모델로부터의 출력으로서 '취약점 발생'이 탐지되면, 상기 스마트 컨트랙트 내 취약점 위치를 특정하기 위한 코드 매핑(Code Mapping)하는 코드 매핑부
를 포함하는, 블록체인 스마트 컨트랙트 취약점 위치 탐지 장치.
A data preprocessing unit that converts smart contracts into bytecode and performs data preprocessing;
A vulnerability detection unit that detects vulnerabilities by inputting the byte code into a deep learning model; and
When a 'vulnerability occurrence' is detected as an output from the deep learning model, a code mapping unit performs code mapping to specify the location of the vulnerability within the smart contract.
Blockchain smart contract vulnerability location detection device, including.
제6항에 있어서,
상기 데이터 전처리부는,
고수준 언어(High-level Language)인 상기 스마트 컨트랙트를, 저수준 언어(Low-level Language)인 상기 바이트 코드로 컴파일(Compile)하고,
컴파일된 상기 바이트 코드를, 상기 딥러닝 모델에서 규정하는 입력 형태로 변환(Transforming)하며,
상기 변환된 바이트 코드를 RGB 이미지로 맵핑(Mapping)하는
블록체인 스마트 컨트랙트 취약점 위치 탐지 장치.
According to clause 6,
The data preprocessing unit,
Compile the smart contract, which is a high-level language, into the byte code, which is a low-level language,
Transforming the compiled byte code into an input form specified in the deep learning model,
Mapping the converted byte code into an RGB image
Blockchain smart contract vulnerability location detection device.
제7항에 있어서,
상기 데이터 전처리부는,
상기 바이트 코드 내 각 Opcode에 할당되는 Operand의 개수를 확인하고,
확인된 상기 Operand의 개수가, 상기 딥러닝 모델에서 규정하는 개수 보다 많으면, 초과하는 개수의 Operand를 제거하며,
확인된 상기 Operand의 개수가, 상기 딥러닝 모델에서 규정하는 개수 보다 적으면, 부족한 개수 만큼의 제로패딩을 추가하는
블록체인 스마트 컨트랙트 취약점 위치 탐지 장치.
In clause 7,
The data preprocessing unit,
Check the number of operands assigned to each opcode in the byte code,
If the number of confirmed operands is greater than the number specified in the deep learning model, the exceeding number of operands is removed,
If the number of confirmed operands is less than the number specified in the deep learning model, zero padding equal to the insufficient number is added.
Blockchain smart contract vulnerability location detection device.
제8항에 있어서,
상기 취약점 탐지부는,
상기 딥러닝 모델에서의, 풀링(Pooling) 연산 및 스트라이드(Stride) 연산을 사용하지 않고,
상기 풀링 연산 및 상기 스트라이드 연산 대신에, 상기 딥러닝 모델에서 Depthwise Separable Convolution 연산을 사용하여, 컨볼루션 연산에 소모되는 파라미터 수를 줄이며,
상기 딥러닝 모델의 마지막 레이어를, Global Max Pooling 레이어를 사용 함으로써, 상기 제로패딩의 추가에 따른 연산 효율 저하를 보상하는
블록체인 스마트 컨트랙트 취약점 위치 탐지 장치.
According to clause 8,
The vulnerability detection unit,
In the deep learning model, without using pooling operation and stride operation,
Instead of the pooling operation and the stride operation, the deep learning model uses a Depthwise Separable Convolution operation to reduce the number of parameters consumed in the convolution operation,
By using the Global Max Pooling layer as the last layer of the deep learning model, the decrease in computational efficiency caused by the addition of the zero padding is compensated.
Blockchain smart contract vulnerability location detection device.
제7항에 있어서,
상기 코드 매핑부는,
Grad-CAM의 적용을 통해, 상기 RGB 이미지에서 취약점 위치를 찾아내고,
바이트 코드 매핑에 의해, 상기 찾은 취약점 위치를 상기 바이트 코드의 명령어로 매핑하며,
스마트 컨트랙트 코드 매핑을 통해, 상기 바이트 코드의 명령어를, 상기 스마트 컨트랙트의 명령어로 매핑하는
블록체인 스마트 컨트랙트 취약점 위치 탐지 장치.
In clause 7,
The code mapping unit,
Through the application of Grad-CAM, the location of vulnerabilities is found in the RGB image,
By byte code mapping, the found vulnerability location is mapped to an instruction of the byte code,
Through smart contract code mapping, the commands of the byte code are mapped to the commands of the smart contract.
Blockchain smart contract vulnerability location detection device.
제1항 내지 제5항 중 어느 한 항의 방법을 실행시키기 위한 프로그램을 기록한 컴퓨터 판독 가능한 기록매체.A computer-readable recording medium recording a program for executing the method of any one of claims 1 to 5.
KR1020220108645A 2022-08-29 2022-08-29 Blockchain smart contract vulnerability location detection method and device KR20240030078A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020220108645A KR20240030078A (en) 2022-08-29 2022-08-29 Blockchain smart contract vulnerability location detection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020220108645A KR20240030078A (en) 2022-08-29 2022-08-29 Blockchain smart contract vulnerability location detection method and device

Publications (1)

Publication Number Publication Date
KR20240030078A true KR20240030078A (en) 2024-03-07

Family

ID=90272105

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020220108645A KR20240030078A (en) 2022-08-29 2022-08-29 Blockchain smart contract vulnerability location detection method and device

Country Status (1)

Country Link
KR (1) KR20240030078A (en)

Similar Documents

Publication Publication Date Title
US7917899B2 (en) Program development apparatus, method for developing a program, and a computer program product for executing an application for a program development apparatus
CN102841844B (en) A kind of binary code bug excavation method based on simple and easy semiology analysis
EP2963547A1 (en) Compiling device, compiling method, and storage medium storing compiler program
EP3062256A1 (en) Flexible instructions sets for obfuscated virtual machines
CN110780879B (en) Decision execution method, device, equipment and medium based on intelligent compiling technology
Hwang et al. CodeNet: Code-targeted convolutional neural network architecture for smart contract vulnerability detection
US20210124976A1 (en) Apparatus and method for calculating similarity of images
KR102151318B1 (en) Method and apparatus for malicious detection based on heterogeneous information network
KR102433002B1 (en) Annotation method through multiple binding box selection and a computer program recorded on a recording medium to execute the same
KR102327026B1 (en) Device and method for learning assembly code and detecting software weakness based on graph convolution network
KR102310595B1 (en) Annotation method of setting object properties using proposed information, and computer program recorded on record-medium for executing method thereof
US11068463B2 (en) System and method for managing log data
KR102110735B1 (en) Method and system for re-generating binary for vulnerability detection
KR20240030078A (en) Blockchain smart contract vulnerability location detection method and device
US10585651B2 (en) Partial connection of iterations during loop unrolling
CN116595534A (en) Defect detection method of intelligent contract
US20230205883A1 (en) Integrated static and dynamic analysis for malware detection
CN112199163B (en) Virtual instruction method, device, equipment and storage medium for analyzing and interpreting routine
KR102434899B1 (en) Method for Training Malware Detection Model And Method for Detecting Malware
KR102378377B1 (en) Apparatus and method for obtaining vulnerable transaction sequence in smart contract
KR102419219B1 (en) A security management system for annotation work, a security management method, and a computer program recorded on a recording medium for executing the same
KR102113966B1 (en) Recorded media recording of the bypass device, method and program for performing the analysis
US20230057138A1 (en) Apparatus and method for identifying abnormal processor and computer-readable storage medium
KR102528473B1 (en) Method, System and Computer Program For Masking Log Data
CN112199160B (en) Virtual instruction recovery method, device, equipment and storage medium