KR101851330B1 - Apparatus and method for detecting code reuse attack - Google Patents

Apparatus and method for detecting code reuse attack Download PDF

Info

Publication number
KR101851330B1
KR101851330B1 KR1020160131061A KR20160131061A KR101851330B1 KR 101851330 B1 KR101851330 B1 KR 101851330B1 KR 1020160131061 A KR1020160131061 A KR 1020160131061A KR 20160131061 A KR20160131061 A KR 20160131061A KR 101851330 B1 KR101851330 B1 KR 101851330B1
Authority
KR
South Korea
Prior art keywords
function
call
attack
branch
program
Prior art date
Application number
KR1020160131061A
Other languages
Korean (ko)
Other versions
KR20180039830A (en
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 KR1020160131061A priority Critical patent/KR101851330B1/en
Priority to SG10201701665SA priority patent/SG10201701665SA/en
Publication of KR20180039830A publication Critical patent/KR20180039830A/en
Application granted granted Critical
Publication of KR101851330B1 publication Critical patent/KR101851330B1/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/52Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow
    • G06F21/54Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow by adding security routines or objects to programs
    • 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

Landscapes

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

Abstract

코드 재사용 공격 탐지 장치 및 그 방법이 개시된다. 공격탐지장치는 프로그램 내 호출 명령을 기 지정된 트램폴린 영역으로 분기하는 제1 점프 명령으로 대체하고, 호출명령을 트램폴린 영역으로 옮기고 제1 점프 명령의 다음으로 분기하는 제2 점프 명령을 트램폴린 영역에 생성하고, 프로그램의 함수 내에 상기 함수의 경계를 포함하는 함수 정보를 파악하는 코드를 추가한 후, 프로세서에 의해 프로그램이 실행될 때 프로세서의 디버그 아키텍쳐를 통해 리턴을 포함하는 간접분기의 목적지 주소, 호출명령의 출발지 주소, 함수 경계, 분기타입을 포함하는 실행흐름정보를 파악하여 코드 재사용 공격을 탐지한다.A code reuse attack detection apparatus and method thereof are disclosed. The attack detection device replaces the in-program call command with a first jump command that branches to a predefined trampoline area, creates a second jump command in the trampoline area that moves the call command to the trampoline area and branches to the next of the first jump command , Adding code for grasping the function information including the boundary of the function in the function of the program, and then adding the branch address of the indirect branch including the return via the debug architecture of the processor when the program is executed by the processor, Identify code reuse attacks by identifying execution flow information including addresses, function boundaries, and branch types.

Description

코드 재사용 공격 탐지 장치 및 그 방법{Apparatus and method for detecting code reuse attack}TECHNICAL FIELD [0001] The present invention relates to a code reuse attack detection apparatus,

본 발명은 코드 재사용 공격을 탐지하는 장치 및 그 방법에 관한 것으로서, 보다 상세하게는 리턴 기반 프로그래밍(ROP, return oriented programming) 또는 점프 기반 프로그래밍(JOP, jump oriented programming)를 이용하여 기존 코드 조각을 재사용하는 공격을 탐지하는 장치 및 그 방법에 관한 것이다. The present invention relates to an apparatus and method for detecting a code reuse attack, and more particularly, to a method and apparatus for reusing existing code fragments by using return oriented programming (ROP) or jump oriented programming (JOP) The present invention relates to an apparatus and a method for detecting an attack.

ARM(Advanced RISC Machine) 기반의 다양한 모바일 기기들이 보편화 되면서 이러한 기기들을 노리는 다양한 소프트웨어 기반 공격들이 등장하였다. As various mobile devices based on ARM (Advanced RISC Machine) became popular, various software based attacks aimed at these devices appeared.

코드 삽입 공격은 공격자가 자신이 수행하고자 하는 코드를 공격하고자 하는 프로그램이 수행하는 동안 메모리 상에 삽입하고, 수행 흐름을 변조해 삽입한 코드가 수행되도록 하는 것이다. 그러나 이러한 공격은

Figure 112016098149091-pat00001
(Write XOR eXecute) 방어 기술을 통해 방어되었다. The code insertion attack is to insert the code that the attacker intends to execute into memory while the attacking program executes, and modulate the execution flow so that the inserted code is executed. However,
Figure 112016098149091-pat00001
(Write XOR eXecute) defense.

코드 재사용 공격(CRA, code reuse attack)은 기존의 코드 삽입 공격과는 다르게 연속적인 수행 흐름 변조를 통해 기존 정상적인 프로그램에 존재하는 작은 코드 조각(gadget)들을 연이어 수행하여 공격자가 원하는 코드를 수행하도록 하는 것이다. 이때 공격자가 변조하는 실행분기 명령의 종류에 따라 리턴(return) 명령어를 변조한 공격인 ROP 공격과 점프(jump) 명령어를 변조한 공격인 JOP 공격으로 나눌 수 있다. A code reuse attack (CRA), unlike the existing code injection attack, continuously executes small code fragments (gadgets) existing in a normal program through successive execution flow modulations so that an attacker can execute desired code will be. In this case, it can be divided into an ROP attack that modifies a return instruction and a JOP attack that modifies a jump instruction depending on the type of execution branch instruction modulated by the attacker.

공개특허공보 제10-2014-0114433호Japanese Patent Application Laid-Open No. 10-2014-0114433

본 발명이 이루고자 하는 기술적 과제는, ROP 또는 JOP를 이용한 코드 재사용 공격을 용이하게 탐지할 수 있는 장치 및 그 방법을 제공하는 데 있다. SUMMARY OF THE INVENTION It is an object of the present invention to provide an apparatus and method capable of easily detecting a code reuse attack using ROP or JOP.

상기의 기술적 과제를 달성하기 위한, 본 발명에 따른 코드 재사용 공격 탐지 방법의 일 예는, 프로그램 내 호출 명령을 기 지정된 트램폴린 영역으로 분기하는 제1 점프 명령으로 대체하고, 상기 호출명령을 상기 트램폴린 영역으로 옮기고 상기 제1 점프 명령의 다음으로 분기하는 제2 점프 명령을 상기 트램폴린 영역에 생성하는 단계; 상기 프로그램의 함수 내에 상기 함수의 경계를 포함하는 함수 정보를 파악하는 코드를 추가하는 단계; According to another aspect of the present invention, there is provided a code reuse attack detecting method for replacing a program call command with a first jump command for branching to a designated trampoline region, Generating a second jump command to the trampoline region to branch to the next of the first jump command; Adding code for grasping function information including a boundary of the function in a function of the program;

상기 트램폴린 영역과 상기 함수 경계 파악 코드가 추가된 프로그램의 수행시 프로세서의 디버그 아키텍쳐를 통해 리턴을 포함하는 간접분기의 목적지 주소, 호출명령의 출발지 주소, 함수 경계를 포함하는 실행흐름정보를 파악하는 단계; 및 상기 실행흐름정보를 기초로 코드 재사용 공격을 탐지하는 단계;를 포함한다.Determining execution flow information including a destination address of an indirect branch including a return via the debug architecture of the processor when the program including the trampoline region and the function boundary identification code is added, ; And detecting a code reuse attack based on the execution flow information.

상기의 기술적 과제를 달성하기 위한, 본 발명에 따른 코드 재사용 공격 탐지 장치의 일 예는, 프로그램 내 호출 명령을 기 지정된 트램폴린 영역으로 분기하는 제1 점프 명령으로 대체하고, 상기 호출명령을 상기 트램폴린 영역으로 옮기고 상기 제1 점프 명령의 다음으로 분기하는 제2 점프 명령을 상기 트램폴린 영역에 생성하고, 상기 프로그램의 함수 내에 상기 함수의 경계를 포함하는 함수 정보를 파악하는 코드를 추가하는 코드구축부; 상기 트램폴린 영역과 상기 함수 경계 파악 코드가 추가된 프로그램의 수행시 프로세서의 디버그 아키텍쳐를 통해 리턴을 포함하는 간접분기의 목적지 주소, 호출명령의 출발지 주소, 함수 경계를 포함하는 실행흐름정보를 파악하는 PTM 분석부; 및 상기 실행흐름정보를 기초로 코드 재사용 공격을 탐지하는 CRA 탐지부;를 포함한다.According to an aspect of the present invention, there is provided an apparatus for detecting a code reuse attack, the apparatus comprising: a processor configured to replace a program call command with a first jump command that branches to a designated trampoline area, A code generating unit for generating a second jump instruction for branching to the next jump instruction in the trampoline area and adding code for grasping function information including a boundary of the function in the function of the program; A PTM for identifying execution flow information including a destination address of an indirect branch including a return, a source address of a call command, and a function boundary through a debug architecture of a processor when executing a program to which the trampoline region and the function boundary identification code are added; Analysis section; And a CRA detection unit for detecting a code reuse attack based on the execution flow information.

본 발명에 따르면, ROP 또는 JOP를 이용한 코드 재사용 공격을 용이하게 탐지할 수 있다. 또한, 하드웨어 모듈 기술과 소프트웨어 구축(instrumentation) 기술을 이용하여 성능 오버헤드를 줄이고 기존 모바일 기기에도 쉽게 적용할 수 있다. 다시 말해, 실질적인 코드 재사용 공격을 검출하는 하드웨어 모듈이 호스트 프로세서와 시스템 버스를 통해 연결되므로 기존 호스트 프로세서의 수정 없이 적용이 가능하고, 소프트웨어 구축 기술의 경우 하드웨어 모듈로 필요한 정보만을 추출해주므로 비교적 적은 오버헤드로 동작 가능하다.According to the present invention, a code reuse attack using ROP or JOP can be easily detected. In addition, using hardware module technology and instrumentation technology, performance overhead can be reduced and it can be easily applied to existing mobile devices. In other words, since a hardware module that detects a real code reuse attack is connected through a host processor and a system bus, it can be applied without modification of the existing host processor. In the software construction technology, only a necessary information is extracted by a hardware module, .

도 1은 본 발명에 따른 코드 재사용 공격 탐지를 위한 전반적인 구조의 일 예를 도시한 도면,
도 2는 본 발명에 따른 코드 재사용 공격을 탐지하는 방법의 일 예를 도시한 도면,
도 3은 본 발명에 따른 코드 재사용 공격 탐지를 위하여 프로그램을 새롭게 구축하는 방법의 일 예를 도시한 도면,
도 4는 본 발명에 따른 공격탐지장치의 일 실시 예의 구성을 도시한 도면,
도 5는 본 발명에 따른 도 4의 CRA 탐지부의 상세 구성의 일 예를 도시한 도면,
도 6은 본 발명에 따른 도 4의 결합부에 의해 두 개의 버퍼로부터 입력되는 신호를 결합하는 일 예를 도시한 도면, 그리고,
도 7은 본 발명에 따른 코드 재사용 공격 탐지 방법의 일 실시 예의 흐름을 도시한 도면이다.
1 is a diagram illustrating an example of an overall structure for detecting a code reuse attack according to the present invention;
FIG. 2 illustrates an example of a method for detecting a code reuse attack according to the present invention.
FIG. 3 illustrates an example of a method for newly constructing a program for detecting a code reuse attack according to the present invention.
FIG. 4 illustrates a configuration of an embodiment of an attack detection apparatus according to the present invention.
FIG. 5 illustrates an example of a detailed configuration of the CRA detection unit of FIG. 4 according to the present invention.
FIG. 6 is a diagram illustrating an example of combining signals input from two buffers by the combining unit of FIG. 4 according to the present invention,
7 is a flowchart illustrating a method of detecting a code reuse attack according to an embodiment of the present invention.

이하에서, 첨부된 도면들을 참조하여 본 발명에 따른 코드 재사용 공격 탐지 장치 및 그 방법에 대해 상세히 살펴본다.Hereinafter, an apparatus and method for detecting a code reuse attack according to the present invention will be described in detail with reference to the accompanying drawings.

도 1은 본 발명에 따른 코드 재사용 공격 탐지를 위한 전반적인 구조의 일 예를 도시한 도면이다.FIG. 1 is a diagram illustrating an example of an overall structure for detecting a code reuse attack according to the present invention.

도 1을 참조하면, ROP 또는 JOP를 이용한 코드 재사용 공격을 탐지하기 위한 공격탐지장치(110)는 SoC(System On-Chip) 플랫폼에 서브시스템으로 구현될 수 있다. 공격탐지장치(110)는 호스트 프로세서(100)와 시스템 버스(140)를 통해 연결되며, 또한 호스트 프로세서(100)의 디버그 아키텍쳐(108)와 직접 연결된다.Referring to FIG. 1, an attack detection apparatus 110 for detecting a code reuse attack using ROP or JOP may be implemented as a subsystem in a system on-chip (SoC) platform. The attack detection device 110 is connected to the host processor 100 through the system bus 140 and directly connected to the debug architecture 108 of the host processor 100.

호스트 프로세서(100), 메인 메모리(120), 메모리 컨트롤러(130) 등은 다양한 형태로 구현될 수 있다. 예를 들어, 호스트 프로세서로 ARM CPU가 사용될 수 있다. 이하 설명의 편의를 위하여 호스트 프로세서가 ARM CPU로 구현된 경우를 가정하여 설명한다. ARM CPU는 애플리케이션 프로그램을 수행하는 코어(102)와 디버그 아키텍쳐(108)인 PTM(Program Trace Macrocell)(104)과 TPIU(Trace Port Interface Unit)(106)를 포함한다. PTM(104) 및 TPIU(106)는 코어(102)에서 수행되는 프로그램의 분기 추적(branch trace)을 공격탐지장치(110)에게 제공한다. 디버그 아키텍쳐(108)가 프로그램의 분기 추적을 수행하는 종래의 다양한 방법이 존재하므로, 이에 대한 추가적인 설명은 생략한다. The host processor 100, the main memory 120, the memory controller 130, and the like may be implemented in various forms. For example, an ARM CPU can be used as the host processor. For convenience of explanation, it is assumed that the host processor is implemented as an ARM CPU. The ARM CPU includes a core 102 executing an application program, a debug trace architecture 108 a Program Trace Macrocell (PTM) 104, and a Trace Port Interface Unit (TPIU) 106. The PTM 104 and the TPIU 106 provide the attack tracer 110 with a branch trace of the program being performed in the core 102. There are various conventional methods by which the debug architecture 108 performs branch tracing of the program, so that a further explanation thereof will be omitted.

공격탐지장치(110)는 PTM 분석부(112) 및 CRA 탐지부(114)를 포함한다. 호스트 프로세서(100)에서 공격탐지장치(110)로 제공하는 정보의 양을 줄이기 위하여, TPIU(106)는 런타임 추적(runtime trace)을 고압축 형태로 공격탐지장치(110)에게 제공한다. PTM 분석부(112)는 디버그 아키텍쳐에 의해 파악된 각종 분기 추적 정보를 TPIU(106) 및 시스템 버스(140)로부터 각각 수신하여 압축해제하고 분석한 후 CRA 탐지부(114)에 전달한다. CRA 탐지부(114)는 분기 추적을 정제하여 코드 재사용 공격을 탐지한다. The attack detection apparatus 110 includes a PTM analysis unit 112 and a CRA detection unit 114. In order to reduce the amount of information provided to the attack detection device 110 from the host processor 100, the TPIU 106 provides a runtime trace to the attack detection device 110 in a high compression manner. The PTM analysis unit 112 receives and decompresses various branch tracking information obtained by the debug architecture from the TPIU 106 and the system bus 140, and transmits the analysis result to the CRA detection unit 114. The CRA detection unit 114 detects the code reuse attack by refining the branch trace.

도 2는 본 발명에 따른 코드 재사용 공격을 탐지하는 방법의 일 예를 도시한 도면이다.FIG. 2 is a diagram illustrating an example of a method for detecting a code reuse attack according to the present invention.

도 1 및 도 2를 참조하면, 호스트 프로세서(100)가 프로그램(200) 내 foo 함수를 호출한 경우에, foo 함수의 리턴 명령의 목적지 주소는 호출 명령인 call foo의 다음을 가리키는 것(210)이 정상이다. 만약 리턴 명령이 호출 명령인 call foo 다음이 아닌 다른 곳에 대한 목적지 주소를 가지고 있는 경우(220)에 ROP 공격이 있다고 할 수 있다. 1 and 2, when the host processor 100 calls the foo function in the program 200, the destination address of the return instruction of the foo function is the address 210 of the call instruction, call foo, This is normal. If the return command has a destination address other than the call command call foo (220), it can be said that there is an ROP attack.

따라서 ROP 공격을 탐지하기 위해서, 공격탐지장치(110)는 모든 호출 명령(call instruction)의 리턴 주소를 쉐도우 스택(shadow stack)이라 불리는 특별 스택에 복사하고, 쉐도우 스택의 꼭대기로부터 회수한 값과 각 리턴 명령의 목적지 주소를 비교한다. Therefore, in order to detect an ROP attack, the attack detection device 110 copies the return address of all call instructions to a special stack called a shadow stack, and stores the value recovered from the top of the shadow stack and each Compare the destination address of the return instruction.

ROP 공격과 달리, JOP 공격은 간접 점프 또는 호출을 이용하여 프로그램 내 코드조각들을 연결하여 공격자가 원하는 코드 시퀀스를 생성한다. 그러므로 JOP 공격은 스택에 저장된 리턴 값을 변경하는 대신에, 간접 분기나 점프의 목적지 주소를 공격자가 원하는 코드 시퀀스를 위한 코드조각들을 가리키는 값으로 변경한다. 일반적으로 정상 프로그램을 수행하는 경우에, 호출 함수의 목적지 주소는 함수 시작(function entry) 주소를 가리키고, 간접 분기의 목적지 주소는 명령어가 속한 함수 내의 주소를 가리킨다. 예를 들어, 도 2와 같이 간접 분기 명령어, inderect_jump의 목적지 주소가 함수 내(230)가 아니라, 함수 밖(240)을 가리키면 비이상적인 흐름이라고 판단한다. 따라서 JOP 공격을 탐지하기 위해서, 공격탐지장치(110)는 호출 명령의 목적지 주소, 간접 점프의 목적지 주소, 함수의 시작과 끝을 포함하는 함수 경계 등의 정보가 필요하다.Unlike an ROP attack, a JOP attack uses an indirect jump or call to connect code fragments in a program and generate an attacker's desired code sequence. Therefore, instead of changing the return value stored in the stack, the JOP attack changes the indirect branch or jump destination address to a value indicating the code fragments for the attacker's desired code sequence. In general, when performing a normal program, the destination address of the calling function points to the function entry address, and the destination address of the indirect branch points to the address in the function to which the command belongs. For example, as shown in FIG. 2, if the destination address of the indirect branch instruction, inderect_jump, indicates the out-of-function 240, not the in-function 230, it is determined to be a non-ideal flow. Therefore, in order to detect a JOP attack, the attack detection apparatus 110 needs information such as a destination address of a call instruction, a destination address of an indirect jump, and a function boundary including a start and an end of a function.

ROP 공격 및 JOP 공격을 모두 탐지하기 위하여 필요한 정보들을 정리하면 다음과 같다.The information needed to detect both ROP and JOP attacks is summarized as follows.

(1) 간접 분기(예를 들어, 간접 호출, 간접 점프, 리턴 등)의 목적지 주소(1) Destination address of an indirect branch (for example, indirect call, indirect jump, return, etc.)

(2) 호출 명령의 출발지 주소(Source address)(2) Source address of the call command

(3) 함수 경계(3) Function bounds

(4) 분기 명령을 분류하기 위한 분기 타입(4) Branch type for branch instruction classification

공격탐지장치(110)는 코드 재사용 공격 탐지를 위한 위 정보들 중 호스트 프로세서(100)의 디버그 아키텍쳐(108)를 통해 간접 분기의 목적지 주소 등을 용이하게 얻을 수 있으나, 다른 정보들을 용이하게 획득하기 어렵다. 본 실시 예는 위 정보들을 용이하게 얻기 위하여 프로그램 바이너리를 새롭게 구축하는 방법을 포함한다.The attack detection device 110 can easily obtain the destination address of the indirect branch or the like through the debug architecture 108 of the host processor 100 among the above information for detecting the code reuse attack, it's difficult. The present embodiment includes a method for newly building a program binary to easily obtain the above information.

도 3은 본 발명에 따른 코드 재사용 공격 탐지를 위하여 프로그램을 새롭게 구축하는 방법의 일 예를 도시한 도면이다.3 is a diagram illustrating an example of a method for newly constructing a program for detecting a code reuse attack according to the present invention.

도 3을 참조하면, 운영체제(OS) 커널에 의해 프로그램 바이너리(300)가 디스크나 메모리 등과 같은 로컬 저장소에 다운로드되어 저장되면, 공격탐지장치(110)는 간접 분기의 목적지 주소뿐만 아니라 호출 명령의 분기 타입과 출발지 주소 등을 파악하기 위하여 프로그램 바이너리를 새롭게 구축한 버전(instrumented version)(310)을 생성하여 저장한다. 3, when the program binary 300 is downloaded and stored in a local storage such as a disk or memory by the operating system (OS) kernel, the attack detection device 110 not only detects the destination address of the indirect branch, (Instrumented version) 310 in which a program binary is newly constructed in order to identify the type, the source address, and the like.

좀 더 상세히 살펴보면, 코드구축부(미도시)는 프로그램을 스캔하여 모든 함수 호출 명령어를 찾는다. 그리고 코드구축부는 원 프로그램 코드의 호출 명령을 간접 분기로 대체하고, 호출 명령을 기 지정된 저장공간(316)으로 옮긴다. 이하에서는 원 코드의 호출 함수 등이 옮겨지는 기 지정된 저장공간(316)을 트램폴린(trampoline)이라고 한다. 예를 들어, 본 실시 예의 경우에 함수 호출 명령어 "call foo"(302)는 트램폴린 영역(316)으로 옮겨지고 "call foo"가 존재하는 원 코드 상에는 트램폴린으로 옮겨진 "call foo"(320)로 분기하는 indrect_jump 명령어(312)가 위치한다. 트램폴린 공간(316)으로 옮겨진 호출 명령(320,324)은 원 코드 상에서 호출 명령이 가리키는 목적지 주소와 동일한 목적지 주소를 가리킨다. 코드구축부는 또한 트램폴린으로 옮겨진 호출 명령 다음에, 원 코드에서 호출 명령이 원래 존재하였던 곳(312)의 다음 주소로 이동할 수 있는 직접 분기(322,326)를 각 호출 명령(320,324) 다음에 포함한다. In more detail, the code builder (not shown) scans the program to find all function call instructions. Then, the code construction unit replaces the call instruction of the original program code with an indirect branch, and moves the call instruction to the pre-designated storage space 316. Hereinafter, the designated storage space 316 in which the call function of the original code is transferred is referred to as a trampoline. For example, in the case of the present embodiment, the function call command " call foo "302 is moved to the trampoline area 316 and on the original code with" call foo "Lt; RTI ID = 0.0 > 312 < / RTI > Call instructions 320 and 324, which are moved into the trampoline space 316, indicate the same destination address as the destination address indicated by the call instruction on the original code. The code builder also includes a direct branch (322, 326) after each call instruction (320, 324) that can be moved to the next address of where the call instruction originally existed in the original code, following the call instruction transferred to the trampoline.

명령어 하나의 메모리 크기가 4byte이고, 트램폴린(316)의 시작 위치의 주소가 A라고 하면, 트램폴린(316)에 옮겨진 첫 번째 호출 명령(call foo)(320)의 위치는 A이고, 두 번째 호출 명령(call bar)(324)의 주소는 A + 8byte(두 번째 호출 명령 앞에 두 개의 명령어(call foo, direct_jump)가 존재함)이다. 즉 n번째 호출 명령의 주소는 A+8*n이이고, 함수의 리턴 명령의 목적지 주소는 각 호출 함수의 다음인 A+8*n+4이다. 트램폴린(316)의 시작 위치를 알고 있으므로, 공격탐지장치(110)는 TPIU(106)로부터 수신한 목적지 주소를 단순히 체크하여 분기 명령의 타입을 쉽게 분류할 수 있다. If the memory size of one instruction is 4 bytes and the address of the start position of the trampoline 316 is A, then the position of the first call command (call foo) 320 transferred to the trampoline 316 is A, the address of the call bar 324 is A + 8 bytes (there are two commands (call foo, direct_jump) before the second call command). That is, the address of the nth call instruction is A + 8 * n, and the destination address of the return instruction of the function is A + 8 * n + 4, which is next to each call function. Since the start position of the trampoline 316 is known, the attack detection device 110 can easily classify the type of the branch instruction by simply checking the destination address received from the TPIU 106.

특히, 호출 명령의 경우에, 공격탐지장치(110)는 트램폴린으로의 간접 점프 뒤에 호출 명령의 목적지 주소를 TPIU(106)로부터 수신한다. 따라서 공격탐지장치(110)는 목적지 주소가 간접 점프에 뒤따라 오면, 분기 타입을 간접 호출이라고 간주하며, 그 외에는 직접 호출이라고 간주한다. 모든 호출은 새롭게 구축 프로그램 버전(도 3의 310)에서 간접 점프에 의해 가리키게 된다. A+8*n을 가리키는 간접 점프의 목적지 주소가 호출의 출발지 주소가 되므로, TPIU(106)로부터 수신한 간접점프의 목적지 주소를 기초로 각 호출의 출발지 주소를 얻을 수 있다. 그리고 ROP 탐지를 위해 쉐도우 스택(도 5의 532)에 유지할 필요가 있는 리턴 명령의 올바른 목적지 주소는 간접 점프의 목적지 주소 그 다음 주소이므로 이를 용이하게 파악할 수 있다. In particular, in the case of a paging command, the attack detection device 110 receives the destination address of the paging command from the TPIU 106 after an indirect jump to the trampoline. Thus, if the destination address follows an indirect jump, the attack detection device 110 regards the branch type as an indirect call, otherwise it is considered a direct call. All calls will be indicated by an indirect jump in the new build version (310 in FIG. 3). The source address of each call can be obtained based on the destination address of the indirect jump received from the TPIU 106 since the destination address of the indirect jump pointing to A + 8 * n becomes the source address of the call. And the correct destination address of the return instruction that needs to be maintained in the shadow stack (532 in FIG. 5) for ROP detection is the destination address and the next address of the indirect jump.

JOP 공격을 탐지하기 위하여, 공격탐지장치(110)는 각 함수의 경계 정보를 파악하는 코드(314)를 각 함수 내에 삽입한다. 본 실시 예의 경우, 함수 foo 내에 함수 경계를 파악하기 위한 store func_info 코드(314)를 추가한다. 함수 경계 정보를 파악하기 위한 코드(314)는 함수의 시작 주소와 크기를 시스템 버스(140)를 통해 하드웨어 모듈의 메모리 맵 주소(memory-mapped address)에 저장한다. 공격탐지장치(110)는 각 함수의 시작 위치와 크기 등을 ELF(Executable and linkable format)가 같은 실행 포맷(executable format)의 심볼 테이블을 참조하여 확인할 수 있다.In order to detect a JOP attack, the attack detection device 110 inserts code 314, which grasps boundary information of each function, in each function. In the case of this embodiment, a store func_info code 314 for grasping the function boundary is added to the function foo. The code 314 for grasping the function boundary information stores the start address and the size of the function in the memory-mapped address of the hardware module through the system bus 140. The attack detection apparatus 110 can confirm the start position and size of each function by referring to a symbol table of an executable format having the same ELF (executable and linkable format).

본 실시 에에서, 코드구축부는 공격탐지장치(110)의 일부 구성으로 구현되거나, 별도의 구성으로 구현될 수 있다. 또한, 코드구축부는 하드웨어 또는 소프트웨어 등 다양한 형태로 구현 가능하다. In this embodiment, the code construction unit may be implemented as a part of the attack detection apparatus 110, or may be implemented in a separate configuration. The code building unit can be implemented in various forms such as hardware or software.

도 4는 본 발명에 따른 공격탐지장치의 일 실시 예의 구성을 도시한 도면이다.4 is a diagram illustrating a configuration of an embodiment of an attack detection apparatus according to the present invention.

도 4를 참조하면, 공격탐지장치(110)는 PTM 분석부(112) 및 CRA 탐지부(420)를 포함하며, PTM 분석부(112)는 버퍼부(400) 및 추적부(410)를 포함한다.4, the attack detection apparatus 110 includes a PTM analysis unit 112 and a CRA detection unit 420. The PTM analysis unit 112 includes a buffer unit 400 and a tracking unit 410 do.

호스트 프로세서(100)의 디버그 아키텍쳐(108)를 이용하기 위하여, 버퍼부(400)는 디버그 아키텍쳐(108)의 출력 신호를 직접 수신한다. 예를 들어, 도 1을 참조하면, TPIU(106)의 출력신호는 버퍼부(400)로 직접 라우팅된다. 일반적으로 호스트 프로세서(100)가 다른 하드웨어 장치보다 더 빠르게 동작하므로, 버퍼부(400)는 TPIU(106)로부터 수신한 추적 정보를 임시 저장한다. 예를 들어, 버퍼부(400)는 FIFO(First In First Out) 타입의 비동기 버퍼(asynchronous buffer)로 구현될 수 있다. To use the debug architecture 108 of the host processor 100, the buffer portion 400 receives the output signal of the debug architecture 108 directly. For example, referring to FIG. 1, the output signal of the TPIU 106 is routed directly to the buffer unit 400. In general, since the host processor 100 operates faster than other hardware devices, the buffer unit 400 temporarily stores the tracking information received from the TPIU 106. For example, the buffer unit 400 may be implemented as a first-in first-out (FIFO) type asynchronous buffer.

추적부(410)는 버퍼부(400)에 저장된 분기 추적 정보를 분석하여 간접 분기 명령의 목적지 주소와 직접 분기의 방향을 파악한다. 이러한 분석 정보를 가지고, 추적부(410)는 호출의 분기 타입과 출발지 주소를 파악한다. 예를 들어, 프로그램 내 모든 호출 명령은 도 3과 같이 트램폴린 영역으로 옮겨져 있고, 트램폴린 내 각 호출 명령은 프로그램 코드 내 간접 분기에 의해 가리키도록 되어 있으므로, 추적부(410)는 간접 분기 뒤에 호출 명령의 목적지 주소가 따라오면 해당 분기의 타입을 간접 호출로 파악하고, 또한 간접 분기의 목적지 주소를 호출 명령의 출발지 주소로 파악한다. 추적부(410)는 각 타입과 분기 관련 정보(예를 들어, 호출의 출발지 주소와 간접 분기의 목적지 주소 등)를 CRA 탐지부(114)로 전달한다.The tracking unit 410 analyzes the branch tracking information stored in the buffer unit 400 to determine the destination address of the indirect branch instruction and the direct branch direction. With this analysis information, the tracking unit 410 grasps the branch type and origin address of the call. For example, since all the call commands in the program are moved to the trampoline area as shown in FIG. 3 and each call command in the trampoline is indicated by an indirect branch in the program code, The type of the branch is identified as an indirect call, and the destination address of the indirect branch is regarded as the start address of the call command. The tracking unit 410 transmits each type and branch related information (for example, a source address of a call and a destination address of an indirect branch, etc.) to the CRA detection unit 114.

도 5는 본 발명에 따른 도 4의 CRA 탐지부(114)의 상세 구성의 일 예를 도시한 도면이다.FIG. 5 is a diagram showing an example of the detailed configuration of the CRA detection unit 114 of FIG. 4 according to the present invention.

도 5를 참조하면, CRA 탐지부(114)는 두 개의 버퍼(500,502), 결합부(510), 검출제어부(520), 스택 관리자(530) 등을 포함한다. 5, the CRA detection unit 114 includes two buffers 500 and 502, a coupling unit 510, a detection control unit 520, a stack manager 530, and the like.

CRA 탐지부(114)는 호스트 프로세서(100)의 프로그램 실행을 추적할 뿐만 아니라 ROP와 JOP 공격을 모두 탐지할 수 있다. 코드 재사용 공격이 존재하는지 파악하기 위하여, CRA 탐지부(114)는 PTM 분석부(112)에 의해 제공되는 분기 정보와 시스템 버스(140)를 통해 입력되는 함수의 시작 주소 및 크기 정보를 이용한다. The CRA detection unit 114 not only tracks the program execution of the host processor 100, but can also detect both ROP and JOP attacks. The CRA detection unit 114 uses the branch information provided by the PTM analysis unit 112 and the start address and the size information of the function input through the system bus 140 in order to determine whether a code reuse attack exists.

제1 버퍼(500)는 TPIU(106)로부터 수신한 정보를 저장하고, 제2 버퍼(502)는 는 시스템 버스(140)로부터 수신한 정보를 저장한다. 제1 버퍼(500) 및 제2 버퍼(502) 모두 FIFO 버퍼로 구현될 수 있다. The first buffer 500 stores information received from the TPIU 106 and the second buffer 502 stores information received from the system bus 140. Both the first buffer 500 and the second buffer 502 may be implemented as FIFO buffers.

TPIU(106)로부터 수신되는 정보와 시스템 버스(140)로부터 수신되는 정보 사이에 수신 순서의 제한이 존재하지는 않는다. 다시 말해, CRA 탐지부(114)는 코드 재사용 공격을 탐지하기 위하여 필요한 간접 분기의 목적지 주소 등을 TPIU(106)로부터 수신하였으나, 아직 시스템 버스(140)로부터 함수의 경계 정보를 미수신한 경우가 발생할 수 있으며, 그 반대의 경우도 가능하다. 따라서 CRA 탐지부(114)는 애플리케이션의 원 프로그램 순서를 추적하기 위하여 TPIU 및 시스템 버스로부터 각각 수신되는 정보를 결합하고 재배열하는 과정을 결합부(510)를 통해 수행한다. There is no limitation of the reception order between the information received from the TPIU 106 and the information received from the system bus 140. [ In other words, when the CRA detecting unit 114 receives the destination address of the indirect branch necessary for detecting a code reuse attack from the TPIU 106 but has not yet received the boundary information of the function from the system bus 140 And vice versa. Therefore, the CRA detection unit 114 performs a process of combining and rearranging the information received from the TPIU and the system bus, respectively, in order to track the original program sequence of the application through the combining unit 510.

결합부(510)는 두 개의 버퍼(500,502)로부터 입력받은 추적 정보를 결합하고 원 프로그램의 수행 형태를 파악한다. 결합부(510)가 두 개의 버퍼로부터 입력되는 신호를 결합하는 일 예가 도 6에 도시되어 있다. The combining unit 510 combines the tracking information input from the two buffers 500 and 502 and grasps the execution mode of the original program. An example in which the combiner 510 combines the signals input from the two buffers is shown in FIG.

도 6을 참조하면, 애플리케이션이 시작되면, 프로그램 흐름은 처음 호출되는 함수(예를 들어, main())를 만난다. 최초 함수를 만나면 함수 경계 정보(F.B0) 등이 시스템 버스(140)를 통해 제2 버퍼(502)로 전달되고, 결합부(510)는 제2 버퍼(502)의 처음 호출되는 함수의 함수 경계 정보 등의 수신 사실을 통지받으면 동작을 시작한다(도 6의 F.B0(600)).Referring to FIG. 6, when an application is started, the program flow encounters a function to be called first (for example, main ()). The function boundary information F.B0 and the like are transmitted to the second buffer 502 through the system bus 140 and the combining unit 510 receives the function of the first function to be called of the second buffer 502 When it is notified of reception of boundary information and the like, the operation is started (F.B0 (600) of FIG. 6).

런타임에서, 프로그램은 호출 명령(예를 들어, 도 3의 call foo 등)을 만나면, 함수 프롤로그(function prologue)에서 함수 경계 정보를 수집하기 위한 코드(도 3의 314)가 수행되고, 분기 정보(분기 타입과 목적지 주소 등의 관련 정보)와 함수 경계 정보가 PTM 분석부(112)와 시스템 버스(140)로부터 각각 전달된다. 이러한 정보들을 포함하는 이벤트들이 도착되어 제1 버퍼(500) 또는 제2 버퍼(502)에 저장되면, 결합부(510)는 그것을 읽어 결합을 위한 동작을 수행한다. At runtime, when the program encounters a call instruction (e.g., call foo in FIG. 3), code (314 in FIG. 3) for collecting function boundary information in a function prologue is performed and branch information Related information such as the branch type and the destination address) and function boundary information are transmitted from the PTM analysis unit 112 and the system bus 140, respectively. When events including such information are received and stored in the first buffer 500 or the second buffer 502, the combining unit 510 reads the events and performs an operation for combining.

만약 함수 경계 정보(F.B1)(602)가 제2 버퍼(502)에 저장되면, 결합부(510)는 제1 버퍼(500)로부터 제2 버퍼(520)에 저장된 함수 경계 정보와 관련된 호출 등의 분기 정보에 관한 이벤트가 수신될 때까지 기다린다. 제1 버퍼(500)가 정보를 수신하면, 결합부(510)는 제1 버퍼(500)에 저장된 분기 관련 정보를 기초로 분기 타입(610)을 체크하고, 직접 또는 간접 호출이라면 결합부(510)는 두 버퍼(500,502)로부터 수신한 정보들(예를 들어, 분기 타입, 함수 경계 정보, 직접 호출을 위한 출발지 주소 등)(602와 610,616)을 결합한다. 그렇지 않다면, 제1 버퍼로부터 수신한 정보(612,618)만이 선택된다. 그리고 나서 정보들은 코드 재사용 공격의 존재에 대한 최종적인 판단을 수행하는 검출제어부(520)로 전달된다.If the function boundary information (F.B1) 602 is stored in the second buffer 502, the combining unit 510 receives a call related to the function boundary information stored in the second buffer 520 from the first buffer 500 And the like are received. When the first buffer 500 receives the information, the combining unit 510 checks the branch type 610 based on the branch-related information stored in the first buffer 500. If the first buffer 500 is a direct or indirect call, Combines the information (e.g., branch type, function boundary information, source address for direct call, etc.) (602 and 610, 616) received from the two buffers 500, 502. Otherwise, only information 612, 618 received from the first buffer is selected. The information is then transmitted to the detection control unit 520, which performs the final determination of the presence of a code reuse attack.

애플리케이션이 수행된 이후, 검출제어부(520)는 결합부(510)에 의해 공급되는 초기 호출 함수 정보를 기다린다. 정보를 수신하면, 검출제어부(520)는 피호출 함수(callee function)의 시작과 끝 주소(= 시작 주소 + 크기)를 계산하고 이를 FUNC_BOUNDS라 불리는 제1 레지스터(522)에 저장한다. After the application is executed, the detection control unit 520 waits for the initial call function information supplied by the combining unit 510. [ Upon receiving the information, the detection control unit 520 calculates the start and end addresses (= start address + size) of the callee function and stores it in the first register 522 called FUNC_BOUNDS.

이후 결합부(510)로부터 들어온 분기 타입이 또 다른 호출이면, 검출제어부(520)는 결합부(510)로부터 입력받은 또 다른 피호출 함수의 시작 주소와 크기를 획득한다. 예를 들어, 간접 호출인 경우에, 간접 호출의 목적지 주소가 검출제어부(520)에 의해 파악된 피호출 함수의 시작 위치와 맞지 않으면, 호출이 모르는 주소로 점프될 수 있음을 의미하며 이는 JOP 공격에 의해 보여지는 전형적인 행동이다. If the branch type coming from the combining unit 510 is another call, the detection control unit 520 obtains the start address and the size of another called function received from the combining unit 510. For example, in the case of an indirect call, if the destination address of the indirect call does not match the start position of the called function identified by the detection control unit 520, it means that the call can be jumped to an unknown address, Is a typical behavior seen by.

호출 명령이 직접 호출이거나 양호하다고 판명되면, 검출제어부(520)는 리턴 주소(출발지 주소 + 0x4)와 FUNC_BOUNDS를 쉐도우 호출 스택(532)으로 푸시한다. 쉐도우 호출 스택(532)은 호스트 프로세서(100)의 호출 스택의 쉐도우 복사본을 유지한다. FUNC_BOUNDS(522)가 스택(532) 안에 저장되는 이유는 피호출 함수가 추후 리턴될 때 그 값이 복구되어야 하기 때문이다. If the paging command is found to be a direct call or a good one, the detection control unit 520 pushes the return address (source address + 0x4) and FUNC_BOUNDS to the shadow call stack 532. The shadow call stack 532 maintains a shadow copy of the call stack of the host processor 100. The reason that FUNC_BOUNDS 522 is stored in stack 532 is that its value must be restored when the called function returns later.

검출제어부(520)는 쉐도우 호출 스택(532)으로의 푸시 이후 FUNC_BOUNDS(522)를 새롭게 계산된 피호출 함수의 시작위치와 끝 주소로 덮어쓴다. 함수가 리턴되면, 검출제어부(520)는 스택의 꼭대기 엔트리를 꺼내고 결합부(510)로부터 수신한 리턴 명령의 목적지 주소와 저장된 리턴 주소를 비교한다. 미스매치인 경우, 호스트 프로세서(100)의 스택의 리턴 주소가 ROP 공격에 의해 악의적으로 조작되었음을 의미하며, 검출제어부(520)는 인터럽트를 발생한다. The detection control unit 520 overwrites FUNC_BOUNDS 522 with the start and end addresses of the newly calculated called function after pushing to the shadow call stack 532. [ When the function is returned, the detection control unit 520 fetches the top entry of the stack and compares the return address of the return instruction received from the combining unit 510 with the stored return address. In the case of a mismatch, it means that the return address of the stack of the host processor 100 has been maliciously manipulated by an ROP attack, and the detection control unit 520 generates an interrupt.

결합부(510)로부터 수신한 리턴 명령의 목적지 주소와 쉐도우 호출 스택(532)에 저장된 리턴 주소가 일치하면, 검출제어부(520)는 FUNC_BOUNDS(522)를 쉐도우 호출 스택(532)으로부터 꺼낸 함수 경계 정보로 다시 쓴다. 간접 점프가 호스트 프로세서에서 발생한 경우에, 검출제어부(520)는 그 목적지 주소가 FUNC_BOUNDS(522)에 의해 참조되는 현 구동 함수의 시작과 끝 주소 내에 존재하는지 체크한다. 주소가 함수 경계의 바깥을 가리키면, 검출제어부(520)는 JOP 공격이 있다고 간주하고 동시에 이러한 공격을 호스트 프로세서(100)에게 알려주시기 위하여 인터럽트 신호를 발생한다. If the destination address of the return instruction received from the combining unit 510 matches the return address stored in the shadow call stack 532, the detection control unit 520 outputs the FUNC_BOUNDS 522 to the function boundary information I write it back. If an indirect jump occurs in the host processor, the detection control unit 520 checks whether the destination address is within the start and end addresses of the current drive function referenced by the FUNC_BOUNDS 522. When the address indicates the outside of the function boundary, the detection control unit 520 regards the JOP attack and simultaneously generates an interrupt signal to notify the host processor 100 of the attack.

쉐도우 호출 스택(532)은 유한 개수(예를 들어, 16 개)의 엔트리를 가진다. 그러므로 목적 애플리케이션이 내포 함수(nested function)를 16번 이상 호출한다면 오버플로우된다. 이러한 제한을 극복하기 위하여, 쉐도우 스택 관리자(530)가 존재한다.The shadow call stack 532 has a finite number of entries (e.g., 16). Therefore, if the destination application calls the nested function more than 16 times, it overflows. To overcome this limitation, a shadow stack manager 530 exists.

쉐도우 호출 스택(532)이 내포 함수에 의해 가득 채워지면, 스택 관리자(530)는 가장 오래된 8개의 엔트리를 AXI 인터페이스(560)를 통해 메모리(120)의 기 지정된 영역(이하, CRA 영역)(550)으로 복사한다. 그리고 VICTIM_ENTRY(534)라고 불리는 레지스터는 가장 최근 축출된 8개 엔트리를 임시 저장한다. When the shadow call stack 532 is filled by the containment function, the stack manager 530 accesses the oldest eight entries via the AXI interface 560 in a predefined area (hereinafter referred to as a CRA area) 550 of the memory 120 ). And a register called VICTIM_ENTRY 534 temporarily stores the eight most recently evicted entries.

게다가 동일한 함수가 반복하여 호출되는 예외적인 경우가 있을 수 있다. 이를 해결하기 위하여 검출제어부(520)는 카운터 값을 저장하는 제2레지스터(524)를 포함한다. 동일 함수가 일련으로 호출되면, 검출제어부(520)는 스택(532)에 어떤 값을 푸시함이 없이 제2 레지스터(524)의 카운터 값만 1 증가시킨다. 함수가 리턴되고 REC_CNT(524)가 0이 아닌 값이면, 검출제어부(520)는 스택(532)의 꼭대기 값을 읽는 대신에 제2 레지스터(524)의 카운터 값을 1씩 감소시킨다. In addition, there may be exceptional cases where the same function is called repeatedly. To solve this problem, the detection control unit 520 includes a second register 524 for storing a counter value. When the same function is called in a series, the detection control unit 520 increments only the counter value of the second register 524 by 1 without pushing any value to the stack 532. If the function is returned and the REC_CNT 524 is a non-zero value, the detection control unit 520 decrements the counter value of the second register 524 by one instead of reading the top value of the stack 532. [

도 7은 본 발명에 따른 코드 재사용 공격 탐지 방법의 일 실시 예의 흐름을 도시한 도면이다.7 is a flowchart illustrating a method of detecting a code reuse attack according to an embodiment of the present invention.

도 7을 참조하면, 공격탐지장치는 프로그램 내에서 호출 명령을 기 지정된 트램폴린 영역으로 분기하는 제1 점프 명령으로 대체하고, 호출명령을 트래폴린 영역으로 옮기고 또한 옮겨진 호출명령 다음에 제1 점프 명령의 다음으로 분기하는 제2 점프 명령을 생성한다(S700). 또한, 프로그램의 함수 내에 함수의 경계를 포함하는 함수 정보를 파악하는 코드를 추가한다(S700).Referring to FIG. 7, the attack detection apparatus replaces a call instruction in a program with a first jump instruction branching to a pre-designated trampoline area, moves the call instruction to the traffian area, Next, a second jump instruction to branch is generated (S700). In addition, a code for grasping the function information including the boundary of the function in the function of the program is added (S700).

공격탐지장치는 호스트 프로세서에 의해 프로그램이 실행될 때 프로세서의 디버그 아키텍쳐를 통해 리턴을 포함하는 간접분기의 목적지 주소, 호출명령의 출발지 주소, 함수 경계, 분기타입을 포함하는 분기 추적 정보를 파악한다(S710).When the program is executed by the host processor, the attack detection apparatus identifies the branch trace information including the destination address of the indirect branch including the return, the start address of the call instruction, the function boundary, and the branch type through the debug architecture of the processor (S710 ).

그리고 공격탐지장치는 분기 추적 정보를 기초로 코드 재사용 공격을 탐지한다(S720). The attack detection apparatus detects a code reuse attack based on the branch trace information (S720).

본 발명은 또한 컴퓨터로 읽을 수 있는 기록매체에 컴퓨터가 읽을 수 있는 코드로서 구현하는 것이 가능하다. 컴퓨터가 읽을 수 있는 기록매체는 컴퓨터 시스템에 의하여 읽혀질 수 있는 데이터가 저장되는 모든 종류의 기록장치를 포함한다. 컴퓨터가 읽을 수 있는 기록매체의 예로는 ROM, RAM, CD-ROM, 자기 테이프, 플로피디스크, 광데이터 저장장치 등이 있다. 또한 컴퓨터가 읽을 수 있는 기록매체는 네트워크로 연결된 컴퓨터 시스템에 분산되어 분산방식으로 컴퓨터가 읽을 수 있는 코드가 저장되고 실행될 수 있다.The present invention can also be embodied as computer-readable codes on a computer-readable recording medium. A computer-readable recording medium includes all kinds of recording apparatuses in which data that can be read by a computer system is stored. Examples of the computer-readable recording medium include ROM, RAM, CD-ROM, magnetic tape, floppy disk, optical data storage, and the like. The computer-readable recording medium may also be distributed over a networked computer system so that computer readable code can be stored and executed in a distributed manner.

이제까지 본 발명에 대하여 그 바람직한 실시예들을 중심으로 살펴보았다. 본 발명이 속하는 기술 분야에서 통상의 지식을 가진 자는 본 발명이 본 발명의 본질적인 특성에서 벗어나지 않는 범위에서 변형된 형태로 구현될 수 있음을 이해할 수 있을 것이다. 그러므로 개시된 실시예들은 한정적인 관점이 아니라 설명적인 관점에서 고려되어야 한다. 본 발명의 범위는 전술한 설명이 아니라 특허청구범위에 나타나 있으며, 그와 동등한 범위 내에 있는 모든 차이점은 본 발명에 포함된 것으로 해석되어야 할 것이다.The present invention has been described with reference to the preferred embodiments. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims. Therefore, the disclosed embodiments should be considered in an illustrative rather than a restrictive sense. The scope of the present invention is defined by the appended claims rather than by the foregoing description, and all differences within the scope of equivalents thereof should be construed as being included in the present invention.

Claims (8)

프로그램 내 호출 명령을 기 지정된 트램폴린 영역으로 분기하는 제1 점프 명령으로 대체하고, 상기 호출명령을 상기 트램폴린 영역으로 옮기고 상기 제1 점프 명령의 다음으로 분기하는 제2 점프 명령을 상기 트램폴린 영역에 생성하는 단계;
상기 프로그램의 함수 내에 상기 함수의 경계를 포함하는 함수 정보를 파악하는 함수 경계 파악 코드를 추가하는 단계;
상기 트램폴린 영역과 상기 함수 경계 파악 코드가 추가된 프로그램의 수행시 프로세서의 디버그 아키텍쳐를 통해 리턴을 포함하는 간접분기의 목적지 주소, 호출의 출발지 주소, 함수 경계를 포함하는 분기 추적 정보를 파악하는 단계; 및
상기 분기 추적 정보를 기초로 코드 재사용 공격을 탐지하는 단계;를 포함하고,
상기 재사용 공격을 탐지하는 단계는,
제1 버퍼에 상기 분기 추적 정보를 저장하는 단계;
제2 버퍼에 시스템 버스를 통해 수신한 함수 경계 정보를 저장하는 단계;
상기 제1 버퍼의 분기 추적 정보를 기초로 파악된 분기 타입이 직접 또는 간접 호출이면, 상기 분기 추적 정보와 상기 제2 버퍼의 함수 경계 정보를 결합하는 단계; 및
상기 분기 추적 정보와 상기 제2 버퍼의 함수 경계 정보의 결합 정보를 분석하여 코드 재사용 공격을 탐지하는 단계;를 포함하는 것을 특징으로 하는 공격 탐지 방법.
Program in the trampoline region by replacing the program call command with a first jump command for branching to a predefined trampoline region and transferring the call command to the trampoline region and branching to the next of the first jump command step;
Adding function boundary detection code for grasping function information including a boundary of the function in a function of the program;
Determining branch trace information including a destination address of an indirect branch, a source address of a call, and a function boundary including a return through a debug architecture of the processor when executing the program to which the trampoline region and the function boundary identification code are added; And
And detecting a code reuse attack based on the branch trace information,
Wherein the detecting the replay attack comprises:
Storing the branch trace information in a first buffer;
Storing function boundary information received through a system bus in a second buffer;
Combining the branch trace information and the function boundary information of the second buffer if the branch type identified based on the branch trace information of the first buffer is a direct or indirect call; And
And analyzing a combination of the branch trace information and the function boundary information of the second buffer to detect a code reuse attack.
제 1항에 있어서, 상기 분기 추적 정보를 파악하는 단계는,
리턴 명령의 목적지 주소와 호출의 출발지 주소를 비교하여 리턴 기반 프로그래밍 공격을 탐지하는 단계; 및
호출 명령의 목적지 주소, 간접 점프 명령의 목적지 주소, 함수 경계를 기초로 호출 명령의 목적지 주소가 함수의 시작 위치인지 여부 또는 함수 내 간접 점프가 함수 내에서 이루어지는 여부를 파악하여 점프 기반 프로그래밍 공격을 탐지하는 단계;를 포함하는 것을 특징으로 하는 공격 탐지 방법.
The method as claimed in claim 1,
Detecting a return-based programming attack by comparing a destination address of the return instruction with a source address of the call; And
Based on the destination address of the call instruction, the destination address of the indirect jump instruction, and the boundary of the function, it detects jump-based programming attacks by determining whether the destination address of the call instruction is the start position of the function or whether the indirect jump within the function occurs within the function The attack detection method comprising the steps of:
프로그램 내 호출 명령을 기 지정된 트램폴린 영역으로 분기하는 제1 점프 명령으로 대체하고, 상기 호출명령을 상기 트램폴린 영역으로 옮기고 상기 제1 점프 명령의 다음으로 분기하는 제2 점프 명령을 상기 트램폴린 영역에 생성하고, 상기 프로그램의 함수 내에 상기 함수의 경계를 포함하는 함수 정보를 파악하는 코드를 추가하는 코드구축부;
상기 트램폴린 영역과 함수 경계 파악 코드가 추가된 프로그램의 수행시 프로세서의 디버그 아키텍쳐를 통해 리턴을 포함하는 간접분기의 목적지 주소, 호출의 출발지 주소, 함수 경계를 포함하는 분기 추적 정보를 파악하는 PTM 분석부; 및
상기 분기 추적 정보를 기초로 코드 재사용 공격을 탐지하는 CRA 탐지부;를 포함하고,
상기 CRA 탐지부는,
상기 PTM 분석부로부터 수신한 분기 추적 정보를 저장하는 제1 버퍼;
시스템 버스를 통해 수신한 함수 경계 정보를 저장하는 제2 버퍼;
상기 제1 버퍼의 분기 추적 정보를 기초로 파악된 분기 타입이 직접 또는 간접 호출이면, 상기 분기 추적 정보와 상기 제2 버퍼의 함수 경계 정보를 결합하는 결합부; 및
상기 결합부의 정보를 분석하여 코드 재사용 공격을 탐지하는 검출 제어부;를 포함하는 것을 특징으로 하는 공격탐지장치.
Program in the trampoline area by replacing the program call command with a first jump command branching to a predefined trampoline area, moving the call command to the trampoline area, and branching to the next of the first jump command A code building unit for adding a code for grasping function information including a boundary of the function in a function of the program;
A PTM analysis unit for obtaining branch tracing information including a destination address of an indirect branch, a source address of a call, and a function boundary including a return through a debug architecture of a processor when executing a program to which the trampoline region and function boundary identification code are added; ; And
And a CRA detection unit for detecting a code reuse attack based on the branch trace information,
Wherein the CRA detection unit comprises:
A first buffer for storing branch trace information received from the PTM analyzer;
A second buffer for storing function boundary information received via the system bus;
A combining unit for combining the branch trace information and the function boundary information of the second buffer if the branch type identified based on the branch tracking information of the first buffer is a direct or indirect call; And
And a detection control unit for analyzing the information of the combining unit and detecting a code reuse attack.
삭제delete 제 3항에 있어서, 상기 검출제어부는,
함수가 호출되면, 피호출 함수의 시작과 끝 주소를 저장하는 제1 레지스터; 및
동일 함수가 반복 호출되는 경우에, 호출될 때마다 카운터 값을 1씩 증가하여 저장하고 리턴이 될 때마다 카운터 값을 1씩 감소하는 제2 레지스터;를 포함하고,
상기 검출제어부는 제1 레지스터에 저장된 함수의 시작과 끝 주소를 기초로 간접 분기의 목적지 주소가 함수 경계 밖인지를 파악하여 공격 여부를 탐지하는 것을 특징으로 하는 공격탐지장치.
The apparatus according to claim 3,
A first register for storing the start and end addresses of the called function when the function is called; And
And a second register for incrementing and storing the counter value by 1 every time the same function is repeatedly called and decrementing the counter value by 1 each time the counter value is returned,
Wherein the detection control unit detects whether the destination address of the indirect branch is out of the function boundary based on the start and end addresses of the function stored in the first register to detect whether the attack is an attack.
제 5항에 있어서,
함수가 호출될 때마다 상기 제1 레지스터의 값을 전달받아 저장하는 쉐도우 호출 스택;을 더 포함하고,
상기 검출제어부는 리턴 명령이 수행되면 상기 쉐도우 호출 스택의 꼭대기로부터 추출한 값과 리턴 명령의 목적지 주소를 비교하여 공격 여부를 판단하는 것을 특징으로 하는 공격탐지장치.
6. The method of claim 5,
And a shadow call stack for receiving and storing the value of the first register each time a function is called,
Wherein the detection control unit compares the value extracted from the top of the shadow call stack with a destination address of a return instruction when a return instruction is executed, and determines whether the attack is an attack.
제 6항에 있어서,
상기 쉐도우 호출 스택이 다 차면, 상기 쉐도우 호출 스택의 오래된 순으로 일부 값을 메모리의 특정 공간으로 복사하는 스택 관리자;를 더 포함하는 것을 특징으로 하는 공격탐지장치.
The method according to claim 6,
Further comprising: a stack manager for copying some values in the old order of the shadow call stack to a specific space in the memory when the shadow call stack is full.
제 1항에 기재된 방법을 수행하기 위한 프로그램을 기록한 컴퓨터로 읽을 수 있는 기록매체.A computer-readable recording medium on which a program for performing the method of claim 1 is recorded.
KR1020160131061A 2016-10-11 2016-10-11 Apparatus and method for detecting code reuse attack KR101851330B1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
KR1020160131061A KR101851330B1 (en) 2016-10-11 2016-10-11 Apparatus and method for detecting code reuse attack
SG10201701665SA SG10201701665SA (en) 2016-10-11 2017-03-02 Apparatus for and method of detecting code reuse attack (cra)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020160131061A KR101851330B1 (en) 2016-10-11 2016-10-11 Apparatus and method for detecting code reuse attack

Publications (2)

Publication Number Publication Date
KR20180039830A KR20180039830A (en) 2018-04-19
KR101851330B1 true KR101851330B1 (en) 2018-04-23

Family

ID=62087924

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020160131061A KR101851330B1 (en) 2016-10-11 2016-10-11 Apparatus and method for detecting code reuse attack

Country Status (2)

Country Link
KR (1) KR101851330B1 (en)
SG (1) SG10201701665SA (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102567924B1 (en) 2021-11-01 2023-08-17 부산대학교 산학협력단 System and Method for Protecting Indirect Call in WebAssembly
KR102544801B1 (en) * 2021-11-09 2023-06-20 한국과학기술원 Method and system to protecting against data-reuse attacks
CN114707143A (en) * 2022-03-15 2022-07-05 中国科学院信息工程研究所 Method and device for monitoring damage attack of memory data

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013228957A (en) 2012-04-26 2013-11-07 Nippon Telegr & Teleph Corp <Ntt> Control monitoring device, control monitoring method, and control monitoring program
JP2016115033A (en) * 2014-12-12 2016-06-23 富士通株式会社 Instruction execution controller and instruction execution control method
KR101658641B1 (en) 2015-06-12 2016-09-22 서울대학교산학협력단 Hardware-based detection of kernel code injection attack apparatus and method thereof

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013228957A (en) 2012-04-26 2013-11-07 Nippon Telegr & Teleph Corp <Ntt> Control monitoring device, control monitoring method, and control monitoring program
JP2016115033A (en) * 2014-12-12 2016-06-23 富士通株式会社 Instruction execution controller and instruction execution control method
KR101658641B1 (en) 2015-06-12 2016-09-22 서울대학교산학협력단 Hardware-based detection of kernel code injection attack apparatus and method thereof

Also Published As

Publication number Publication date
KR20180039830A (en) 2018-04-19
SG10201701665SA (en) 2018-05-30

Similar Documents

Publication Publication Date Title
US10242043B2 (en) Software security via control flow integrity checking
JP5459313B2 (en) Dynamic data flow tracking method, dynamic data flow tracking program, dynamic data flow tracking device
KR102306568B1 (en) Processor trace-based enforcement of control flow integrity in computer systems
US8117660B2 (en) Secure control flows by monitoring control transfers
US8316448B2 (en) Automatic filter generation and generalization
US8079084B1 (en) Virus co-processor instructions and methods for using such
US10102373B2 (en) Method and apparatus for capturing operation in a container-based virtualization system
US20100257608A1 (en) Apparatus and method for preventing virus code execution
US7854008B1 (en) Software-hardware partitioning in a virus processing system
US20160034687A1 (en) Transparent detection and extraction of return-oriented-programming attacks
US20060195724A1 (en) Method for determining code coverage
KR101851330B1 (en) Apparatus and method for detecting code reuse attack
JP2010238228A (en) Method and device for dynamically analyzing program
KR20080035564A (en) Changing code execution path using kernel mode redirection
US10311233B2 (en) Generic unpacking of program binaries
US8250544B2 (en) Annotating exception information in a computer program
US8336039B2 (en) Program, apparatus, and method of optimizing a Java object
CN111931191A (en) Dynamic detection method and system for binary software stack overflow leakage hole of Linux platform
US20080114971A1 (en) Branch history table for debug
US11663012B1 (en) Systems and methods for detecting coroutines
US8806448B2 (en) Dynamic instrumentation method and apparatus for tracing and analyzing a program
KR101947737B1 (en) Method and apparatus for explicit and implicit information flow tracking
CN108228239B (en) Branch instruction grabbing method and device based on quick simulator QEMU
JP4701611B2 (en) Memory management method for dynamic conversion emulators
US8839207B2 (en) Debugging extensible markup language

Legal Events

Date Code Title Description
E701 Decision to grant or registration of patent right
GRNT Written decision to grant