A Plugin Detection Method and System Based on Permission Graph Attention and Contrast Learning

By constructing a heterogeneous graph of plugin behavior and graph attention computation, and combining triplet contrastive learning to generate a normal behavior prototype library, the problems of high false alarm rate and insufficient adaptability in plugin security detection in the prior art are solved, and accurate identification and security protection of plugin behavior are achieved.

CN123114582APending Publication Date: 2026-11-17QUANZHOU RIRIYU NETWORK TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611496983.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-24
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing plugin security detection methods struggle to identify hidden malicious logic and dynamically generated behaviors during plugin runtime, and lack adaptive anomaly detection capabilities, resulting in a high false alarm rate and an inability to effectively protect the security of the development environment.

Method used

By constructing a heterogeneous graph of plugin behavior, combining plugin declaration permissions and graph attention calculation, and using triplet contrastive learning to generate a normal behavior prototype library, and adaptively setting anomaly judgment threshold, accurate identification and isolation processing of plugin behavior can be achieved.

Benefits of technology

It improves the ability to identify malicious behaviors such as unauthorized plug-ins, reduces the false alarm rate, adapts to the behavior distribution of plug-ins of different functional types, has the ability to trace the source of anomalies and handle them automatically, and is suitable for dynamic security protection in integrated development environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114582A_ABST
    Figure CN123114582A_ABST
Patent Text Reader

Abstract

This invention discloses a plugin detection method and system based on permission graph attention and contrastive learning, belonging to the field of software security detection technology. The specific steps of the method are as follows: collecting plugin runtime behavior data to generate event sequences, constructing a behavior heterogeneous graph and obtaining initial features of nodes and edges, calculating the constraint mask matrix and edge permission deviation by combining declared permissions, obtaining graph-level anomaly scores through graph attention, training with triple contrastive learning, clustering to generate a normal behavior prototype library, obtaining an adaptive threshold based on a generalized Pareto distribution, and realizing plugin anomaly judgment. This invention constructs a plugin behavior heterogeneous graph to model multi-dimensional runtime behavior, calculates anomaly scores by combining declared permissions and graph attention to identify unauthorized behavior, optimizes the encoder through triple contrastive learning, establishes a normal behavior prototype library by clustering, obtains an adaptive threshold by fitting a generalized Pareto distribution, outputs source tracing and linkage handling, and completes IDE plugin security detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software security detection technology, specifically to a plugin detection method and system based on permission graph attention and contrastive learning. Background Technology

[0002] With the continuous development of the integrated development environment (IDE) ecosystem, the number of various functional plugins is constantly increasing. Plugins can extend the capabilities of development tools and assist developers in completing various tasks such as code writing, project management, and tool integration, becoming an indispensable part of the development process. During operation, plugins have the ability to access local files, initiate network requests, and call system interfaces. If a plugin contains malicious logic, it can exploit runtime privileges to steal local project source code, leak sensitive configuration information, and establish illegal network connections, posing a serious security threat to development terminals and project data. Current development environment platforms mainly rely on manual review before deployment to manage plugin security. However, manual review cannot cover all dynamic behaviors during plugin operation. Some plugins disguised as normal tools can bypass the static review process and install themselves in the user's local environment to perform malicious operations. Therefore, conducting runtime security testing on IDE plugins and identifying abnormal behaviors that exceed their business requirements has become a real problem that needs to be solved in the field of development tool security.

[0003] Existing plugin security detection methods are mainly divided into two categories: static analysis and dynamic behavior analysis. Static analysis relies on parsing plugin source code and configuration files to perform rule matching, which makes it difficult to detect hidden malicious logic triggered only during runtime, and also fails to identify dynamically generated behaviors during operation. Traditional dynamic behavior analysis mostly performs statistical judgment on single behavioral events, severing the correlation between different behaviors and ignoring the data flow and call relationships between system calls, network access, and file operations, making it difficult to capture unauthorized attacks across behavioral chains. Some graph model detection solutions do not combine the plugin's own declared permissions for constraint calculation, uniformly using global behavior standards to evaluate all plugins. Plugins with different functional positioning have significantly different behavior patterns, which easily generates a large number of false positives. At the same time, most detection solutions use fixed thresholds to complete anomaly detection, which cannot adapt to the diverse behavioral distribution of plugins, lacks means to build benign behavior benchmarks, and the detection results lack corresponding alarm tracing and automated handling capabilities, making it difficult to directly implement in real integrated development environment protection scenarios. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of existing technologies by providing a plugin detection method and system based on permission graph attention and contrastive learning. This scheme collects various dynamic behavior data of plugins during runtime, converts them into behavior event sequences, constructs a heterogeneous plugin behavior graph, and initializes node and edge features. It parses the plugin configuration to obtain a set of declared permissions, calculates the constraint mask matrix and edge permission deviation, incorporates permission constraints into graph attention calculation, updates node features, and obtains node and graph-level anomaly scores. The graph network is optimized through triple contrastive learning, and a normal behavior prototype library is generated based on benign plugin clustering. An adaptive judgment threshold is obtained by fitting a distribution to complete plugin identification. The system includes modules for behavior acquisition, model calculation, and alarm handling, which can identify malicious behaviors such as unauthorized plugins, implement risk alarms and isolation processing, effectively reduce false alarms, and adapt to the dynamic security protection needs of plugins in the development environment.

[0005] To solve the above-mentioned technical problems, this invention provides the following technical solution: On one hand, a plugin detection method based on permission graph attention and contrastive learning, the specific steps of which are as follows:

[0006] S1 collects raw behavioral data of system calls, network communication, and file operations during the plugin's operation and converts them into a sequence of behavioral events.

[0007] S2, construct a heterogeneous graph of plugin behavior based on the sequence of behavioral events, calculate the encoding result of node behavior parameters as the initial feature vector of the node, and calculate the strength of node association as the initial weight of the edge.

[0008] S3, parse the plugin configuration file to obtain the set of declared permissions, and calculate the constraint mask matrix and edge permission deviation degree of the behavior heterogeneous graph based on the set of declared permissions. The edge permission deviation degree represents the degree to which the node interaction deviates from the declared permissions.

[0009] S4: Calculate graph attention weights based on heterogeneous graphs, constraint mask matrices, and edge permission deviations; update node features; calculate node anomaly scores and aggregate them into graph-level anomaly scores.

[0010] S5. Construct triplet samples and use triplet contrastive learning loss to update network parameters. After encoding the benign plug-in behavior graph, perform K-Means clustering to generate a normal behavior prototype library.

[0011] S6 calculates the minimum distance between the graph vector of the plugin under test and the normal behavior prototype library. The adaptive anomaly judgment threshold is obtained by estimating the generalized Pareto distribution parameters from the distance samples of benign plugins. The graph-level anomaly score is compared with the adaptive anomaly judgment threshold, and the plugin judgment result is output.

[0012] Furthermore, in S1, the behavior event is configured with four types of attribute fields; the first type of attribute field records the event type, and the selectable values ​​for the event type are limited to system call, network communication, and file operation; the second type of attribute field records the time of the event occurrence, which is directly obtained from the system clock, and the time unit is set to seconds; the third type of attribute field records the target object of the event, and the record content of the target object includes the API function name, the target IP address with the corresponding port number, and the complete file path; the fourth type of attribute field records the parameters carried by the event, and the record content of the parameters includes the input parameters of the system call, the HTTP request Uniform Resource Locator and request body content, and the operation mode corresponding to the file.

[0013] Furthermore, in S2, the plug-in behavior heterogeneous graph contains four types of nodes: the first type is API call nodes, whose node identifier is the system call function name; target objects with the same system call function name in the collected behavior event sequence are merged into the same API call node; the second type is data object nodes, whose node identifier is the variable name or memory data block identifier of the plug-in running in memory; the third type is network endpoint nodes, whose node identifier is a combination of IP address and port number; the fourth type is file resource nodes, whose node identifier is the complete file path; when the CodeBERT pre-trained model is used to encode the behavior event parameter fields, the dimension of the node output feature is set to 768.

[0014] Furthermore, in S2, the heterogeneous graph of plugin behavior includes three types of edges: the first type is the call edge, which connects the two ends of the call edge to two API call nodes that are executed sequentially; the second type is the data flow edge, which connects one end of the data flow edge to the node that generates the data and the other end of the data flow edge to the node that consumes the corresponding data; the third type is the resource access edge, which connects all nodes that access the same file or all nodes that access the same network endpoint; a sliding window is used to count the number of times each pair of nodes appears together, and the number of events in the window is fixed at 50 events.

[0015] Furthermore, in S3, the process of generating constraint mask matrix elements includes three types of comparison operations: the first type of comparison operation targets API call nodes, comparing whether the system call function corresponding to the API call node falls within the list of APIs allowed to be called as declared in the plugin configuration file; the second type of comparison operation targets network endpoint nodes, comparing whether the access address corresponding to the network endpoint node falls within the range of domain names and IP addresses allowed to be accessed as declared in the plugin configuration file; the third type of comparison operation targets file resource nodes, comparing whether the file path corresponding to the file resource node falls within the range of directories allowed to be read and written as declared in the plugin configuration file; each pair of nodes performs the corresponding type of comparison operation, and fills in the values ​​of the matrix elements corresponding to the constraint mask matrix based on the comparison results.

[0016] Furthermore, in S5, the training dataset is composed of a set of malicious plugin samples and a set of benign plugin samples. The sources of malicious plugin samples include publicly available malicious plugin sample libraries, vulnerability reports released by security organizations, and historical event handling records of enterprise security teams. Benign plugin samples are taken from plugins that have passed security audits in the VS-Code plugin market and JetBrains plugin market. For each plugin sample included in the training dataset, the following processes are executed in sequence: S1 raw behavior data collection and transformation, S2 plugin behavior heterogeneous graph construction, and S3 constraint mask matrix and edge permission deviation calculation. Each sample generates a corresponding plugin behavior heterogeneous graph, and all generated plugin behavior heterogeneous graphs are divided into the malicious plugin sample set or the benign plugin sample set.

[0017] Furthermore, in S5, the triplet sample consists of three parts: anchor sample, positive sample, and negative sample. When the anchor sample belongs to the behavior heterogeneous graph corresponding to a benign plugin, the positive sample is selected from the behavior heterogeneous graph generated by the same plugin under different collection time windows. When the anchor sample belongs to the behavior heterogeneous graph corresponding to a malicious plugin, the positive sample is selected from the behavior heterogeneous graph corresponding to another plugin instance that implements the same malicious behavior. The negative sample is a behavior heterogeneous graph whose category is different from the anchor sample. During the K-Means clustering execution phase, the clustering number is matched with the total number of functional categories corresponding to benign plugins within the training dataset.

[0018] Furthermore, in step S6, all benign plugins that have been installed and certified for security within the current development environment are extracted. The minimum distance between the graph vector corresponding to each benign plugin and the normal behavior prototype library is calculated one by one, and all minimum distances are used to construct a distance sample set. Quantile operations are performed on the constructed distance sample set, and the 90th percentile value obtained by the quantile operation is selected as the boundary value. Samples with values ​​greater than the boundary value in the distance sample set are filtered out, and the filtered samples are defined as tail samples. The Newton-Raphson iterative operation is used to perform iterative solution operations on the tail samples to solve for the shape parameters and scale parameters corresponding to the generalized Pareto distribution.

[0019] Furthermore, in S6, after the plugin determination result is output, subsequent processing is performed; if the plugin determination result is a malicious plugin, an alarm record is generated, and the alarm record content includes the overall abnormality score of the plugin, the node identifier corresponding to the abnormality, and the relevant record content of the node permission deviation; if the plugin determination result is a malicious plugin, isolation processing is performed for the plugin; if the plugin determination result is a benign plugin, plugin release processing is performed.

[0020] On the other hand, a plugin detection system based on permission graph attention and contrastive learning includes:

[0021] The behavior acquisition module is used to collect raw behavior data of system calls, network communication, and file operations during the operation of the plugin, and convert and output a sequence of behavior events.

[0022] The heterogeneous graph construction module is used to construct a heterogeneous graph of plugin behavior based on the sequence of behavioral events, and to calculate the initial feature vectors of nodes and the initial weights of edges.

[0023] The permission parsing and calculation module is used to parse the plugin configuration file to obtain the declared permission set and calculate the constraint mask matrix and the deviation of the edge permission.

[0024] The graph attention anomaly calculation module is used to combine heterogeneous graphs, constraint mask matrices, and edge permission deviations to calculate graph attention weights, update node features, and obtain node anomaly scores and graph-level anomaly scores.

[0025] The contrastive learning training module is used to construct triplet samples, update network parameters based on triplet contrastive learning loss, and perform K-Means clustering on benign plug-in graph encoding to generate a normal behavior prototype library.

[0026] The adaptive judgment module is used to calculate the minimum distance between the graph vector of the plugin under test and the normal behavior prototype library. It solves the adaptive anomaly judgment threshold based on the generalized Pareto distribution and outputs the plugin judgment result by combining the graph-level anomaly threshold.

[0027] The alarm handling module is used to perform alarm record generation, plugin isolation, or plugin release operations based on the plugin judgment results.

[0028] The behavior acquisition module includes a system call interception submodule, a network traffic mirroring submodule, and a file system monitoring submodule;

[0029] The system call interception submodule is used to capture various raw data of system calls generated during the operation of the plugin;

[0030] The network traffic mirroring submodule is used to obtain the raw network communication traffic data sent and received during the plugin execution process;

[0031] The file system monitoring submodule is used to collect raw data of file operations performed by the plugin on local files, including reading, writing, and modification.

[0032] Compared with existing technologies, this plugin detection method and system based on permission graph attention and contrastive learning has the following advantages:

[0033] I. This invention constructs a heterogeneous graph of plugin behavior to uniformly model the multi-dimensional runtime behavior of plugins. Different types of behavior, such as system calls, network interactions, and file access, are transformed into nodes and related edges in a graph structure, fully depicting the interaction logic and data flow relationships during plugin runtime. This overcomes the information gaps caused by relying solely on static code analysis or single-dimensional behavior statistics. By incorporating the declared permission information in the plugin configuration file, a constraint mask matrix and edge permission deviation are introduced. Permission violation features are embedded into the graph attention calculation process, allowing the model to focus on abnormal interaction behaviors that deviate from its declared permissions while learning behavior patterns, avoiding the model only learning general behavior features while ignoring the plugin's own permission boundaries. Relying on the graph attention mechanism, the calculation weights of different nodes and edges are adaptively allocated, strengthening the impact of abnormal interaction links on feature updates. This yields node and graph-level anomaly scores that reflect the degree of permission violations, improving the ability to identify hidden unauthorized behaviors and reducing misjudgment interference from legitimate behaviors.

[0034] Second, this invention optimizes the parameters of the graph encoder through triplet contrastive learning, narrowing the vector representation of similar plugin behavior graphs while widening the feature distance between samples of different categories. This results in learning discriminative plugin behavior graph vectors. A normal behavior prototype library is then constructed based on clustering of benign plugin samples, establishing a reference benchmark for benign plugin behavior. An adaptive anomaly detection threshold is solved by fitting a generalized Pareto distribution to the tail data of the distance samples, replacing the fixed threshold method. This adapts to the behavioral distribution differences of plugins with different functional types, avoiding the problem of threshold mismatch in multi-type plugin detection scenarios. After detection, anomaly tracing information is output synchronously, linking isolation and release processes. While identifying malicious plugins, it retains anomaly clues, balancing detection accuracy with practical handling capabilities, and adapting to the security detection business needs of plugins in integrated development environments.

[0035] Other advantages, objectives and features of the invention will be set forth in part in the description which follows, and in part will be apparent to those skilled in the art from the following examination or study, or may be learned from the practice of the invention. Attached Figure Description

[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.

[0037] Figure 1 This is a flowchart of a plugin detection method based on permission graph attention and contrastive learning.

[0038] Figure 2 This is a module architecture diagram of a plugin detection system based on permission graph attention and contrastive learning.

[0039] Figure 3 This is a schematic diagram of the internal components of the behavior acquisition module. Detailed Implementation

[0040] To further illustrate the technical means and effects of the present invention in achieving its intended purpose, the following detailed description of the specific implementation methods, structures, features, and effects of the present invention, in conjunction with the accompanying drawings and preferred embodiments, is provided below.

[0041] Example:

[0042] Reference Figure 1One embodiment of the present invention proposes a plugin detection method based on permission graph attention and contrastive learning. It adopts a data processing mechanism that constructs a heterogeneous graph of plugin behavior, integrates plugin declaration permission constraint mask and edge permission deviation, combines graph attention network and triple contrastive learning, and generates adaptive judgment threshold based on generalized Pareto distribution. It can accurately identify abnormal behavior of IDE plugins without relying on a large number of malicious plugin labeled samples, and complete alarm, isolation or release handling, so as to achieve high robustness and high confidence in the detection of malicious plugins.

[0043] The method described in this embodiment specifically includes:

[0044] Collect raw behavioral data of system calls, network communications, and file operations during the plugin's operation and convert them into behavioral event sequences;

[0045] Based on the sequence of behavioral events, construct a heterogeneous graph of plugin behavior, calculate the encoding results of node behavior parameters as the initial feature vector of the node, and calculate the strength of node association as the initial weight of the edge.

[0046] Parse the plugin configuration file to obtain the set of declared permissions. Calculate the constraint mask matrix and edge permission deviation degree on the behavior heterogeneous graph using the set of declared permissions. The edge permission deviation degree represents the degree to which node interactions deviate from the declared permissions.

[0047] Graph attention weights are calculated based on heterogeneous graphs, constraint mask matrices, and edge permission deviations. Node features are updated, node anomaly scores are calculated, and aggregated into graph-level anomaly scores.

[0048] Construct triplet samples and use triplet contrastive learning loss to update network parameters. After encoding the benign plug-in behavior graph, perform K-Means clustering to generate a normal behavior prototype library.

[0049] Calculate the minimum distance between the graph vector of the plugin under test and the normal behavior prototype library. Estimate the generalized Pareto distribution parameters from the distance samples of benign plugins to obtain the adaptive anomaly judgment threshold. Compare the graph-level anomaly score with the adaptive anomaly judgment threshold and output the plugin judgment result.

[0050] Specifically, the technical principle of this invention lies in constructing a permission-constrained heterogeneous graph representation and contrastive learning detection system.

[0051] The system first collects system calls, network communications, and file operations during the operation of the IDE plugin sandbox, and converts the raw behavioral data into a standardized sequence of behavioral events. Then, it constructs a heterogeneous graph of plugin behavior containing multiple types of nodes and edges. The initial features of the nodes are obtained by encoding the behavioral event parameters through the CodeBERT pre-trained model, and the initial weights of the edges are calculated by combining the co-occurrence count and the time decay factor with the sliding window statistics.

[0052] Next, the plugin configuration file is read and parsed to obtain the set of permissions declared by the plugin. A binary constraint mask matrix is ​​generated based on the set of declared permissions. The edge permission deviation degree corresponding to each edge is further calculated to quantify the severity of the interaction behavior between nodes exceeding the plugin's declared permissions.

[0053] The constraint mask matrix and edge permission deviation are introduced into the graph attention weight calculation process. In the attention calculation stage, a permission deviation adjustment coefficient is introduced so that the edge that violates the declared permission contributes more to the feature update of the neighboring node. The node feature is iteratively updated, the node anomaly score is calculated for each node, and then all node anomaly scores are aggregated to obtain the graph-level anomaly score of the entire behavior graph.

[0054] During the training phase, triplet samples are constructed, and all learnable parameters of the graph network are optimized by relying on the triplet contrastive learning loss. The behavior graphs corresponding to benign plugins in the training set are encoded into graph vectors, and K-Means clustering is performed to obtain cluster centers, thereby constructing a normal behavior prototype library.

[0055] During the online detection phase, the distance sample set of certified benign plugins is extracted, the tail portion of the sample is truncated, and the shape and scale parameters of the generalized Pareto distribution are solved by Newton-Raphson iteration. Combined with the preset target false alarm rate, the adaptive anomaly judgment threshold is calculated. The graph-level anomaly score of the plugin under test is compared with the adaptive anomaly judgment threshold, and the plugin judgment result is output. Then, based on the judgment result, alarm record generation, plugin isolation or plugin release operations are completed.

[0056] By employing a complete closed-loop processing approach, including behavioral graph modeling, declaring permission constraints, graph attention networks, contrastive learning, and adaptive thresholding based on generalized Pareto distribution, we can achieve malicious behavior detection for online IDE plugins, reduce false positives, and improve detection confidence.

[0057] Optionally, the process of collecting system calls, network communications, and file operations during the operation of the acquisition plugin and converting them into a sequence of behavioral events includes:

[0058] Deploy a system call interception submodule in the plugin process space of the integrated development environment, and deploy a network traffic mirroring submodule and a file system monitoring submodule in the sandbox. Set the collection duration T, with the value of T ranging from 60 seconds to 600 seconds, to capture the raw behavioral data of system calls, network communication, and file operations generated during the plugin's operation.

[0059] For each captured raw behavioral data point, four attribute fields are extracted, and the data is converted into standardized behavioral events. A sequence of behavioral events is then assembled from all the captured events, such as... Figure 3 As shown.

[0060] Specifically, the system call interception submodule is deployed in the IDE plugin process space to intercept all system call behaviors initiated by the plugin process; the network traffic mirroring submodule and the file system monitoring submodule are deployed in an isolated sandbox environment. The sandbox environment is used to host the plugin under test and prevent malicious plugins from damaging the host environment. The collection duration T can be configured according to the complexity of the plugin's business. For lightweight plugins, T=60 seconds is set, and for plugins with complex functions and slow behavior triggering, T=600 seconds is set.

[0061] The behavior event has four types of attribute fields. The first attribute field records the event type, which is limited to system call, network communication, and file operation. The second attribute field records the event occurrence time, which is obtained directly from the system clock in seconds. The third attribute field records the target object of the event, including the API function name, target IP address with corresponding port number, and complete file path. The fourth attribute field records the parameters carried by the event, including the input parameters of the system call, the HTTP request Uniform Resource Locator and request body content, and the operation mode of the file.

[0062] Mathematical expression for behavioral event sequence:

[0063]

[0064] In the formula, A set of sequences of behavioral events; For the first A behavioral event; This represents the total number of behavior events; each behavior event includes the type, timestamp, target, and params attribute fields.

[0065] Optionally, the step of constructing a heterogeneous graph of plugin behavior based on the sequence of behavioral events, calculating the encoding results of node behavior parameters as the initial feature vector of the node, and calculating the strength of node association as the initial weight of the edge includes:

[0066] Define the heterogeneous graph of plugin behavior , R represents the set of nodes, and R represents the set of node types. Represents a set of edges; node types are set to API call nodes, data object nodes, network endpoint nodes, and file resource nodes; edge types are set to call edges, data stream edges, and resource access edges.

[0067] Set a sliding window with a fixed number of 50 events, traverse the sequence of behavioral events, count the number of times each pair of nodes appears together, and calculate the initial weight of the edge by combining the average time interval of the behavioral events and the time interval decay coefficient.

[0068] Specifically, the plugin behavior heterogeneous graph contains four types of nodes: the first type is API call nodes, which are identified by the system call function name. Target objects with the same system call function name appearing in the collected behavior event sequence are merged into the same API call node; the second type is data object nodes, which are identified by the variable name or memory data block identifier of the plugin running in memory; the third type is network endpoint nodes, which are identified by the combination of IP address and port number; and the fourth type is file resource nodes, which are identified by the complete file path. When using the CodeBERT pre-trained model to encode behavior event parameter fields, the dimension of the node output features is set to 768.

[0069] The heterogeneous graph of plugin behavior contains three types of edges: the first type is the call edge, which connects the two ends of the call edge to two API call nodes that are executed sequentially; the second type is the data flow edge, which connects one end of the data flow edge to the node that generates the data and the other end of the data flow edge to the node that consumes the corresponding data; the third type is the resource access edge, which connects all nodes that access the same file or all nodes that access the same network endpoint.

[0070] Mathematical expression for the initial feature vector of a node:

[0071]

[0072] In the formula, For nodes The initial feature vector; For nodes A subset of the associated behavioral events; This is the time decay coefficient; The end timestamp of the data collection time window For pre-trained word embedding functions; Parameters carried by the behavioral event; For the natural constant An exponential function with base 0.05. Mathematical expression for initial edge weights:

[0073]

[0074] In the formula, For nodes With nodes The initial weights of the edges between them; For nodes , The number of times they appear together; The total number of behavioral events; This is the time interval decay coefficient; For nodes , The average time interval between related behavioral events.

[0075] Optionally, the parsing of the plugin configuration file yields a set of declared permissions, and the constraint mask matrix and edge permission deviation are calculated from the set of declared permissions on the behavioral heterogeneous graph, including:

[0076] Read the plugin configuration file; for the VS-Code plugin, read package.json; for the JetBrains plugin, read plugin.xml. Parse the configuration file content to obtain the set of declared permissions; complete the process of generating constraint mask matrix elements; and perform three-class comparison operations.

[0077] The first type of comparison operation targets API call nodes, comparing whether the system call function corresponding to the API call node falls within the list of APIs allowed to be called as declared in the plugin configuration file;

[0078] The second type of comparison operation targets network endpoint nodes, comparing whether the access address corresponding to the network endpoint node falls within the range of domain names and IP addresses allowed to be accessed as declared in the plugin configuration file;

[0079] The third type of comparison operation targets file resource nodes, comparing whether the file path corresponding to the file resource node falls within the directory range that is allowed to be read and written as declared in the plugin configuration file; the above-mentioned corresponding type of comparison operation is performed on each pair of nodes, and the values ​​of the matrix elements corresponding to the constraint mask matrix are filled in according to the comparison results.

[0080] Based on the constraint mask matrix, the number of times nodes co-occur, the initial weight of edges, and the arithmetic mean of the initial weights of all edges, calculate the edge permission deviation degree corresponding to each edge in the heterogeneous graph.

[0081] Specifically, declare the mathematical expression for the permission set:

[0082]

[0083] In the formula, To declare a set of permissions; For the first The identifier for the item's declared permissions; This represents the total number of entries declaring permissions. The generation dimension is... Binary constraint mask matrix Mathematical expressions for the elements of the mask matrix: In the formula, For the constraint mask matrix, the first Line 1 Column matrix elements; , For nodes within a heterogeneous graph of plugin behavior; To declare the permission set; perform operation and permission whitelist comparison processing for API call nodes, network endpoint nodes, and file resource nodes respectively.

[0084] Mathematical expression for edge permission deviation:

[0085]

[0086] In the formula, For nodes , Permission deviation between edges; To constrain the matrix elements of the mask matrix; For nodes , The number of times they appear together; Set the initial weights for the edges; The initial weights of all edges are the arithmetic mean. ; This represents the total number of edges.

[0087] Optionally, the step of calculating graph attention weights based on heterogeneous graphs, constraint mask matrices, and edge permission deviations, updating node features, calculating node anomaly scores, and aggregating them into graph-level anomaly scores includes: determining nodes The set of direct neighbor nodes The edge permission deviation is introduced into the attention calculation to solve the graph attention weight; the graph attention weight is used to perform weighted aggregation of the features of neighboring nodes, and the updated node feature vector is obtained through the ELU activation function; the updated node feature vector, the normal behavior of the corresponding node type as the center vector, the average permission deviation of the node, and the frequency of node behavior events are combined to calculate the node anomaly score corresponding to each node; the graph-level anomaly score is obtained by aggregating all node anomaly scores.

[0088] Specifically, the mathematical expression for graph attention weights is:

[0089]

[0090] In the formula, For nodes For neighboring nodes Attention weights; It is a learnable linear transformation matrix; A learnable attention vector; This represents vector concatenation operations; It is a linear unit activation function with leakage correction, and the slope in the negative interval is greater than 0; This is the adjustment coefficient for permission deviation. The deviation of the edge permission; For nodes The set of neighboring nodes.

[0091] Mathematical expression for node feature update:

[0092]

[0093] In the formula, For nodes The updated feature vector; It is the activation function for the exponential linear unit; For nodes The set of neighboring nodes; For graph attention weights; It is a learnable linear transformation matrix; For neighboring nodes The initial eigenvectors.

[0094] Mathematical expression for node anomaly scoring:

[0095]

[0096] In the formula, For nodes Node anomaly scoring; represent Norm; For nodes The updated feature vector; Represents a node Type identifier, Represents a node The center vector of normal behavior for the node type; For nodes Average permission deviation; when hour, ;when hour, ; This is the deviation enhancement coefficient; This is the frequency enhancement coefficient for behavior. For nodes Frequency of occurrence of related behavioral events; This represents the maximum frequency of all node behavior events.

[0097] Mathematical expression for graph-level anomaly scoring:

[0098]

[0099] In the formula, For graph-level anomaly scoring; This represents the total number of nodes in the heterogeneous graph. Score node anomalies; This is the weighting coefficient for the maximum anomaly score; This represents the maximum value of the anomaly scores for all nodes.

[0100] Optionally, the step of constructing triplet samples and updating network parameters using triplet contrastive learning loss, encoding benign plug-in behavior graphs, and then performing K-Means clustering to generate a normal behavior prototype library includes:

[0101] A training dataset is constructed, consisting of a set of malicious plugin samples and a set of benign plugin samples. The sources of malicious plugin samples include publicly available malicious plugin sample libraries, vulnerability reports released by security organizations, and historical incident handling records of enterprise security teams. Benign plugin samples are taken from plugins that have passed security audits in the VSCode plugin marketplace and JetBrains plugin marketplace. For each plugin sample included in the training dataset, the following steps are performed in sequence: S1 raw behavior data collection and transformation processing, S2 plugin behavior heterogeneous graph construction processing, and S3 constraint mask matrix and edge permission deviation calculation processing. Each sample generates a corresponding plugin behavior heterogeneous graph, and all generated plugin behavior heterogeneous graphs are divided and assigned to either the malicious plugin sample set or the benign plugin sample set.

[0102] Encode a single behavioral heterogeneous graph, calculate the mean of the feature vectors after all nodes are updated, and extract the graph-level representation vector;

[0103] Construct triplet samples , For anchor samples, As a positive sample, For negative samples, when the anchor sample belongs to the behavior heterogeneous graph corresponding to a benign plugin, the positive sample is the behavior heterogeneous graph generated by the same plugin under other different collection time windows; when the anchor sample belongs to the behavior heterogeneous graph corresponding to a malicious plugin, the positive sample is the behavior heterogeneous graph corresponding to other plugin instances that implement the same malicious behavior; the negative sample is the behavior heterogeneous graph with a category different from the anchor sample; the network parameters are updated using triplet contrastive learning loss; after the network parameters converge, the map representation vectors corresponding to all benign plugins in the training set are extracted, and K-Means clustering is performed. The number of K-Means clusters is matched with the total number of functional categories corresponding to benign plugins in the training dataset. The cluster center vectors obtained by clustering together constitute the normal behavior prototype library.

[0104] Specifically, the mathematical expression for a graph-level vector is:

[0105]

[0106] In the formula, Behavioral diagram Graph-level representation of vectors; This represents the total number of nodes in the heterogeneous graph. The feature vector after node update. Mathematical expression for the triplet contrastive learning loss function:

[0107]

[0108] In the formula, The loss is for contrastive learning of triples; Represents the square of the L2 distance; , , The graph-level representation vectors are, in order, anchor samples, positive samples, and negative samples; This is the interval parameter.

[0109] Optionally, the step of calculating the minimum distance between the graph vector of the plug-in to be tested and the normal behavior prototype library, estimating the generalized Pareto distribution parameters from the distance samples of benign plug-ins to obtain the adaptive anomaly judgment threshold, comparing the graph-level anomaly score with the adaptive anomaly judgment threshold, and outputting the plug-in judgment result includes:

[0110] Extract all benign plugins that have been installed and certified for security within the current development environment, calculate the minimum distance between the graph vector corresponding to each benign plugin and the normal behavior prototype library, and construct a distance sample set from all the minimum distances.

[0111] Perform quantile operations on the completed distance sample set, and select the 90th percentile value obtained from the quantile operation as the boundary value; filter the samples in the distance sample set whose values ​​are greater than the boundary value, and define the filtered samples as tail samples.

[0112] The Newton-Raphson iterative calculation method is used to construct the log-likelihood function of the generalized Pareto distribution, and iterative calculation is performed on the tail samples to solve the shape parameters and scale parameters corresponding to the generalized Pareto distribution.

[0113] Substitute the distribution parameters and the preset target false alarm rate to calculate the adaptive anomaly detection threshold;

[0114] Compare the graph-level anomaly score of the plugin under test with the adaptive anomaly judgment threshold, and output the plugin judgment result.

[0115] Specifically, the mathematical expression for minimum distance is:

[0116]

[0117] In the formula, Minimum distance; The graph-level vector of the behavior graph of the plugin under test; The first in the normal behavior prototype library Cluster center vectors; The total number of cluster centers for the normal behavior prototype library; This represents the L2 norm.

[0118] Mathematical expression of the cumulative distribution function of the generalized Pareto distribution:

[0119]

[0120] In the formula, The cumulative distribution function of the generalized Pareto distribution; It is a distance random variable; The shape parameter of the generalized Pareto distribution; It is the 90th percentile of the distance to the sample set; This is the scaling parameter for the generalized Pareto distribution.

[0121] Mathematical expression of the log-likelihood function of the generalized Pareto distribution:

[0122]

[0123] In the formula, It is the log-likelihood function; This represents the total number of tail samples; For natural logarithm operations; Tail sample offset ; The shape parameter of the generalized Pareto distribution; This is the scaling parameter for the generalized Pareto distribution.

[0124] Mathematical expression for adaptive anomaly detection threshold:

[0125]

[0126] In the formula, An adaptive anomaly detection threshold; It is the 90th percentile of the distance to the sample set; The scaling parameter of the generalized Pareto distribution; The shape parameter of the generalized Pareto distribution; For the purpose

[0127] Label the false alarm rate, and .

[0128] Mathematical expression for the discriminant:

[0129] Judgment result

[0130] In the formula, For graph-level anomaly scoring; This is the adaptive anomaly detection threshold.

[0131] Optionally, the subsequent processing performed after the output plugin determination result includes:

[0132] If a plugin is determined to be a malicious plugin, an alarm record is generated. The alarm record includes the plugin's overall anomaly score, the node identifier corresponding to the anomaly, and the relevant record of the node's permission deviation.

[0133] If a plugin is determined to be a malicious plugin, isolation measures will be taken for that plugin.

[0134] If the plugin is determined to be a benign plugin, the plugin will be allowed to proceed.

[0135] Specifically, when a plugin is identified as malicious, the system generates a complete alarm log. The alarm log saves the plugin ID, plugin name, graph-level anomaly score, the node identifier that triggered the anomaly, and the permission deviation record of the corresponding node, which is convenient for security operations personnel to backtrack and analyze. Isolation processing refers to terminating the plugin process, uninstalling the plugin, blocking the plugin's network access permissions, and prohibiting the plugin from reading and writing local files. When a plugin is identified as benign, it is allowed to run normally in the IDE environment.

[0136] Based on the same inventive concept, and referring to Figure 2 The present invention also provides a plugin detection system based on permission graph attention and contrastive learning. This system is applicable to any of the aforementioned plugin detection methods based on permission graph attention and contrastive learning. The system includes:

[0137] The behavior acquisition module is used to collect raw behavior data of system calls, network communication, and file operations during the operation of the plugin, and convert and output a sequence of behavior events.

[0138] The heterogeneous graph construction module is used to construct a heterogeneous graph of plugin behavior based on the sequence of behavioral events, and to calculate the initial feature vectors of nodes and the initial weights of edges.

[0139] The permission parsing and calculation module is used to parse the plugin configuration file to obtain the declared permission set and calculate the constraint mask matrix and the deviation of the edge permission.

[0140] The graph attention anomaly calculation module is used to combine heterogeneous graphs, constraint mask matrices, and edge permission deviations to calculate graph attention weights, update node features, and obtain node anomaly scores and graph-level anomaly scores.

[0141] The contrastive learning training module is used to construct triplet samples, update network parameters based on triplet contrastive learning loss, and perform K-Means clustering on benign plug-in graph encoding to generate a normal behavior prototype library.

[0142] The adaptive judgment module is used to calculate the minimum distance between the graph vector of the plugin under test and the normal behavior prototype library. It solves the adaptive anomaly judgment threshold based on the generalized Pareto distribution and outputs the plugin judgment result by combining the graph-level anomaly threshold.

[0143] The alarm handling module is used to perform alarm record generation, plugin isolation, or plugin release operations based on the plugin judgment results.

[0144] The behavior acquisition module includes a system call interception submodule, a network traffic mirroring submodule, and a file system monitoring submodule;

[0145] The system call interception submodule is deployed in the integrated development environment plugin process space; the network traffic mirroring submodule and the file system monitoring submodule are deployed inside the sandbox, with a set collection duration. .

[0146] It should be noted that the modular division between the above-mentioned units does not necessarily represent the direct splitting or indirect combination of physical entities. As long as the purpose of this invention is achieved, it can be applied to the embodiments of this invention.

[0147] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.

Claims

1. A plugin detection method based on permission graph attention and contrastive learning, characterized in that, The specific steps of this method are as follows: S1 collects raw behavioral data of system calls, network communication, and file operations during the plugin's operation and converts them into a sequence of behavioral events. S2, construct a heterogeneous graph of plugin behavior based on the sequence of behavioral events, calculate the encoding result of node behavior parameters as the initial feature vector of the node, and calculate the strength of node association as the initial weight of the edge. S3, parse the plugin configuration file to obtain the set of declared permissions, and calculate the constraint mask matrix and edge permission deviation degree of the behavior heterogeneous graph based on the set of declared permissions. The edge permission deviation degree represents the degree to which the node interaction deviates from the declared permissions. S4: Calculate graph attention weights based on heterogeneous graphs, constraint mask matrices, and edge permission deviations; update node features; calculate node anomaly scores and aggregate them into graph-level anomaly scores. S5. Construct triplet samples and use triplet contrastive learning loss to update network parameters. After encoding the benign plug-in behavior graph, perform K-Means clustering to generate a normal behavior prototype library. S6 calculates the minimum distance between the graph vector of the plugin under test and the normal behavior prototype library. The adaptive anomaly judgment threshold is obtained by estimating the generalized Pareto distribution parameters from the distance samples of benign plugins. The graph-level anomaly score is compared with the adaptive anomaly judgment threshold, and the plugin judgment result is output.

2. The plugin detection method based on permission graph attention and contrastive learning according to claim 1, characterized in that, In S1, the behavior event is set with four types of attribute fields; the first type of attribute field of the behavior event records the event type, and the selectable values ​​of the event type are limited to system call, network communication, and file operation; the second type of attribute field of the behavior event records the time when the event occurs, and the time when the event occurs is directly read from the system clock, with the time unit set to seconds; The third type of attribute field of the behavior event records the target object of the event. The record content of the target object includes the API function name, the target IP address with the corresponding port number, and the complete file path. The fourth type of attribute field of the behavior event records the parameters carried by the event. The record content of the parameters includes the input parameters of the system call, the HTTP request Uniform Resource Locator and request body content, and the operation mode corresponding to the file.

3. The plugin detection method based on permission graph attention and contrastive learning according to claim 1, characterized in that, In S2, the plug-in behavior heterogeneous graph contains four types of nodes: the first type is API call nodes, whose node identifier is the system call function name. Target objects with the same system call function name in the collected behavior event sequence are merged and assigned to the same API call node. The second category is data object nodes, whose node identifiers are the variable names or memory data block identifiers in which the plugin runs; the third category is network endpoint nodes, whose node identifiers are a combination of IP address and port number. The fourth category is file resource nodes, whose node identifier is the complete file path; when using the CodeBERT pre-trained model to encode the behavioral event parameter fields, the dimension of the node output feature is set to 768.

4. The plugin detection method based on permission graph attention and contrastive learning according to claim 1, characterized in that, In S2, the heterogeneous graph of plugin behavior includes three types of edges: the first type is the call edge, which connects the two ends of the call edge to two API call nodes that are executed sequentially; the second type is the data flow edge, which connects one end of the data flow edge to the node that generates the data and the other end of the data flow edge to the node that consumes the corresponding data; the third type is the resource access edge, which connects all nodes that access the same file or all nodes that access the same network endpoint. The sliding window used to count the number of times each pair of nodes appears is fixed at 50 events.

5. The plugin detection method based on permission graph attention and contrastive learning according to claim 1, characterized in that, In step S3, the process of generating constraint mask matrix elements includes three types of comparison operations: the first type of comparison operation targets API call nodes, comparing whether the system call function corresponding to the API call node falls within the list of APIs allowed to be called as declared in the plugin configuration file; the second type of comparison operation targets network endpoint nodes, comparing whether the access address corresponding to the network endpoint node falls within the range of domain names and IP addresses allowed to be accessed as declared in the plugin configuration file; the third type of comparison operation targets file resource nodes, comparing whether the file path corresponding to the file resource node falls within the range of directories allowed to be read and written as declared in the plugin configuration file; each pair of nodes performs the corresponding type of comparison operation, and fills in the values ​​of the matrix elements corresponding to the constraint mask matrix based on the comparison results.

6. The plugin detection method based on permission graph attention and contrastive learning according to claim 1, characterized in that, In step S5, the training dataset consists of a combination of a malicious plugin sample set and a benign plugin sample set. The sources of malicious plugin samples include publicly available malicious plugin sample libraries, vulnerability reports released by security organizations, and historical event handling records of enterprise security teams. Benign plugin samples are taken from plugins that have undergone security audits in the VS-Code plugin marketplace and JetBrains plugin marketplace. For each plugin sample included in the training dataset, the following steps are performed in sequence: S1 raw behavior data collection and transformation processing, S2 plugin behavior heterogeneous graph construction processing, and S3 constraint mask matrix and edge permission deviation calculation processing. Each sample generates a corresponding plugin behavior heterogeneous graph, and all generated plugin behavior heterogeneous graphs are divided into the malicious plugin sample set or the benign plugin sample set.

7. The plugin detection method based on permission graph attention and contrastive learning according to claim 1, characterized in that, In S5, the triplet sample consists of three parts: anchor sample, positive sample, and negative sample. When the anchor sample belongs to the behavior heterogeneous graph corresponding to a benign plugin, the positive sample is selected from the behavior heterogeneous graph generated by the same plugin under different collection time windows. When the anchor sample belongs to the behavior heterogeneous graph corresponding to a malicious plugin, the positive sample is selected from the behavior heterogeneous graph corresponding to another plugin instance that implements the same malicious behavior. The negative sample is a behavior heterogeneous graph whose category is different from the anchor sample. During the K-Means clustering execution phase, the clustering number is matched with the total number of functional categories corresponding to benign plugins in the training dataset.

8. The plugin detection method based on permission graph attention and contrastive learning according to claim 1, characterized in that, In step S6, all benign plugins that have been installed and certified for security within the current development environment are extracted. The minimum distance between the graph vector corresponding to each benign plugin and the normal behavior prototype library is calculated one by one, and all minimum distances are used to construct a distance sample set. Quantile operation is performed on the constructed distance sample set, and the 90th percentile value obtained by the quantile operation is selected as the boundary value. Samples with values ​​greater than the boundary value in the distance sample set are filtered out, and the filtered samples are defined as tail samples. The Newton-Raphson iterative operation is used to perform iterative solution operation on the tail samples to solve for the shape parameters and scale parameters corresponding to the generalized Pareto distribution.

9. The plugin detection method based on permission graph attention and contrastive learning according to claim 1, characterized in that, In step S6, after the plugin determination result is output, subsequent processing is performed; if the plugin determination result is a malicious plugin, an alarm record is generated. The alarm record includes the overall abnormal score of the plugin, the node identifier corresponding to the abnormality, and the relevant record content of the node permission deviation. If a plugin is determined to be a malicious plugin, isolation measures will be taken for that plugin. If the plugin is determined to be a benign plugin, the plugin will be allowed to proceed.

10. A plugin detection system based on permission graph attention and contrastive learning, the system being applicable to the plugin detection method based on permission graph attention and contrastive learning as described in any one of claims 1-9, characterized in that, The system includes: The behavior acquisition module is used to collect raw behavior data of system calls, network communication, and file operations during the operation of the plugin, and convert and output a sequence of behavior events. The heterogeneous graph construction module is used to construct a heterogeneous graph of plugin behavior based on the sequence of behavioral events, and to calculate the initial feature vectors of nodes and the initial weights of edges. The permission parsing and calculation module is used to parse the plugin configuration file to obtain the declared permission set and calculate the constraint mask matrix and the deviation of the edge permission. The graph attention anomaly calculation module is used to combine heterogeneous graphs, constraint mask matrices, and edge permission deviations to calculate graph attention weights, update node features, and obtain node anomaly scores and graph-level anomaly scores. The contrastive learning training module is used to construct triplet samples, update network parameters based on triplet contrastive learning loss, and perform K-Means clustering on benign plug-in graph encoding to generate a normal behavior prototype library. The adaptive judgment module is used to calculate the minimum distance between the graph vector of the plugin under test and the normal behavior prototype library. It solves the adaptive anomaly judgment threshold based on the generalized Pareto distribution and outputs the plugin judgment result by combining the graph-level anomaly threshold. The alarm handling module is used to perform alarm record generation, plugin isolation, or plugin release operations based on the plugin's judgment results.