Malicious code injection detector
By combining Bi-LSTM neural networks and online/offline models, the malware detection system is automatically updated, solving the problem of existing technologies being unable to detect unknown malware signatures and achieving efficient malware injection detection.
Patent Information
- Application Number
- CN202480041683.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-07-03
- Filing Date
- 2024-07-01
- Publication Date
- 2026-02-17
AI Technical Summary
Existing methods for detecting malicious code injection rely on lists of known malware signatures, which cannot effectively detect new malware signatures that have not yet been identified, and manual updates are inefficient.
By employing neural network models, particularly bidirectional long short-term memory (Bi-LSTM) neural networks, and combining online model inference with offline training models, we can automatically update and identify features of interest in the source code, including malicious code injection.
It enables automatic detection and updating of unknown malicious code, improving detection efficiency and enabling the identification of potential malicious code injection in large-scale source code.
Smart Images

Figure CN121548819A_ABST
Abstract
Description
[0001] Cross-reference to related applications This application claims the benefit and priority of U.S. Provisional Application No. 63 / 511,746, entitled “Malicious Code Injection Detector,” filed July 3, 2023, pursuant to 35 USC § 119(e), the contents of which are hereby incorporated herein by reference in their entirety. Technical Field
[0002] At least some aspects of this disclosure relate to programming language processing (PLP), such as using neural network models to detect features of interest in source code. Background Technology
[0003] Malicious actors may use e-commerce websites as a means to steal consumers' personal information. For example, credit card fraudsters might attempt to inject malicious code into the source code of an e-commerce website's checkout page. This malicious code injection could be designed to collect credit card credentials provided by consumers when making transactions through the website's checkout page. The fraudsters could then attempt to use the stolen credit card credentials to commit fraudulent transactions. These types of attacks can be mitigated by detecting and removing malicious code injections.
[0004] Detecting malicious code injection can be a complex and time-consuming task. For example, a transaction service provider might be interested in detecting and resolving malicious code injections that could exist in the source code of thousands of different e-commerce websites. Therefore, current methods for detecting malicious code injection may rely on comparing the source code of each webpage with a list of known malware signatures. This list of known malware signatures is often manually created and may need to be manually updated as additional known malware signatures are identified. Therefore, current methods for detecting malicious code injection may fail to detect new and / or unknown malware signatures that have not yet been identified and added to the list of known malware signatures.
[0005] Accordingly, there is a need for alternative systems, methods, and apparatuses for detecting features of interest in source code, such as malicious code injection. This disclosure provides various solutions that employ neural network models to detect features of interest in source code. Summary of the Invention
[0006] In various aspects, this disclosure provides a computer-implemented method for detecting features of interest in source code. The computer-implemented method may include receiving candidate source code by a text preprocessing module, and segmenting the candidate source code into fragments by the text preprocessing module. The computer-implemented method may further include transforming the fragments into vectors by an encoder model. Each of the vectors may correspond to a different fragment within the segment. The computer-implemented method may further include generating tensors based on the vectors by an embedding processing module, and applying the tensors to a decoder model by the embedding processing module. The computer-implemented method may further include determining the probability that the candidate source code contains a feature of interest by the decoder model.
[0007] In various aspects, this disclosure provides a source code classification system. The source code classification system may include online model inference configured to determine the probability that a candidate source code includes a feature of interest. The online model inference may include a text preprocessing module, an encoder model, an embedding processing module, and a decoder model. The text preprocessing module may be configured to segment the candidate source code into fragments. The encoder model may be configured to transform the fragments into vectors. Each of the vectors may correspond to a different fragment within the segment. The embedding processing module may be configured to generate tensors based on the vectors. The decoder model may be configured to determine the probability that the candidate source code includes the feature of interest based on the tensors. Attached Figure Description
[0008] In this description, specific details, such as particular aspects, procedures, techniques, etc., are set forth for purposes of explanation and not limitation in order to provide a thorough understanding of the invention. However, it will be apparent to those skilled in the art that the invention may be practiced in other aspects besides these specific details.
[0009] The accompanying drawings, together with the detailed description below, are incorporated in and form part of this specification, and serve to further illustrate aspects of the concepts including the claimed disclosure and to explain the various principles and advantages of those aspects.
[0010] The apparatus and methods disclosed herein have been indicated by conventional symbols in the accompanying drawings where appropriate, showing only those specific details relevant to understanding various aspects of this disclosure, so as not to obscure this disclosure with details obvious to those skilled in the art who benefit from the description herein.
[0011] Figure 1 A diagram of a source code classification system according to at least one aspect of this disclosure is shown.
[0012] Figure 2A block diagram of a module configured to classify source code according to at least one aspect of this disclosure is shown.
[0013] Figure 3 A block diagram of a bidirectional long short-term memory (Bi-LSTM) model according to at least one aspect of the present disclosure is shown.
[0014] Figure 4 This is a flowchart of a method for classifying source code according to at least one aspect of this disclosure, the method using... Figure 1 The system execution.
[0015] Figure 5 This is a flowchart of a method for classifying source code according to at least one aspect of this disclosure, the method using... Figure 2 The module is executed.
[0016] Figure 6 It is a block diagram of a computer device having a data processing subsystem or component according to at least one aspect of the present disclosure.
[0017] Figure 7 It is a graphical representation of an example system including a host according to at least one aspect of this disclosure.
[0018] Throughout the various views, corresponding reference numerals indicate the corresponding parts. The examples listed herein illustrate various aspects of this disclosure in one form, and such examples should not be construed as limiting the scope of this disclosure in any way. Detailed Implementation
[0019] Before explaining the various forms of proximity cards, it should be noted that the illustrative forms disclosed herein are not limited in application or use to the details of the construction and arrangement of the components shown in the figures and descriptions. Illustrative forms may be implemented or incorporated into other forms, variations, and modifications, and may be practiced or performed in various ways. Furthermore, unless otherwise indicated, the terminology and expressions used herein are chosen for the convenience of the reader in describing the illustrative forms, and not for the purpose of limiting them. Similarly, in the following description, it should be understood that terms such as “forward,” “backward,” “left,” “right,” “above,” “below,” “upward,” and “downward” are convenient words and should not be construed as limiting terms.
[0020] As mentioned above, malicious actors may attempt to inject malicious code into the source code of e-commerce websites, such as the checkout page. Malicious code injection can be designed to collect various consumer credentials. Current methods for detecting malicious code injection may rely on comparing the webpage source code with a list of known malware signatures. However, the list of known malware signatures is often manually created and may need to be manually updated as additional known malware signatures are identified. Therefore, current methods for detecting malicious code injection may not be able to detect new and / or unknown malware signatures that have not yet been discovered and added to the list. Therefore, there is a need for alternative systems, methods, and apparatuses for detecting features of interest in the source code, such as malicious code injection.
[0021] This disclosure provides systems, methods, and apparatus for detecting features of interest in source code. For example, in various aspects, this disclosure provides a source code classification system. The source code classification system may include online model inference and an offline trained model. Online model inference determines the probability that candidate source code includes a feature of interest. The feature of interest may be, for example, malicious code injected into the candidate source code. The offline trained model is trained based on labeled data and can be implemented as online model inference. In some aspects, the offline trained model is automatically retrained based on candidate source code classified by the online model inference, treating the classified candidate source code as labeled data. The online model inference may be automatically updated based on the retrained offline trained model. Therefore, the source code classification system may employ a feedback process for automated retraining.
[0022] In some aspects, online model inference can include a text preprocessing module, an encoder model, an embedding processing module, and a decoder model. The text preprocessing module can segment candidate source code into fragments. The encoder model can transform the fragments into vector embeddings. The embedding processing module can generate tensor embeddings based on the vector embeddings. The decoder model can determine the probability that the candidate source code includes features of interest based on the tensor embeddings. In one aspect, the decoder model includes a bidirectional long short-term memory (Bi-LSTM) neural network. Therefore, online model inference can employ deep learning techniques to identify both known (e.g., previously identified) and unknown (e.g., previously unidentified) features of interest in the candidate source code.
[0023] The apparatuses, systems, and methods disclosed herein offer numerous technical advantages. For example, unlike conventional methods that may rely on collecting and comparing candidate source code with a list of known features of interest (e.g., a list of known malware signatures), the various apparatuses, systems, and methods disclosed herein employ deep learning techniques to identify features of interest in candidate source code that may not yet be identified, thereby providing improvements in malware detection techniques. Therefore, even if fraudsters employ novel types of malware and / or new attack methods that have not yet been discovered, the various apparatuses, systems, and methods disclosed herein can be used to identify malicious code injected into the source code of e-commerce checkout web pages.
[0024] As another example, the various apparatuses, systems, and methods disclosed herein provide technological improvements by employing a feedback process that automatically retrains the online model inference using classification-based candidate source code. This automated retraining enables the online model inference to be automatically updated as new code signatures are identified. Therefore, for example, as the types of malicious code and / or the attack methods employed by fraudsters evolve, the ability of the online model inference to identify corresponding code signatures will also evolve.
[0025] Furthermore, the various apparatuses, systems, and methods disclosed herein can be scaled to investigate candidate source code from thousands of different web pages, thereby identifying features of interest in candidate source code on a scale that is practically impossible for human thought to execute. Additionally, the deep learning techniques employed by the apparatuses, systems, and methods disclosed herein can identify patterns in code signatures, identifying previously unknown features of interest in a manner that is practically impossible for human thought to execute.
[0026] Figure 1 This is a diagram of a source code classification system 100 according to at least one aspect of this disclosure. The source code classification system 100 includes a source code classification server 102, which is connected via a network 160 to one or more website servers 1401, 1402, ... 140 n Communication. One or more web servers 1401, 1402, ... 140 n Each of the following hosts one or more web pages: 1411, 1422, ..., 142 n One or more web pages 1411, 1422, ... 142 n Each of these can be based on website servers 1401, 1402, ... 140 n The source code is generated from the corresponding memory storage in the memory. One or more web pages 1411, 1422, ... 142 nThe source code for any of these can include, for example, JavaScript source code, Hypertext Markup Language (HTML) source code, Cascading Style Sheets (CCS), or any other type of source code suitable for generating web pages, or a combination thereof. Website servers 1401, 1402, ... 140 n Any one or more of these can generally be referred to as "website server 140" in this document. Web pages 1411, 1422, ... 142 n One or more of these may be referred to as "Page 142" in this article.
[0027] Network 160 includes one or more wired and / or wireless networks. For example, network 160 may include cellular networks (e.g., Long Term Evolution (LTE) networks, fourth-generation (4G) networks, fifth-generation (5G) networks, Code Division Multiple Access (CDMA) networks, etc.), Public Land Mobile Networks (PLMN), Local Area Networks (LAN), Wide Area Networks (WAN), Metropolitan Area Networks (MAN), Telephone Networks (e.g., Public Switched Telephone Network (PSTN)), Private Networks, Self-organizing Networks, Intranets, the Internet, Fiber-based Networks, Cloud Computing Networks, etc., and / or combinations of these or other types of networks.
[0028] The source code classification server 102 includes online model inference 104 and offline training model 106. In some aspects, the online model inference 104 and / or the offline training model 106 are generated based on instructions stored in the memory of the source code classification server 102 and executable by the processor of the source code classification server 102. In other aspects, the online model inference 104 and / or the offline training model 106 are specially configured hardware units. In some aspects, the online model inference 104 and / or the offline training model 106 may be implemented as or otherwise include the information described herein. Figure 2 Module 210 is described. A source code classification server 102, including online model inference 104 and offline training model 106, can classify source code from webpage 142, as described in this document. Figure 4 Method 400 is described.
[0029] refer to Figure 1Online model inference 104 can receive (e.g., retrieve) the source code of webpage 142 from the corresponding web server 140 and classify it. Online model inference 104 may include an encoder model and a decoder model to perform classification. The encoder model may generate vector embeddings corresponding to portions (e.g., fragments) of the source code. In some aspects, the encoder model may include a bidirectional encoder representation (BERT) model from a transformer trained for processing natural language and / or programming languages. The decoder model may classify the source code based on the vector embeddings generated by the encoder model. For example, the decoder model may classify the source code by determining the probability that the source code includes a feature of interest. In one aspect, the feature of interest may be malicious code injection, such as malicious code injected by a fraudster into the source code of webpage 142 and designed to steal personal credentials entered by a consumer via webpage 142. In other aspects, the feature of interest may be another type of code signature that may need to be identified in the source code of webpage 142. In some aspects, the decoder model may include a recurrent neural network, such as a bidirectional long short-term memory (Bi-LSTM) neural network.
[0030] Still referencing Figure 1 The offline training model 106 can be an offline version of the online model inference 104. The offline training model 106 can be trained and implemented as the online model inference 104. For example, the offline training model 106 can include the encoder and decoder models described above. To initially train the offline training model 106, a labeled dataset can be applied to it. The labeled dataset can include, for example, positive samples including source code with features of interest (e.g., positive samples including various different malicious code injections) and / or negative samples not including source code with features of interest. Training with the labeled dataset allows the offline training model 106 to update various parameters of the encoder model and / or decoder model (e.g., fitting the encoder model and / or decoder model based on the labeled dataset). The "trained" offline model 106 can then be implemented as the online model inference 104.
[0031] In some respects, after initial training, the offline-trained model 106 can be retrained, and the resulting "retrained" offline model 106 can be implemented as an updated version of the online model inference 104. In one respect, the source code classification server 102 can be configured to retrain the offline-trained model 106 based on a user-provided labeled dataset. For example, after initially training the offline-trained model 106, an additional labeled dataset including positive and / or negative samples of source code can be applied to the offline-trained model 106 for retraining.
[0032] On the other hand, the source code classification server 102 can be configured to automatically retrain the offline training model 106 based on the source code of webpage 142 that has already been classified by the online model inference 104. For example, the offline training model 106 can automatically receive the source code of webpage 142 that has already been classified by the online model inference 104. The offline training model 106 can automatically retrain itself by treating the received source code as a labeled dataset (e.g., treating the source code as a positive sample when the online model inference 104 has classified the source code as including the features of interest, and / or treating the source code as a negative sample when the online model inference 104 has classified the source code as not including the features of interest). The online model inference 104 can be automatically updated based on the resulting "retrained" offline model 106.
[0033] although Figure 1 It describes the interaction with one or more web servers 1401, 1402, ... 140 n Communication is used for one or more web pages 1411, 142 2、 ...142 n The source code classification server 102 is configured to classify source code from various sources, but in various respects, it can also be used to classify source code from other sources. For example, the source code classification server 102 can be configured to communicate with any type of device and / or server to receive and classify source code stored thereon. Similarly, other devices, systems, and methods described herein for classifying source code from web pages can be configured to classify other types of source code and / or source code from other sources. The source code classification server 102 can be configured to classify source code written in various different programming languages, such as Python, Java, JavaScript, PHP, Ruby, Go, HTML, and / or CCS.
[0034] Figure 1 The number and arrangement of systems, devices, and networks shown in the source code classification system 100 are provided as examples. Additional devices, systems, and / or networks, fewer devices, systems, and / or networks, different devices, systems, and / or networks, or networks may exist. Figure 1 The devices, systems, and / or networks shown are arranged in different ways. Furthermore, Figure 1 The two or more devices shown can be implemented within a single device, or Figure 1 The single device shown can be implemented as multiple distributed devices.
[0035] Figure 2 A block diagram of module 210 for classifying source code according to at least one aspect of this disclosure is shown. (The above refers to...) Figure 1The described online model inference 104 and / or offline training model 106 can be implemented as or may otherwise include module 210. Module 210 may include text preprocessing module 212, encoder model 214, embedding processing module 216, and decoder model 218. In some aspects, module 210, including text preprocessing module 212, encoder model 214, embedding processing module 216, and / or decoder model 218, categorizes the source code from webpage 142, as described herein. Figure 5 Method 500 is described.
[0036] Main reference Figure 2 And also refer to Figure 1 The text preprocessing module 212 can preprocess the source code of webpage 142, making it available for processing by the encoding model 214. For example, the text preprocessing module 212 can segment the source code of webpage 142 into source code fragments with a maximum string length. The maximum string length of the fragments can be selected to optimize the efficiency of the encoder model 214. For example, as explained below, the encoder model 214 can generate vector embeddings from the source code fragments. Choosing a longer maximum string length for the fragments can preserve more contextual information in the vector embeddings generated from the fragments. However, applying fragments with a longer maximum string length to the encoder model 214 may also require more time and / or processing resources.
[0037] Still mainly refer to Figure 2 And also refer to Figure 1 As described above, encoder model 214 can transform each fragment of source code into a vector embedding that can be processed by decoder model 218. Encoder model 214 may include a deep learning model pre-trained for natural language and / or programming language (e.g., programming languages such as Python, Java, JavaScript, PHP, Ruby, Go, HTML, CCS, etc.). In some aspects, encoder model 214 includes a bidirectional encoder representation (BERT) model from the transformer. Encoder model 214 can be used to transform fragments into vector embeddings of a specific length, such as a vector embedding with a length of 768 units. In other aspects, encoder model 214 can be used to transform fragments into vector embeddings with a length other than 768 units, such as 128, 256, 512, or 1024 units.
[0038] Embedding processing module 216 can generate tensors based on the vector embeddings output by encoder model 214 and apply the tensors to decoder model 218. Embedding processing module 216 can generate tensors in a form that can be processed by decoder model 218. For example, as described above, each vector embedding output by encoder model 214 can have a length of 768 units. In this regard, decoder model 218 can be configured to accept tensors with a dimension of 10 × 768 units. Therefore, based on the vector embeddings output by encoder model 214, embedding processing module 216 can generate tensors with a dimension of 10 × 768 units. Embedding processing module 216 can pad tensors with zeros as needed to generate tensors of the desired dimension.
[0039] Decoder model 218 classifies the source code of webpage 142 based on tensors generated by embedding processing module 216. For example, decoder model 218 may include a neural network that classifies the source code by determining the probability that the source code includes a feature of interest. In one aspect, the feature of interest may be malicious code injection, such as malicious code injected into the source code of a checkout webpage designed to steal a consumer's personal credentials. In other aspects, the feature of interest may be another type of code signature that may need to be identified in the source code of webpage 142. In some aspects, decoder model 218 may include a recurrent neural network, such as a bidirectional long short-term memory (Bi-LSTM) neural network. In some aspects, decoder model 218 may be implemented as or otherwise include the features described herein. Figure 3 The Bi-LSTM model 320 is described.
[0040] Figure 2 The number and arrangement of models and modules shown in module 210 are provided as an example. Module 210 may include... Figure 2 The models / modules shown are compared to additional models / modules, fewer models / modules, and / or models / modules arranged differently. Furthermore, Figure 2 Two or more of the models / modules shown can be implemented within a single model / module, or Figure 2 The single model / module shown can be implemented as multiple separate models / modules.
[0041] Figure 3 A block diagram of a bidirectional long short-term memory (Bi-LSTM) model 320 according to at least one aspect of this disclosure is shown. The Bi-LSTM model 320 can determine the probability that the source code includes a feature of interest based on received tensor embeddings generated from the source code. (The above relates to...) Figure 2 The described decoder model 218 can be implemented as or otherwise include the Bi-LSTM model 320.
[0042] refer to Figure 3 The Bi-LSTM model 320 may include any one or more of the following: Bi-LSTM layer 322, average pooling layer 324, max pooling layer 326, first linear layer 328, rectified linear unit (ReLU) layer 330, dropout layer 332, second linear layer 334, and sigmoid layer 336. The Bi-LSTM layer 322 may include two Long Short-Term Memory (LSTM) layers, where the first LSTM layer processes the input stream in a first direction, and the second LSTM layer processes the input stream in a second direction opposite to the first direction. The bidirectional architecture of the Bi-LSTM layer 322 allows the Bi-LSTM model 320 to consider contextual information included in the input tensor embeddings, which can lead to more accurate classification of the source code.
[0043] Still referencing Figure 3 The average pooling layer 324 and / or max pooling layer 326 can be configured to reduce noise and amplify various features in the output of the Bi-LSTM layer 322 by respectively calculating the average and maximum values of the output set from the Bi-LSTM layer 322. The outputs of the average pooling layer 324 and max pooling layer 326 can be pooled (e.g., recombined) to be used as input to the first linear layer 328. The first linear layer 328 can be configured to perform a linear transformation on the pooled outputs from the average pooling layer 324 and max pooling layer 326. The ReLU layer 330 can be configured to apply a non-linear activation function to the output of the first linear layer 328. The dropout layer 332 can be configured to set various outputs from the ReLU layer 330 to zero at a specified dropout rate to reduce overfitting of the Bi-LSTM model 320 during training. The second linear layer 334 can be configured to perform a linear transformation on the output of the dropout layer 332 to produce a single output value. The sigmoid layer 336 can be configured to scale the output value from the second linear layer 334 to a value in the range of 0 to 1. Therefore, the output value of the S-shaped layer 336 can represent the probability that the source code used to generate the tensor embedding input includes the features of interest.
[0044] Still referencing Figure 3 In one aspect, the Bi-LSTM model 320 is configured to accept tensor embedding inputs with a size of 10×786 units and can be configured to accept a batch size of 64. In another aspect, each LSTM layer of the Bi-LSTM layer 322 may include 64 units. In yet another aspect, the first linear layer may include 16 hidden units. In yet another aspect, the dropout layer 332 may include a dropout rate of 0.1.
[0045] Figure 4This is a flowchart of a method 400 for classifying candidate source code according to at least one aspect of this disclosure, the method using Figure 1 The system execution. Main reference. Figure 4 And also refer to Figure 1 According to method 400, the labeled dataset is provided to offline training model 106 via method 402 for training and / or retraining. The labeled dataset provided to offline training module 106 via method 402 may include positive samples and / or negative samples of training source code, wherein the positive samples of training source code include features of interest, and the negative samples of training source code do not include features of interest. Features of interest may be, for example, malicious code injected into the training source code. The training source code may include JavaScript source code, Hypertext Markup Language (HTML) source code, Cascading Style Sheets (CCS), Python source code, PHP (PHP: Hypertext Preprocessor) source code, Ruby source code, Go source code, any other type of source code, or a combination thereof.
[0046] Still mainly refer to Figure 4 And also refer to Figure 1 According to method 400, online model inference 104 is implemented (e.g., updated) based on a trained offline training model 106. As described above, the offline training model 106 may be an offline version of the online model inference 104 that is trained and implemented as the online model inference 104. According to method 400, online model inference 104 may receive 406 candidate source codes from webpage 142 and classify the candidate source codes 408. For example, online model inference 104 may classify candidate source codes 408 by determining the probability (e.g., a value in the range of 0 to 1) that the candidate source code includes a feature of interest, such as malicious code injection (e.g., malicious code designed to steal consumer credentials). In some aspects of method 400, if the probability is greater than or equal to a classification threshold, the candidate source code may be classified as including the feature of interest. If the probability is not greater than or equal to the classification threshold, the candidate source code may be classified as not including the feature of interest. In some respects, the classification threshold can be a value greater than or equal to 0.2, such as 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, or 0.999.
[0047] Still mainly refer to Figure 4 And also refer to Figure 1The online model inference 104 can automatically provide 410 of the 408 classified candidate source codes to the offline training model 106 (e.g., and the offline training model 106 can automatically receive the 408 classified candidate source codes) for retraining. In some aspects, the offline training model 106 can automatically provide 410 of the candidate source codes to the offline training model 106 for retraining based on the probability that the candidate source codes include features of interest determined by the online model inference 104. For example, if the probability is greater than or equal to a retraining threshold, the online model inference can automatically provide 410 of the candidate source codes to the offline training model 106 as positive samples for retraining. If the probability is less than the training threshold, the online model inference 104 can automatically provide 410 of the candidate source codes to the offline training model 106 as negative samples for retraining. Alternatively, if the probability is less than the training threshold, the online model inference 104 may not automatically provide 410 of the candidate source codes to the offline training model 106 for retraining. The offline training model 106 can be automatically retrained based on providing 410 candidate source codes. Furthermore, the retrained offline training model 106 can be automatically implemented as an online model inference 104, thereby automatically generating an updated version of the online model inference 104.
[0048] In some respects, the classification threshold and the training threshold can differ. For example, the training threshold can be greater than the classification threshold. This ensures that the offline training model 106 is retrained only using candidate source code that is determined to have a high probability of including the features of interest, thereby ensuring that the updated version of the online model inference 104 maintains accuracy when classifying the candidate source code subsequently. In some respects, the training threshold can be greater than or equal to 0.2, such as 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, or 0.999.
[0049] In some aspects, according to method 400, the user may optionally sample (412) candidate source code that will be automatically provided (410) to the offline training model 106 for retraining. In this regard, the user may periodically and / or randomly view the candidate source code that will be automatically provided (410) to the offline training model 106 for retraining. Before allowing retraining of the offline training model 106 based on the candidate source code, the user may view the candidate source code to ensure that it meets certain criteria. For example, the user may verify the accuracy of the classification of the candidate source code (e.g., to ensure that candidate source code classified as 408 including features of interest does indeed include features of interest before allowing it to be provided as positive samples for retraining the offline training model 106). In one aspect, the optional sampling (412) may be user-initiated. In other aspects, the source code classification server 102 may be configured to periodically and / or randomly provide notifications related to the optional sampling (412) requested by the user. Optional sampling 412 can help ensure that only candidate source code that is correctly classified as including features of interest is used to retrain the offline training model 106, thereby ensuring that the updated version of the online model inference 104 remains accurate when the candidate source code is subsequently classified.
[0050] Figure 5 This is a flowchart of a method for classifying source code according to at least one aspect of this disclosure, the method using... Figure 2 Module 210 is executed. Main reference: Figure 5 And also refer to Figure 2 According to method 500, text preprocessing module 212 receives candidate source code 502. In one aspect of method 500, candidate source code 502 may include content related to a webpage (e.g., ...). Figure 1 The JavaScript source code corresponding to webpage 142. In other aspects of method 500, candidate source code 502 may include source code written in other programming languages (e.g., Python, Java, JavaScript, PHP, Ruby, Go, HTML, CCS, etc.) and may be received from sources other than webpages (e.g., any type of software source code).
[0051] Still mainly refer to Figure 5 And also refer to Figure 2 According to method 500, text preprocessing module 212 segments candidate source code 502 into fragments 504 of candidate source code 502. Furthermore, encoder model 214 transforms fragments 504 into vectors 506 (e.g., vector embedding). Each vector in 506 may correspond to a different fragment in fragment 504.
[0052] Still mainly refer to Figure 5And also refer to Figure 2 According to method 500, embedding processing module 216 generates tensor 508 based on vector 506 and applies tensor 508 to decoder model 218. Decoder model 218 generates classification output 510 based on tensor 508. For example, according to various aspects of method 500, classification output 510 includes the probability that candidate source code 502 includes features of interest. In one aspect, features of interest may include malicious code injected into candidate source code 502.
[0053] In various aspects of method 500, decoder model 218 generates classification output 510 based on tensor 508 by applying tensor 508 to a bidirectional long short-term memory (Bi-LSTM) layer to generate Bi-LSTM layer output. In one aspect, decoder model 218 applies the Bi-LSTM layer output to an average pooling layer to generate an average pooling layer output, and applies the Bi-LSTM layer output to a max pooling layer to generate a max pooling layer output. Furthermore, decoder model 218 combines the average pooling layer output and the max pooling layer output to generate a lumped output. In another aspect, decoder model 218 applies the lumped output to a first linear layer to generate a first linear layer output, applies the first linear layer output to a rectified linear unit (ReLU) layer to generate a ReLU layer output, applies the ReLU layer output to a dropout layer to generate a dropout layer output, applies the dropout layer output to a second linear layer to generate a second linear layer output, and applies the second linear layer output to a sigmoid layer to generate classification output 510.
[0054] In various aspects of method 500, a decoder model 218 is trained by an offline training module based on a labeled dataset. The labeled dataset may include positive samples of the training source code, which include features of interest. In various aspects of method 500, the decoder model 218 may label candidate source code 502 as additional positive samples based on classification output 510. Furthermore, the training module may automatically retrain the decoder model based on the additional positive samples.
[0055] Figure 6 It is a block diagram of a computer device 3000 including a data processing subsystem or component according to at least one aspect of this disclosure. Figure 6The subsystems shown are interconnected via system bus 3010. Additional subsystems are shown, such as printer 3018, keyboard 3026, fixed disk 3028 (or other memory including computer-readable media), and monitor 3022 coupled to display adapter 3020. Peripheral devices and input / output (I / O) devices coupled to I / O controller 3012 (which may be a processor or other suitable controller) can be connected to the computer system via any number of means known in the art, such as serial port 3024. For example, serial port 3024 or external interface 3030 can be used to connect computer devices to a wide area network (e.g., the Internet), a mouse input device, or a scanner. The interconnection via the system bus allows central processing unit 3016 to communicate with each subsystem and allows control over the execution of instructions from system memory 3014 or fixed disk 3028, as well as the exchange of information between subsystems. System memory 3014 and / or fixed disk 3028 may be embodied in computer-readable media.
[0056] Figure 7 This is a graphical representation of an example computing system 4000 according to at least one aspect of this disclosure, the example computing system including a host 4002 containing an instruction set for generating any one or more of the systems, models, and modules described herein and / or performing any one or more of the methods described herein. In various aspects, the host 4002 operates as a standalone device or can be connected (e.g., network-connected) to other machines. In a network deployment, the host 4002 can operate as a server or client machine in a server-client network environment, or as a peer-to-peer (or distributed) network environment. The host 4002 can be a computer or computing device, a personal computer (PC), a tablet PC, a set-top box (STB), a personal digital assistant (PDA), a cellular phone, a portable music player (e.g., a portable hard disk audio device, such as a Moving Picture Experts Group Audio Layer 3 (MP3) player), a network appliance, a network router, a switch, or a bridge, or any machine capable of executing a set of instructions (sequentially or otherwise) specifying actions to be taken by said machine. Furthermore, although only a single machine is shown, the term "machine" should also be understood to include any set of machines that individually or collectively execute a set (or more sets) of instructions to perform any one or more of the methods discussed herein.
[0057] Example system 4000 includes a host 4002, on which a host operating system (OS) 4004 runs on one or more processors / processor cores 4006 (e.g., a central processing unit (CPU), a graphics processing unit (GPU), or both) and various memory nodes 4008. The host OS 4004 may include a super manager 4010 capable of control functions and / or communicating with virtual machines (“VMs”) 4012 running on machine-readable media. VM 4012 may also include a virtual CPU or vCPU 4014. Memory nodes 4008 may be linked or pinned to virtual memory nodes or vNodes 4016. When a memory node 4008 is linked or pinned to a corresponding vNode 4016, data can then be directly mapped from the memory node 4008 to the corresponding vNode 4016.
[0058] All the various components shown in host 4002 can be connected to and linked to each other, or communicate with each other via a bus (not shown) or through other coupling or communication channels or mechanisms. Host 4002 may further include a video display, audio device or other peripheral device 4018 (e.g., liquid crystal display (LCD), alphanumeric input device (including, for example, a keyboard), cursor control device (e.g., mouse), voice recognition or biometric authentication unit, external driver, signal generation device (e.g., speaker)), persistent storage device 4020 (also referred to as a disk drive unit), and network interface device 4022. Host 4002 may further include a data encryption module (not shown) for encrypting data. The components disposed in host 4002 are components commonly found in computer systems that can be adapted for use with aspects of this disclosure, and are intended to represent a broad category of such computer components known in the art. Thus, system 4000 may be a server, minicomputer, host computer, or any other computer system. The computer may further include different bus configurations, networking platforms, multiprocessor platforms, etc. It can use various operating systems, including UNIX, LINUX, WINDOWS, QNX ANDROID, IOS, CHROME, TIZEN and other suitable operating systems.
[0059] The disk drive unit 4024 may also be a solid-state drive (SSD), a hard disk drive (HDD), or other drive including a computer or machine-readable medium on which one or more sets of instructions and data structures (e.g., data / instructions 4026) embodying or utilizing any one or more of the methods or functions described herein are stored. The data / instructions 4026 may also reside wholly or at least partially within the main memory node 4008 and / or the processor 4006 during execution by the host 4002. The data / instructions 4026 may be further sent or received via a network 4028 via a network interface device 4022 utilizing any of several well-known transport protocols (e.g., Hypertext Transfer Protocol (HTTP)).
[0060] Processor 4006 and memory node 4008 may further include machine-readable media. The term "computer-readable media" or "machine-readable media" should be considered as including a single or multiple media (e.g., a centralized or distributed database and / or associated caches and servers) storing one or more sets of instructions. The term "computer-readable media" should also be considered as including any medium capable of storing, encoding, or carrying a set of instructions for execution by host 4002 and causing host 4002 to perform any one or more methods of this application, or any medium capable of storing, encoding, or carrying data structures utilized by or associated with such set of instructions. Therefore, the term "computer-readable media" should be considered as including, but not limited to, solid-state memory, optical and magnetic media, and carrier signals. Such media may further include, but are not limited to, hard disks, floppy disks, flash memory cards, digital video optical discs, random access memory (RAM), read-only memory (ROM), etc. The exemplary aspects described herein may be implemented in an operating environment including software installed on a computer, in hardware, or in a combination of software and hardware.
[0061] Those skilled in the art will recognize that an Internet service can be configured to provide Internet access to one or more computing devices coupled to the Internet service, and the computing devices may include one or more processors, buses, memory devices, display devices, input / output devices, etc. Furthermore, those skilled in the art will understand that the Internet service can be coupled to one or more databases, repositories, servers, etc., which can be used to implement any aspect of the various aspects of this disclosure as described herein.
[0062] Computer program instructions may also be loaded onto a computer, server, other programmable data processing apparatus or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable apparatus, provide for implementing the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0063] For example, a suitable network may include any one or more of the following, or connected to any one or more of them: local intranet, PAN (Personal Area Network), LAN (Local Area Network), WAN (Wide Area Network), MAN (Metropolitan Area Network), Virtual Private Network (VPN), Storage Area Network (SAN), Frame Relay connection, Advanced Intelligent Network (AIN) connection, Synchronous Fiber Network (SONET) connection, digital T1, T3, E1 or E3 line, Digital Data Service (DDS) connection, DSL (Digital Subscriber Line) connection, Ethernet connection, ISDN (Integrated Services Digital Network) line, dial-up port (e.g., V.90, V.34 or V.34bis), dual analog modem connection, cable modem, ATM (Asynchronous Transfer Mode) connection, or FDDI (Fiber Distributed Data Interface) or CDDI (Copper Distributed Data Interface) connection. Furthermore, communications may include links to any of a variety of wireless networks, including WAP (Wireless Application Protocol), GPRS (General Packet Radio Service), GSM (Global System for Mobile Communications), CDMA (Code Division Multiple Access) or TDMA (Time Division Multiple Access), cellular telephone networks, GPS (Global Positioning System), CDPD (Cellular Digital Packet Data), RIM (Room Photograph) full-duplex paging networks, Bluetooth radio, or IEEE 802.11-based radio frequency networks. Network 4028 may further include or interface with any one or more of the following: RS-232 serial connection, IEEE-1394 (FireWire) connection, Fibre Channel connection, IrDA (Infrared) port, SCSI (Small Computer System Interface) connection, USB (Universal Serial Bus) connection or other wired or wireless, digital or analog interfaces or connections, mesh or Digi® network connections.
[0064] Broadly speaking, a cloud-based computing environment is a resource that typically combines large groups of processors (e.g., within a web server) with computing power and / or large groups of computer memory or storage devices with storage capacity. Systems providing cloud-based resources may be available only to their owners, or such systems may be accessible to external users who deploy applications within the computing infrastructure to benefit from large computing or storage resources.
[0065] For example, a cloud consists of a network of web servers comprising multiple computing devices (e.g., host 4002), where each server 4030 (or at least several) provides processor and / or storage resources. These servers manage workloads provided by multiple users (e.g., cloud resource customers or other users). Typically, each user's workload requirements for the cloud change in real time, sometimes dramatically. The nature and extent of these changes usually depend on the type of business associated with the user.
[0066] It is worth noting that any hardware platform suitable for performing the processes described herein is suitable for use with the technology. As used herein, the terms "computer-readable storage medium" and "computer-readable storage media" refer to any one or more media that participate in providing instructions to the CPU for execution. Such media can take many forms, including but not limited to non-volatile media, volatile media, and transmission media. Non-volatile media include, for example, optical discs or magnetic disks, such as fixed disks. Volatile media include dynamic memory, such as system RAM. Transmission media include coaxial cables, copper wires, and optical fibers, which include conductors comprising one side of a bus. Transmission media can also take the form of acoustic or optical waves, such as acoustic or optical waves generated during radio frequency (RF) and infrared (IR) data communications. Common forms of computer-readable media include, for example, floppy disks, hard disks, magnetic tapes, any other magnetic media, CD-ROMs, digital video discs (DVDs), any other optical media, any other physical media with markings or perforations, RAM, PROMs, EPROMs, EEPROMs, FLASH EPROMs, any other memory chips or data exchange adapters, carrier waves, or any other media from which a computer can read.
[0067] Various forms of computer-readable media can participate in loading one or more sequences of one or more instructions to the CPU for execution. A bus carries data to system RAM, from which the CPU fetches and executes instructions. Instructions received from system RAM may optionally be stored on a disk before or after execution by the CPU.
[0068] Computer program code used to perform operations on aspects of the present invention can be written in any combination of one or more programming languages, including object-oriented programming languages (such as Java, Smalltalk, C++, etc.) and conventional procedural programming languages (such as the "C" programming language, Go, Python, or other programming languages including assembly language). The program code can execute entirely on the user's computer, partially on the user's computer, or as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or can connect to an external computer (e.g., via the Internet using an Internet service provider).
[0069] Examples of the apparatuses, systems, and methods described in accordance with various aspects of this disclosure are provided below in the numbered clauses. Any aspect of the (multiple) apparatuses, (multiple) methods, and / or (multiple) systems may include any one or more of the numbered clauses below and any combination thereof.
[0070] Clause 1: A computer-implemented method comprising: receiving candidate source code by a text preprocessing module; segmenting the candidate source code into fragments by the text preprocessing module; transforming the fragments into vectors by an encoder model, wherein each of the vectors corresponds to a different fragment within the fragments; generating tensors based on the vectors by an embedding processing module; applying the tensors to a decoder model by the embedding processing module; and determining, by the decoder model, the probability that a feature of interest exists in the candidate source code.
[0071] Clause 2: The computer-implemented method according to Clause 1, wherein receiving the candidate source code includes receiving JavaScript source code corresponding to a webpage.
[0072] Clause 3: A computer-implemented method according to any one of Clauses 1 to 2, wherein the feature of interest includes malicious code injected into the candidate source code.
[0073] Clause 4: A computer-implemented method according to any one of Clauses 1 to 3, wherein generating the probability of the presence of a feature of interest in the candidate source code by the decoder model comprises: applying the tensor to a bidirectional long short-term memory (Bi-LSTM) layer to generate a Bi-LSTM layer output.
[0074] Clause 5: The computer-implemented method according to Clause 4, wherein generating the probability that the candidate source code contains a feature of interest by the decoder model further comprises: applying the output of the Bi-LSTM layer to an average pooling layer to generate an average pooling layer output; applying the output of the Bi-LSTM layer to a max pooling layer to generate a max pooling layer output; and combining the average pooling layer output and the max pooling layer output to generate a concentrated output.
[0075] Clause 6: The computer-implemented method according to Clause 5, wherein generating the probability that the candidate source code contains a feature of interest by the decoder model further comprises: applying the concentrated output to a first linear layer to generate a first linear layer output; applying the first linear layer output to a rectified linear unit (ReLU) layer to generate a ReLU layer output; applying the ReLU layer output to a dropout layer to generate a dropout layer output; applying the dropout layer output to a second linear layer to generate a second linear layer output; and applying the second linear layer output to a sigmoid layer to generate the probability that the candidate source code contains a feature of interest.
[0076] Clause 7: A computer-implemented method according to any one of Clauses 1 to 6, wherein transforming the segment into the vector by the encoder model comprises: applying the segment to a pre-trained model for programming language processing.
[0077] Clause 8: The computer-implemented method according to any one of Clauses 1 to 7 further comprises: training the decoder model by a training module based on a labeled dataset, wherein the labeled dataset includes positive samples of training source code, the positive samples of the training source code including the features of interest.
[0078] Clause 9: The computer-implemented method according to Clause 8 further includes: marking the candidate source code as an additional positive sample by the training module based on the probability satisfying a predetermined threshold; and retraining the decoder model by the training module based on the candidate source code.
[0079] Clause 10: The computer-implemented method according to any one of Clauses 1 to 9 further includes classifying the candidate source code as including the feature of interest by a classification module based on the probability exceeding a predetermined threshold.
[0080] Clause 11: A source code classification system comprising: an online model inference configured to determine the probability that a candidate source code includes a feature of interest, wherein the online model inference includes: a text preprocessing module configured to segment the candidate source code into fragments; an encoder model configured to transform the fragments into vectors, wherein each of the vectors corresponds to a different fragment within the fragments; an embedding processing module configured to generate a tensor based on the vectors; and a decoder model configured to determine the probability that the candidate source code includes the feature of interest based on the tensor.
[0081] Clause 12: The source code classification system pursuant to Clause 11 further includes: an offline training model for retraining the online model inference, wherein the offline training model is configured to update the online model inference based on a labeled dataset.
[0082] Clause 13: The source code classification system according to Clause 12, wherein the labeled dataset comprises positive samples of source code, each of the positive samples of source code comprising the feature of interest.
[0083] Clause 14: A source code classification system pursuant to any one of Clauses 11 to 13, wherein the feature of interest includes malicious code injection.
[0084] Clause 15: A source code classification system pursuant to any one of Clauses 11 to 14, wherein the candidate source code includes JavaScript source code.
[0085] Clause 16: A source code classification system according to any one of Clauses 12 to 15, wherein the online model inference is configured to receive the candidate source code from an active webpage and determine the probability that the candidate source code from the active webpage includes the feature of interest.
[0086] Clause 17: The source code classification system according to Clause 16, wherein the offline trained model is configured to automatically apply the candidate source code from the active webpage as a labeled dataset for updating the online model based on the probability that the probability of the candidate source code from the active webpage including the feature of interest satisfies a probability threshold.
[0087] Clause 18: A source code classification system according to any one of Clauses 11 to 17, wherein the decoder model comprises a bidirectional long short-term memory (Bi-LSTM) neural network.
[0088] Clause 19: The source code classification system according to Clause 18, wherein the Bi-LSTM neural network comprises: an average pooling layer; a max pooling layer, wherein the outputs of the average pooling layer and the max pooling layer are combined to generate a lumped output; a first linear layer; a rectified linear unit (ReLU) layer; a dropout layer; a second linear layer; and a sigmoid layer.
[0089] Clause 20: A source code classification system according to any one of Clauses 11 to 19, wherein the encoder model includes a bidirectional encoder representation (BERT) model from the converter.
[0090] Furthermore, it should be understood that any one or more of the forms, expressions, and examples described below may be combined with any one or more of the other forms, expressions, and examples described below.
[0091] While several forms have been shown and described, the applicant does not intend to limit or restrict the scope of the appended claims to such details. Many modifications, variations, alterations, substitutions, combinations, and equivalents of those forms can be implemented without departing from the scope of this disclosure, and such modifications, variations, alterations, substitutions, combinations, and equivalents will be apparent to those skilled in the art. Furthermore, the structure of each element associated with a said form can alternatively be described as means for providing the function performed by said element. Additionally, where materials are disclosed for certain components, other materials may be used. Therefore, it should be understood that the foregoing description and the appended claims are intended to cover all such modifications, combinations, and variations falling within the scope of the disclosed forms. The appended claims are intended to cover all such modifications, variations, alterations, substitutions, modifications, and equivalents.
[0092] As used herein, a “server” can include one or more computing devices, which may be individual, independent machines located in the same or different locations, owned or operated by the same or different entities, and may further be one or more clusters of distributed computers or “virtual” machines housed within a data center. Those skilled in the art will understand and appreciate that the functionality performed by a single “server” may be distributed across multiple different computing devices for various reasons. As used herein, “server” is intended to refer to all such scenarios and should not be construed as or limited to a particular configuration. Furthermore, a server as described herein may, but does not necessarily, reside in (or be operated by) an agent of a merchant, payment network, financial institution, healthcare provider, social media provider, government agency, or any of the aforementioned entities. The term “server” may also refer to or include one or more processors or computers, storage devices, or similar computer arrangements that facilitate multi-party communication and processing through a network environment such as the Internet, but it should be understood that communication may be facilitated through one or more public or private network environments, and various other arrangements are possible. Additionally, multiple computers (e.g., servers) or other computerized devices (e.g., point-of-sale devices) communicating directly or indirectly in a network environment can constitute a "system" (e.g., a merchant's point-of-sale system). As used herein, references to "server" or "processor" can refer to a previously stated server and / or processor, different servers and / or processors, and / or combinations of servers and / or processors, as described herein. For example, as used in the specification and claims, a first server and / or first processor stated to perform a first step or function can refer to the same or different servers and / or processors stated to perform a second step or function.
[0093] The term "system" can refer to one or more computing devices or a combination of computing devices (e.g., processor, server, client device, software application, module, such component, etc.). For example, a system may include multiple computing devices that include software applications, wherein the multiple computing devices are connected via a network.
[0094] As used herein, "server computer" can describe a powerful computer or cluster of computers. For example, a server computer can be a mainframe, a small computer cluster, or a group of servers functioning as a single unit. A server computer can be associated with an entity such as a payment processing network, wallet provider, merchant, authentication cloud, acquirer, or issuer. In one example, a server computer can be a database server coupled to a web server. The server computer can be coupled to a database and can include any combination of hardware, software, other logic, or foregoing for servicing requests from one or more client computers. A server computer can include one or more computing devices and can use any of a variety of computing architectures, arrangements, and compilations for servicing requests from one or more client computers. In some embodiments or aspects, a server computer can provide and / or support payment network cloud services.
[0095] As used herein, references to “apparatus,” “server,” “processor,” etc., may refer to a previously stated apparatus, server, or processor, different servers or processors, and / or combinations of servers and / or processors that are stated to perform a prior step or function. For example, as used in the specification and claims, a first server or first processor stated to perform a first step or a first function may refer to the same or different server or the same or different processor stated to perform a second step or a second function.
[0096] One or more components may be referred to herein as “configured to,” “configurable to,” “operable as,” “suitable for,” “capable of,” “compliant to,” etc. Those skilled in the art will recognize that “configured to” can generally encompass active state components and / or inactive state components and / or standby state components, unless the context requires otherwise.
[0097] Those skilled in the art will recognize that, in general, the terms used herein, and especially in the appended claims (e.g., the body of the appended claims), are typically intended as “open-ended” terms (e.g., the term “including” should be interpreted as “including but not limited to”, the term “having” should be interpreted as “having at least”, the term “includes” should be interpreted as “includes but is not limited to”, etc.). Those skilled in the art will further understand that if a particular number of the introduced claim statements are intended, then such intent will be expressly stated in the claims, and where no such statements are present, such intent does not exist. For example, to aid understanding, the appended claims may contain the introductory phrases “at least one” and “one or more” to introduce the claim statements. However, the use of such phrases should not be construed as limiting any particular claim containing such a claim statement to a claim containing only one such statement by introducing the claim statement with the indefinite article "a(a)" or "an", even when the same claim includes the introductory phrase "one or more" or "at least one" and the indefinite article such as "a(a)" or "an" (e.g., "a(a)" and / or "an" should generally be interpreted as meaning "at least one" or "one or more"); the same applies to the use of definite articles for introducing the claim statement.
[0098] Unless otherwise stated, the terms “substantially,” “about,” or “approximately” as used in this disclosure mean an acceptable error in a particular value as determined by one of ordinary skill in the art, depending in part on how the value is measured or determined. In some aspects, the terms “substantially,” “about,” or “approximately” mean within 1, 2, 3, or 4 standard deviations. In some aspects, the terms “substantially,” “about,” or “approximately” mean within 50%, 20%, 15%, 10%, 9%, 8%, 7%, 6%, 5%, 4%, 3%, 2%, 1%, 0.5%, or 0.05% of a given value or range.
[0099] Furthermore, even when a specific number of claims are explicitly stated, those skilled in the art will recognize that such statements should generally be interpreted as meaning at least the stated number (e.g., simply stating "two statements" without other modifiers generally means at least two statements, or two or more statements). Moreover, in these cases where the convention of "at least one of A, B, and C" is used, such constructions are generally intended to be in the sense that those skilled in the art would understand the convention to be (e.g., "a system having at least one of A, B, and C" will include, but is not limited to, systems having only A, only B, only C, A and B together, A and C together, B and C together, and / or A, B, and C together, etc.). In these cases where the convention of "at least one of A, B, or C" is used, such constructions are generally intended to be in the sense that those skilled in the art would understand the convention to be (e.g., "a system having at least one of A, B, or C" will include, but is not limited to, systems having only A, only B, only C, A and B together, A and C together, B and C together, and / or A, B, and C together, etc.). Those skilled in the art will further understand that, whether in the specification, claims, or drawings, optional words and / or phrases that typically present two or more alternative terms should be understood to include the possibility of including one, any, or both of the terms, unless the context otherwise specifies. For example, the phrase “A or B” will generally be understood to include the possibility of including “A” or “B” or “A and B”.
[0100] Regarding the appended claims, those skilled in the art will understand that the operations described herein can generally be performed in any order. Furthermore, although the various operation flowcharts are presented in sequences, it should be understood that the various operations can be performed in orders other than those shown, or can be performed simultaneously. Examples of such alternative orderings may include overlapping, interleaving, interrupted, reordered, ascending, preparatory, supplementary, simultaneous, inverted, or other varied orderings, unless the context otherwise requires. Moreover, terms such as “in response to,” “related to,” or other past tense adjectives are generally not intended to exclude such variations, unless the context otherwise requires.
[0101] It is worth noting that any reference to “an aspect,” “one aspect,” “an example,” “an example,” and the like means that a particular feature, structure, or characteristic described in connection with said aspect is included in at least one aspect. Therefore, the appearance of the phrases “in an aspect,” “in one aspect,” “in an example,” and “in an example” in various places throughout the specification does not necessarily refer to the same aspect. Furthermore, a particular feature, structure, or characteristic may be combined in one or more aspects in any suitable manner.
[0102] As used herein, unless the context clearly indicates otherwise, the singular forms “a”, “an”, and “the” include plural referents.
[0103] Any patent application, patent, non-patent publication, or other disclosure cited in this specification and / or listed in any application data sheet is incorporated herein by reference so that the incorporated material is not inconsistent with it. Consequently, and to the extent necessary, any conflicting material incorporated by reference as expressly set forth herein supersedes any conflicting material. It is claimed that any material or portion thereof incorporated herein by reference that conflicts with existing definitions, statements, or other disclosures set forth herein will be incorporated only to the extent that the incorporated material does not conflict with existing disclosures.
[0104] In summary, the numerous benefits arising from adopting the concepts described herein have been described. One or more forms of the foregoing description have been presented for illustrative and descriptive purposes. They are not intended to be exhaustive or limited to the precise forms disclosed. Modifications or variations are possible in light of the foregoing teachings. The aforementioned forms have been chosen and described to illustrate principles and practical applications, thereby enabling those skilled in the art to utilize the various forms and make various modifications suitable for the particular application considered. The claims filed herein are intended to define the overall scope.
Claims
1. A computer-implemented method comprising: receiving, by a text preprocessing module, a candidate source code; segmenting, by the text preprocessing module, the candidate source code into snippets; transforming, by an encoder model, the snippets into vectors, wherein each of the vectors corresponds to a different one of the snippets; generating, by an embedding processing module, a tensor based on the vectors; applying, by the embedding processing module, the tensor to a decoder model; and determining, by the decoder model, a probability that a feature of interest is present in the candidate source code.
2. The computer-implemented method of claim 1, wherein receiving the candidate source code comprises receiving JavaScript source code corresponding to a web page.
3. The computer-implemented method of claim 2, wherein the feature of interest comprises malicious code injected into the candidate source code.
4. The computer-implemented method of claim 1, wherein generating, by the decoder model, the probability that the feature of interest is present in the candidate source code comprises: applying the tensor to a bidirectional long short-term memory (Bi-LSTM) layer to generate a Bi-LSTM layer output.
5. The computer-implemented method of claim 4, wherein generating, by the decoder model, the probability that the feature of interest is present in the candidate source code further comprises: applying the Bi-LSTM layer output to an average pooling layer to generate an average pooling layer output; applying the Bi-LSTM layer output to a max pooling layer to generate a max pooling layer output; and combining the average pooling layer output and the max pooling layer output to generate a central output.
6. The computer-implemented method of claim 5, wherein generating, by the decoder model, the probability that the feature of interest is present in the candidate source code further comprises: applying the central output to a first linear layer to generate a first linear layer output; applying the first linear layer output to a rectified linear unit (ReLu) layer to generate a ReLu layer output; applying the ReLu layer output to a dropout layer to generate a dropout layer output; applying the dropout layer output to a second linear layer to generate a second linear layer output; and applying the second linear layer output to a sigmoid layer to generate the probability that the feature of interest is present in the candidate source code.
7. The computer-implemented method of claim 4, wherein transforming, by the encoder model, the snippets into the vectors comprises: applying the snippets to a pre-trained model for programming language processing.
8. The computer-implemented method of claim 1, further comprising: training, by a training module, the decoder model based on a labeled dataset, wherein the labeled dataset includes positive samples of training source code that include the feature of interest.
9. The computer-implemented method of claim 8, further comprising: labeling, by the training module, the candidate source code as an additional positive sample based on the probability satisfying a predetermined threshold; and retraining, by the training module, the decoder model based on the candidate source code. 10. The computer-implemented method of claim 1, further comprising classifying, by a classification module, the candidate source code as including the feature of interest based on the probability exceeding a predetermined threshold.
11. A source code classification system comprising: an online model inference configured to determine a probability that a candidate source code includes a feature of interest, wherein the online model inference comprises: a text preprocessing module configured to segment the candidate source code into segments; an encoder model configured to transform the segments into vectors, wherein each of the vectors corresponds to a different one of the segments; an embedding processing module configured to generate a tensor based on the vectors; and a decoder model configured to determine the probability that the candidate source code includes the feature of interest based on the tensor.
12. The source code classification system of claim 11, further comprising: an offline training model to retrain the online model inference, wherein the offline training model is configured to update the online model inference based on a labeled dataset.
13. The source code classification system of claim 12, wherein the labeled dataset includes positive samples of source code that each include the feature of interest.
14. The source code classification system of claim 13, wherein the feature of interest includes malicious code injection.
15. The source code classification system of claim 14, wherein the candidate source code includes JavaScript source code.
16. The source code classification system of claim 15, wherein the online model inference is configured to receive the candidate source code from an active web page and determine the probability that the candidate source code from the active web page includes the feature of interest.
17. The source code classification system of claim 16, wherein the offline training model is configured to automatically apply the candidate source code from the active web page as a labeled dataset for updating an online model based on the probability that the candidate source code from the active web page includes the feature of interest satisfying a probability threshold.
18. The source code classification system of claim 12, wherein the decoder model includes a bidirectional long short-term memory (Bi-LSTM) neural network.
19. The source code classification system of claim 18, wherein the Bi-LSTM neural network includes: an average pooling layer; a max pooling layer, wherein outputs of the average pooling layer and the max pooling layer are combined to generate a central output; a first linear layer; a rectified linear unit (ReLu) layer; a dropout layer; a second linear layer; and a sigmoid layer.
20. The source code classification system of claim 18, wherein the encoder model includes a bidirectional encoder representations from transformers (BERT) model.
