A multi-threaded program anomaly detection method based on system call sequence

Obtain thread-level system call information through instrumentation, and use Var-grams and hidden Markov models to build a behavior library for multi-thread programs, which solves the problem that existing technology cannot detect multi-thread program exceptions and realizes the behavior of multi-thread programs. Accurate representation and anomaly detection.

CN114201358BInactive Publication Date: 2024-08-30NANJING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111384841.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-22
Publication Date
2024-08-30
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing technology cannot effectively detect anomalies in multi-threaded programs, cannot accurately represent the behavior of multi-threaded programs, and the anomaly detection method of single-threaded programs is not suitable for multi-threaded environments.

Method used

Obtain thread-level system call information through instrumentation, use Var-grams algorithm to segment system call sequences, build a hidden Markov model, establish a behavior library for multi-threaded programs, and perform anomaly detection in real environments.

Benefits of technology

It achieves accurate representation and abnormality detection of multi-threaded program behavior, can accurately determine whether an abnormality occurs in a multi-threaded environment, and improves the accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114201358B
    Figure CN114201358B
Patent Text Reader

Abstract

The present invention proposes an abnormality detection active defense system for multi-threaded programs. The system detects whether an abnormality occurs in a program based on a system call sequence. The abnormality includes an abnormality caused by a vulnerability in the program itself and an abnormality caused by an external malicious attack. For a program, the system call sequence generated during its operation should be stable and in line with expectations. If the system call sequence generated by the program undergoes a huge change, it indicates that the function of the program has changed and an abnormality may occur in the program. Therefore, the system call sequence generated when the program is running can be used to represent the behavior of the program. However, for multi-threaded programs, due to the influence of thread scheduling, the system call sequence generated by a program running multiple times under the same input may be different, and it is impossible to accurately represent the behavior of the program. Therefore, the present invention is oriented to multi-threaded programs, shields the influence of thread scheduling on the system call sequence, and uses the thread-level system call sequence to detect the running status of the multi-threaded program in real time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of software security and anomaly detection, and detects multi-threaded programs based on thread-level system call sequences. Background Art

[0002] Most of the functions and services that a program needs to implement during operation, such as file reading and memory management, can only be implemented by the operating system. During the development process, the program uses library functions provided by various programming languages ​​to implement these functions, and these library functions are implemented directly or indirectly by calling system calls, that is, most of the functions that a program needs to implement are implemented by calling system calls. In order to implement a certain function of a program, the program often needs to call multiple system calls. The sequential execution of multiple system calls constitutes a sequence, namely the system call sequence. If the system call sequence has undergone major changes, it means that the functions implemented by the program may also have undergone major changes. Therefore, the system call sequence can be used to represent the behavior of the program.

[0003] The system call sequence generated by the program during operation can be captured through some system instructions or tools. For example, the Linux system provides the Ptrace instruction to obtain the system call sequence generated when the program is running. During the operation of a multi-threaded program, there are usually multiple threads executing concurrently. Over a period of time, the number of concurrent threads and the order of thread execution are often random and uncertain. Therefore, the system call sequence seen from the process level cannot distinguish the process to which each system call belongs. At the same time, due to the randomness of thread scheduling, the process-level system call sequence obtained from multiple runs of the same multi-threaded program under the same input may be different, and cannot accurately represent the behavior of the program. Although the execution order of threads is uncertain, the execution order of system calls in the same thread is fixed and can represent the behavior of the thread, so the behavior of the program can be abstracted based on the thread-level system call sequence.

[0004] Instrumentation technology refers to the technology of inserting some code segments into the program to collect information while ensuring the original logical integrity of the program and not changing the original function of the program. By instrumenting the program, the system call information when the program is running can be obtained, such as thread number, system call name, system call parameters, etc., so as to obtain the thread-level system call sequence.

[0005] Var-grams algorithm is a pattern extraction algorithm, which is an improvement of N-grams algorithm. The system call sequence generated by one run of the program is often very long, and pattern extraction is required to divide the long sequence into several short sequences. A short sequence represents a behavior of the program. The improvement of Var-grams algorithm compared to N-grams is that the length of the short sequences extracted by N-grams algorithm is fixed and the same, while the length of the short sequences obtained by Var-grams algorithm is not fixed. Therefore, the system call sequence obtained by Var-grams algorithm can better represent the behavior of the program.

[0006] Hidden Markov model is a statistical model used to describe a Markov process with hidden unknown parameters. Its common application is Chinese word segmentation. The process of extracting behaviors from the system call sequence generated by the actual program running is similar to the Chinese word segmentation process. The hidden Markov model is trained with the short system call sequence set obtained by the Var-grams algorithm to obtain the parameters of the hidden Markov model, so that the system call sequence obtained by the actual program running can be analyzed and the system call sequence can be divided into behavior sequences. Summary of the invention

[0007] The present invention mainly solves the deficiency that the prior art can only detect exceptions for single-threaded sequential programs, but cannot be applied to multi-threaded program exception detection, and proposes a multi-threaded program exception detection method based on system call sequence. The method proposed by the present invention extracts the system call sequence generated by thread operation from the perspective of thread level, more accurately represents the behavior of the thread, builds a behavior library of multi-threaded programs, and detects whether an exception occurs during the operation of the multi-threaded program.

[0008] In order to solve the above technical problems, the technical solution adopted by the present invention is: a multi-threaded program exception detection method based on system call sequence, comprising the following steps:

[0009] Step S1, instrumentation program

[0010] Use the instrumentation tool to instrument the program and obtain thread-level system call information, including thread number, system call name, system call number, etc. Thus, the system call sequences of various threads that were originally randomly mixed together can be extracted using the thread number as the index.

[0011] Step S2, obtaining a trusted thread-level system call sequence

[0012] In a safe and trusted environment, run the instrumented program multiple times, traverse all or most of the program's execution paths as much as possible, and obtain the system call sequence containing thread information generated when the program is running; disassemble the total system call sequence according to the thread number in the thread information to obtain the system call sequence generated when each thread is running.

[0013] Step S3, mining the behavior in the thread-level system call sequence

[0014] The thread-level system call sequence obtained in step S2 is segmented using the Var-grams algorithm. Each thread-level system call sequence is segmented into several short system call sequences of varying lengths. Each short system call sequence represents a behavior of the program. All short system call sequences are put into a set to construct a dictionary set of program behaviors.

[0015] Step S4, training a Hidden Markov Model (HMM)

[0016] The behavior dictionary obtained in step S3 is used as training data of the HMM model for supervised training to obtain various parameters of the HMM model; and a behavior library of the program is constructed.

[0017] Step S5: Obtaining the actual running behavior of the program

[0018] Similar to step S2, the thread-level system call sequences generated by the program running in the real environment are collected; the collected thread-level system call sequences are used as the input of the HMM model, the sequences are segmented, and the sequences are divided into several short system call sequences of different lengths, each of which represents a behavior of the program, thereby obtaining the behavior sequence of the actual running of the program.

[0019] Step S6: Anomaly detection

[0020] The detected behavior of the program during actual runtime is matched with the behavior in the behavior library, and whether an exception occurs in the program is determined based on the matching result. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0022] Figure 1 In the form of a system call sequence;

[0023] Figure 2 For trusted computing;

[0024] Figure 3 Extract behaviors for the Var-grams algorithm;

[0025] Figure 4 It is the exception detection process of multi-threaded programs based on system call sequence. DETAILED DESCRIPTION

[0026] The following will describe the implementation methods of the present invention in detail with reference to the accompanying drawings and embodiments, so that the implementation process of how the present invention applies technical means to solve technical problems and achieve technical effects can be fully understood and implemented accordingly.

[0027] Figure 1 The figure shows a sequence of system calls generated during the running of a program, which contains information such as the system call name, system call parameters, and system call return value. The traditional method of detecting program anomalies based on system call sequences is mainly for single-threaded sequential programs, which may not be suitable for anomaly detection of multi-threaded programs. In order to obtain the behavior of multi-threaded programs, it is necessary to obtain the caller (thread) information of the system call, so as to obtain the behavior of each thread.

[0028] Step S1, instrumentation program

[0029] In order to obtain the system call information when the program is running, you need to use the instrumentation tool to instrument the program. Program instrumentation means inserting code segments into the program while ensuring the original logic of the program and not changing the original functions. These code segments can detect the information when the program is running. For example, insert the detection code at the entrance of the system call. When the program calls the system call, the detection code can obtain the caller and the system call information, including the thread number, system call name, system call number and other information. In this way, the system call sequence of each thread that was originally randomly mixed together can be extracted with the thread number as the index.

[0030] Step S2, obtaining a trusted thread-level system call sequence

[0031] In order to learn the normal behavior of the program, the program needs to be placed in a safe and trusted environment. The so-called safe and trusted environment mainly means that the program will not be attacked by external attacks when running in this environment, or it can run normally even if attacked. Building a safe and trusted environment generally requires hardware support. Figure 2 The diagram shows the hierarchical relationship of trusted computing given by the Trusted Computing Group (TCG). In a secure and trusted environment, run the instrumented program multiple times, traverse all or most of the program's execution paths as much as possible, and obtain the system call sequence containing thread information generated when the program is running; disassemble the total system call sequence according to the thread number in the thread information to obtain the system call sequence generated when each thread is running.

[0032] Step S3, mining the behavior in the thread-level system call sequence

[0033] The thread-level system call sequence obtained in step S2 is segmented using the Var-grams algorithm. Each thread-level system call sequence is segmented into several short system call sequences of varying lengths. Each short system call sequence represents a behavior of the program. All short system call sequences are put into a set to construct a dictionary set of program behaviors. Figure 3 It shows how the Var-grams algorithm segments the system call sequence and extracts patterns. Each pattern is a short sequence after segmentation, and a pattern can represent a behavior of the program.

[0034] Step S4, training a Hidden Markov Model (HMM)

[0035] The behavior dictionary obtained in step S3 is used as training data of the HMM model for supervised training to obtain various parameters of the HMM model; and a behavior library of the program is constructed.

[0036] Step S5: Obtaining the actual running behavior of the program

[0037] Similar to step S2, the thread-level system call sequences generated by the program running in the real environment are collected; the collected thread-level system call sequences are used as the input of the HMM model, the sequences are segmented, and the sequences are divided into several short system call sequences of different lengths, each of which represents a behavior of the program, thereby obtaining the behavior sequence of the actual running of the program.

[0038] Step S6: Anomaly detection

[0039] The detected behavior of the program during actual runtime is matched with the behavior in the behavior library, and whether an exception occurs in the program is determined based on the matching result.

[0040] The multi-threaded program exception detection process based on system call sequence is as follows Figure 4 shown.

[0041] The above description shows and describes several preferred embodiments of the present invention, but as mentioned above, it should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the invention concept described herein through the above teachings or the technology or knowledge of the relevant field. Changes and variations made by those skilled in the art do not depart from the spirit and scope of the present invention, and should be within the scope of protection of the claims attached to the present invention.

Claims

1. A multi-threaded program exception detection method based on system call sequence, characterized in that: The steps include: Step S1, instrumentation program Use the instrumentation tool to instrument the program and obtain thread-level system call information, including thread number, system call name, system call number, etc., so that the system call sequences of various threads that were originally randomly mixed together can be extracted using the thread number as the index; Step S2, obtaining a trusted thread-level system call sequence In a safe and trusted environment, run the instrumented program multiple times, traverse all or most of the program's execution paths as much as possible, and obtain the system call sequence containing thread information generated when the program is running; The total system call sequence is disassembled according to the thread number in the thread information to obtain the system call sequence generated when each thread is running; Step S3, mining the behavior in the thread-level system call sequence The thread-level system call sequence obtained in step S2 is segmented using the Var-grams algorithm. Each thread-level system call sequence is segmented into a number of short system call sequences of varying lengths. Each short system call sequence represents a behavior of the program. All short system call sequences are put into a set to construct a dictionary set of program behaviors. Step S4, training a Hidden Markov Model (HMM) The behavior dictionary obtained in step S3 is used as training data of the HMM model for supervised training to obtain various parameters of the HMM model; a behavior library of the program is constructed; Step S5: Obtaining the actual running behavior of the program Similar to step S2, the thread-level system call sequences generated by the program running in the real environment are collected; the collected thread-level system call sequences are used as the input of the HMM model, the sequences are segmented, and the sequences are divided into several short system call sequences of different lengths, each of which represents a behavior of the program, thereby obtaining the behavior sequence of the actual running of the program; Step S6: Anomaly detection The detected behavior of the program during actual runtime is matched with the behavior in the behavior library, and whether an exception occurs in the program is determined based on the matching result.

Citation Information

Patent Citations

  • Self-organized mapping model based cloud software performance exception error diagnosis method and system

    CN105677572A

  • Multi-thread program plagiarism detection method based on dynamic birthmarks and related equipment

    CN112559978A