Memory horse detection method and device, electronic equipment and storage medium

By checking the identifier in the request header and calling the memory malware detection code, and combining the memory malware characteristics to determine the target object, the resource waste and false positives and false negatives in memory malware detection in the prior art are solved, and efficient memory malware identification and accurate detection are achieved.

CN118965347APending Publication Date: 2024-11-15HILLSTONE NETWORKS CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411027406.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

Existing technologies for detecting memory malware attacks suffer from problems such as frequent detection, wasted resources, false positives, and false negatives.

Method used

By checking whether the request header contains a first identifier when a request is received, memory malware detection is performed only on requests carrying the first identifier. Pre-built memory malware detection code is called to identify the target object before the target application calls the target object. Memory malware features are used to determine whether the target object is a memory malware. A plugin package is inserted to reduce the impact of detection.

Benefits of technology

It improves the accuracy and efficiency of memory malware detection, reduces resource consumption, and minimizes the impact on server and application performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118965347A_ABST
    Figure CN118965347A_ABST
Patent Text Reader

Abstract

The invention provides a memory horse detection method and device, electronic equipment and a storage medium, and the method comprises the steps: determining whether a request header of a request comprises a first identifier or not under the condition that the request for accessing a target application is received; wherein the request header comprises a first identifier which is used for representing that the type of the target object requested to be accessed is the same as the type of a memory horse; and in response to the first identifier included in the request header, calling a preset memory horse detection code to identify whether the target object is a memory horse or not before the target application calls a target method to extract the target object. By means of the method, the memory horse is effectively recognized, and resources occupied in the memory horse detection process are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of network security technology, and more specifically, to a memory horse detection method, device, electronic device and storage medium. Background Art

[0002] Memory Trojans are a technical means of fileless attacks. They write malicious backdoors and Trojans into the memory and execute them, achieving the effect of remotely attacking Web servers and applications. Since memory Trojan attacks are carried out without files, the attacks are concealed. At present, the main method is to check whether a memory Trojan attack has been carried out by hooking at the entrance and exit of the application extraction method. However, the above detection methods have the problems of frequent detection, waste of resources, false detection, and missed detection. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a memory horse detection method, device, electronic device and storage medium, which are used to effectively identify memory horses and reduce the resources occupied during the memory horse detection process.

[0004] In a first aspect, the present application provides a memory horse detection method, comprising: upon receiving a request to access a target application, determining whether a first identifier is included in a request header of the request; wherein the request header includes the first identifier, which is used to characterize that the type of the target object requested to access is the same as the type of the memory horse; in response to the request header including the first identifier, before the target application calls a target method to extract the target object, calling a preset memory horse detection code to identify whether the target object is a memory horse.

[0005] In the above implementation process, first, whether the request header includes the first identifier, the request header includes the first identifier, which is used to characterize that the type of the target object requested for access is the same as the type of the memory horse. If the request header does not carry the first identifier, it means that the type of the object requested by the request header is different from the type of the memory horse, and the object requested by the request header is not a memory horse, so there is no need to further detect the object requested by the request header. On the contrary, if the request header carries the first identifier, it means that the type of the object requested by the request header is the same as the type of the memory horse, and the object requested by the request header may be a memory horse. Through the above method, only the request header including the first identifier is tested for memory horse, and the request header not including the first identifier is not tested, thereby reducing the performance occupied during the detection process. In addition, when it is determined that the request header includes the first identifier, before the target application calls the target method to extract the target object, the preset memory horse detection code is called to identify whether the target object is a memory horse, and whether the target object is a memory horse is judged. Only when the target application requests the target object, the memory horse detection is performed, and the object detected is the target object of the same type as the memory horse, thereby improving the accuracy of the memory horse detection.

[0006] In an optional implementation, calling a preset memory horse detection code to identify whether the target object is a memory horse, including: calling the memory horse detection code to determine the target object attributes based on the request header; obtaining the target object corresponding to the request header based on the target object attributes; and identifying whether the target object is a memory horse based on preset memory horse features.

[0007] In an optional implementation, the memory horse is a Tomcat Upgrade memory horse, the target object attribute is an upgradedName attribute of the target object, and obtaining the target object corresponding to the request header according to the target object attribute includes: matching in a target data structure object according to the upgradedName attribute of the target object, and determining the target object from the target data structure object, wherein the target data structure object is used to store the upgradedName attribute of the target object and the target object in a key-value pair format.

[0008] In an optional embodiment, identifying whether the target object is a memory horse based on a preset memory horse feature includes: determining whether the value of the class file path corresponding to the target object is empty; if the value of the class file path is not empty, determining whether the class file path of the target object includes a preset file path; if the class file path includes the preset file path, determining that the target object is a memory horse; if the class file path does not include the preset file path, determining that the target object is not a memory horse.

[0009] In the above implementation process, the injection method used by the memory horse during the injection process will correspond to a type of file path. This type of file path is used as the preset file path. By judging whether the class path corresponding to the target object includes the preset file path, it is determined whether the target object is a memory horse, which can improve the accuracy of memory horse detection.

[0010] In an optional embodiment, identifying whether the target object is a memory horse based on a preset memory horse feature includes: when the value of the class file path corresponding to the target object is empty, and / or the class file path includes a preset file path, determining that the target object is a memory horse.

[0011] In the above implementation process, if the attacker exploits the vulnerability to inject a memory malware, the value of the class path corresponding to the memory malware is empty; if the class path corresponding to the target object includes a preset file path, which is the file path used by the attacker when injecting the memory malware, it means that the target object is a memory malware. Therefore, whether the value of the class path corresponding to the target object is empty and whether the class file path corresponding to the target object includes a preset file path are used as memory malware features to improve the accuracy of memory malware detection.

[0012] In an optional embodiment, the method further includes: injecting a plug-in package into the target application, wherein the plug-in package is used to traverse class objects loaded into the memory of the target application; when the traversed class object is a target class object, inserting the memory horse detection code before the code corresponding to the target method in the target class object.

[0013] In the above implementation process, by injecting the plug-in package into the target application, the plug-in package inserts the memory horse detection code before the extraction method in the target class object, and when the target application calls other class objects, the memory horse detection code does not trigger the memory horse detection. Only when the Tomcat application calls the extraction method in the target class object, the memory horse detection code performs a memory horse detection on the request header including the first identifier, thereby minimizing the impact on the server or application during the memory horse detection process.

[0014] In an optional embodiment, injecting the plug-in package into the target application includes: injecting the plug-in package into the target application through an agent program, wherein the agent program is a program that can perform specified tasks or operations when the target application is running; or, injecting the plug-in package into the target application by modifying the JVM underlying function, wherein the JVM underlying function is used to provide an operating environment for the target application.

[0015] In a second aspect, the present application provides a memory horse detection device, comprising:

[0016] A determination module, configured to determine, upon receiving a request to access a target application, whether a request header of the request includes a first identifier; wherein the request header includes the first identifier, which is used to indicate that the type of the target object requested to access is the same as the type of the memory horse;

[0017] The detection module is used to call a preset memory horse detection code to identify whether the target object is a memory horse before the target application calls a target method to extract the target object in response to the first identifier included in the request header.

[0018] In an optional implementation, the detection module is specifically used to call the memory horse detection code to determine the target object attributes based on the request header; obtain the target object corresponding to the request header based on the target object attributes; and identify whether the target object is a memory horse based on preset memory horse features.

[0019] In an optional implementation, the memory horse is a Tomcat Upgrade memory horse, the memory horse detection device is used to detect the TomcatUpgrade memory horse, the target object attribute is the upgradedName attribute of the target object, and the detection module is specifically used to match the target data structure object according to the upgradedName attribute of the target object, and determine the target object from the target data structure object, wherein the target data structure object is used to store the upgradedName attribute of the target object and the target object in a key-value pair manner.

[0020] In an optional implementation, the detection module is specifically used to determine whether the value of the class file path corresponding to the target object is empty; if the value of the class file path is not empty, determine whether the class file path of the target object includes a preset file path; if the class file path includes the preset file path, determine that the target object is a memory horse; if the class file path does not include the preset file path, determine that the target object is not a memory horse.

[0021] In an optional implementation, the detection module determines that the target object is a memory horse when the value of the class file path corresponding to the target object is empty and / or the class file path includes a preset file path.

[0022] In an optional embodiment, the device also includes an insertion module for injecting a plug-in package into the target application, wherein the plug-in package is used to traverse class objects loaded into the memory of the target application; when the traversed class object is a target class object, the memory horse detection code is inserted before the code corresponding to the target method in the target class object.

[0023] In an optional embodiment, the insertion module is specifically used to inject the plug-in package into the target application through an agent program, wherein the agent program is a program that can perform specified tasks or operations when the target application is running; or, inject the plug-in package into the target application by modifying the JVM underlying function, wherein the JVM underlying function is used to provide a running environment for the target application.

[0024] In a third aspect, the present application provides an electronic device, comprising: a processor, a memory and a bus; the processor and the memory communicate with each other through the bus; the memory stores computer program instructions that can be executed by the processor, and the processor calls the computer program instructions to execute a method as described in any of the aforementioned embodiments.

[0025] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a computer, the computer executes a method as described in any one of the aforementioned embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0027] Figure 1 A flowchart of a memory horse detection method provided in an embodiment of the present application;

[0028] Figure 2 A flowchart of inserting memory horse detection code in a Tomcat application provided by an embodiment of the present application;

[0029] Figure 3 A flowchart for detecting an Upgrade memory horse provided in an embodiment of the present application;

[0030] Figure 4 A structural block diagram of a memory horse detection device provided in an embodiment of the present application;

[0031] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0034] It should also be noted that the information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) collected by this application are information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data are in compliance with the relevant laws, regulations and standards of the relevant regions, necessary confidentiality measures are taken, and public order and good customs are not violated, and corresponding operation portals are provided for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.

[0035] To facilitate understanding of this solution, the following takes Tomcat Upgrade memory horse (hereinafter referred to as Upgrade memory horse) as an example to illustrate the construction and utilization process of Upgrade memory horse.

[0036] The Upgrade malware exploits the Upgrade mechanism of Tomcat (a Java-based Web application server and Servlet container maintained by the Apache Software Foundation) by inserting malicious malware into the Map structure of httpUpgradeProtocols and triggering the malicious accept method to control the Tomcat server.

[0037] The harm of Upgrade memory horse is mainly reflected in the following process:

[0038] The process of constructing the Upgrade memory horse is as follows: an attacker can obtain the permission to operate Tomcat memory through a vulnerability or a web backdoor (WebShell) and construct a custom UpgradeProtocol object, which is the Upgrade memory horse. Add the constructed UpgradeProtocol object to the httpUpgradeProtocols attribute of AbstractHttp11Protocol, which is a Map data structure. After the addition is completed, the Upgrade memory horse takes effect. At this time, there is an object corresponding to the Upgrade memory horse in the Map object list of httpUpgradeProtocols.

[0039] The Upgrade memory horse exploitation process is as follows: After constructing the Upgrade memory horse, the attacker adds the upgrade flag and command operation instructions in the request header. After Tomcat recognizes the existence of the upgrade flag in the request header, it obtains the corresponding Upgrade memory horse through the getUpgradeProtocol method and then calls the object's `accept` method. The `accept` method in UpgradeProtocol can recognize the command operation instructions in the request header and execute the response instructions, allowing the attacker to control the Tomcat server.

[0040] Since the attacker needs to construct an Upgrade memory horse in the Map object list first, the current detection method for the Upgrade memory horse is mainly as follows: During each request, the entry and exit of the extraction method of the Tomcat container class are hooked. If a new Upgrade protocol object is added at the exit compared to the entry, it means that the Upgrade protocol object is an Upgrade memory horse constructed by the attacker, thereby realizing the detection of the Upgrade memory horse. However, in actual application scenarios, most requests are not Upgrade type requests. The above detection method will hook the entry and exit of the extraction method for each request process, resulting in performance waste and affecting the request response efficiency.

[0041] In addition, in the above detection method, if there is no new Upgrade protocol object at the exit compared to the entry, it is considered that the attacker has not injected the Upgrade memory horse. However, the attacker can bypass the above detection mechanism by delaying the injection of the Upgrade memory horse, resulting in missed detection. Furthermore, there may be cases where the Upgrade protocol object is added in some normal business. In the above detection mechanism, the Upgrade protocol object added in the normal business will be judged as the Upgrade memory horse, resulting in false detection.

[0042] According to an embodiment of the present application, an embodiment of a memory horse detection method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0043] In an optional embodiment, a memory horse detection system can be used as the execution subject of the memory horse detection method in the embodiment of the present application, wherein the memory horse detection system can be a software system or an embedded system combining software and hardware. In addition, the memory horse detection system can also be run on various electronic devices such as firewall devices, gateway devices, computer devices, terminals, etc.

[0044] It should be noted that in addition to using the above-mentioned memory horse detection system as the execution subject, the memory horse detection method in the embodiment of the present application can also use other devices, equipment or systems as the execution subject, and the present application does not specifically limit this.

[0045] See also Figure 1 , Figure 1 A flowchart of a memory horse detection method provided in an embodiment of the present application, the memory horse detection method may include the following contents:

[0046] Step S101: when receiving a request for accessing a target application, determining whether a request header of the request includes a first identifier.

[0047] In an embodiment of the present application, the request header includes a first identifier, which is used to characterize that the type of the target object requested for access is the same as the type of the memory horse. In actual scenarios, the identification information carried in the request headers requesting different types of objects is different. In order to reduce the performance occupied by detecting the memory horse, the identification information carried in the request header is judged. If the request header does not carry the first identifier, it means that the type of the object requested by the request header is different from the type of the memory horse, and the object requested by the request header is not a memory horse, and there is no need to further detect the object requested by the request header. If the request header carries the first identifier, it means that the type of the object requested by the request header is the same as the type of the memory horse, and the object requested by the request header may be a memory horse. Therefore, after determining that the request header includes the first identifier, the object requested by the request header (i.e., the target object) is obtained according to the information in the request header.

[0048] This application does not limit the type of memory horse. The type of memory horse can be an Upgrade memory horse, or other types of memory horses related to the network request type.

[0049] The target application may be, for example, a Tomcat application, or other applications that can be injected by the Upgrade memory horse.

[0050] Considering that in different application scenarios, the identification information corresponding to the target object of the same type as the memory horse is different, the specific value of the first identification can be determined according to the identification information that needs to be set in the request header when requesting the memory horse in the actual application scenario. For example, for the Upgrade memory horse implemented using Tomcat's Upgrade mechanism, when requesting the Upgrade memory horse, the type of the target object requested to be accessed is the UpgradeProtocol object, and the upgrade identification needs to be added in the request header.

[0051] In some examples, the type of the target object accessed by the request header is an UpgradeProtocol object, and the first identifier is an upgrade identifier.

[0052] In some examples, in response to not including the first identifier in the request header, it is determined that the target object is not a memory horse.

[0053] Step S102: In response to the first identifier included in the request header, before the target application calls the target method to extract the target object, call a preset memory horse detection code to identify whether the target object is a memory horse.

[0054] In the embodiment of the present application, if the request header carries a first identifier, it means that the target type of the object requested by the request header is the same as the type of the memory horse, and the target object may be a memory horse or an object corresponding to a normal business. If the request is a request header sent by an attacker, the target object requested by the request header is a memory horse. In the normal processing logic of the target application, after the target application receives the request header, the target application calls the target method to obtain the memory horse corresponding to the request header. The attacker controls the target application through the memory horse. Therefore, after determining that the request header includes the first identifier through the above step S101, in order to avoid the target application directly obtaining the memory horse according to the request header, before the target application calls the target method to extract the target object, the preset memory horse detection code is called to identify whether the target object is a memory horse, thereby realizing memory horse detection on the target object.

[0055] The following is an exemplary description of the specific process of calling the preset memory horse detection code to identify whether the target object is a memory horse.

[0056] As an optional implementation, the above step S102 may include: calling the memory horse detection code to determine the target object attributes according to the request header; obtaining the target object corresponding to the request header according to the target object attributes; and identifying whether the target object is a memory horse according to preset memory horse features.

[0057] In an embodiment of the present application, after determining that the request header includes the first identifier, the memory horse detection code is called to parse the request header to determine the target object attributes. In the process of the attacker using the memory horse, the attacker constructs and sends a request in order to obtain and call the target object through the request header in the request (in this case, the target object is the memory horse constructed by the attacker). The request header includes the target object attributes, and the target object can be obtained according to the target attribute object. According to the above introduction, the inclusion of the first identifier in the request header indicates that the target object requested by the request header may be a memory horse. Therefore, in order to realize memory horse detection, it is necessary to determine the target object attributes according to the request header, and then obtain the target object corresponding to the request header according to the target object attributes, and then identify whether the target object is a memory horse according to the preset memory horse features.

[0058] The memory horse feature can be characterized as: whether the value of the class file path is empty, and / or whether the class file path includes a preset file path.

[0059] The following takes the Upgrade memory horse as an example to illustrate the method of obtaining the target object corresponding to the request header according to the target object attribute.

[0060] Further, as an optional implementation method, obtaining the target object corresponding to the request header according to the target object attributes includes: matching in the target data structure object according to the upgradedName attribute of the target object, and determining the target object from the target data structure object, wherein the target data structure object is used to store the upgradedName attribute of the target object and the target object in a key-value pair format.

[0061] Here, the target data structure object may be a Map object of httpUpgradeProtocols, and the target object is determined from the Map object of httpUpgradeProtocols by matching the upgradedName attribute of the target object in the Map object of httpUpgradeProtocols.

[0062] In an embodiment of the present application, in a Tomcat application, an UpgradeProtocol object will be added to the httpUpgradeProtocols attribute of AbstractHttp11Protocol, which can be a Map data structure, which stores the UpgradeProtocol object in the form of a key-value pair, the key value is the upgradedName attribute of the UpgradeProtocol object, and the value value is the UpgradeProtocol object. The Upgrade memory horse constructed by the attacker is also an UpgradeProtocol object, and the upgradedName attribute of the Upgrade memory horse is stored in the Map object of httpUpgradeProtocols in the form of a key value. Therefore, in some examples, after determining the upgradedName attribute of the target object through the request header, the value of the upgradedName attribute of the target object is matched with all the key values ​​in the Map object of httpUpgradeProtocols to determine the target object.

[0063] It is understandable that the above method of determining the target object is a specific implementation method of determining the Upgrade memory horse in the Tomcat application. In other application scenarios, after determining the request header, the target object can be obtained according to the request header in a manner specified by the protocol corresponding to the application scenario. This application does not specifically limit the method of obtaining the target object.

[0064] After obtaining the target object corresponding to the request header, identify whether the obtained target object is a memory horse according to the preset memory horse feature. According to the above analysis, if the request header carries the first identifier, it means that the type of the object requested by the request header is the same as the type of the memory horse, and the target object may be a memory horse or an object corresponding to normal business. Therefore, after obtaining the target object, it is necessary to further analyze the target object according to the preset memory horse feature to determine whether the target object has the memory horse feature, so as to determine whether the target object is a memory horse. If the target object has the memory horse feature, it is determined that the target object is a memory horse; conversely, if the target object does not have the memory horse feature, it is determined that the target object is not a memory horse.

[0065] As an optional implementation, based on a preset memory horse feature, identifying whether the target object is a memory horse may include: determining whether the value of the class file path corresponding to the target object is empty; if the value of the class file path is not empty, determining whether the class file path of the target object includes a preset file path; if the class file path includes the preset file path, determining that the target object is a memory horse; if the class file path does not include the preset file path, determining that the target object is not a memory horse.

[0066] In the embodiment of the present application, by analyzing the process of injecting the Upgrade memory horse, it can be known that the attacker can use WebShell to inject the Upgrade memory horse. In the scenario of injecting the Upgrade memory horse using WebShell, there are Java Server Pages (JSP) related paths in the class path of the target object, for example: the class path of the target object includes JSP related paths such as org / apache / jsp / , / jsp_servlet / , / work / _jsp / , etc. Therefore, the JSP related path can be used as the preset file path.

[0067] The preset file path is a JSP-related path, which is an implementation method in the application scenario where the memory horse is an Upgrade memory horse. In other application scenarios, the preset file path can be determined according to the actual application scenario. This application does not limit the type of the preset file path.

[0068] In the process of identifying whether the target object is a memory malware, first determine whether the value of the class file path corresponding to the target object is empty; if the value of the class file path corresponding to the target object is not empty, it means that the attacker may use WebShell to inject the Upgrade memory malware. Therefore, further determine whether the class file path corresponding to the target object includes the preset file path. If it does, the target object is determined to be a memory malware; if it does not, the target object is determined not to be a memory malware.

[0069] Further, based on preset memory horse features, identifying whether the target object is a memory horse may include: when the value of the class file path corresponding to the target object is empty, and / or the class file path includes a preset file path, determining that the target object is a memory horse.

[0070] In the embodiment of the present application, by analyzing the process of Upgrade memory horse injection, it can be known that if an attacker exploits a vulnerability to inject the Upgrade memory horse, the value of the Class class path corresponding to the Upgrade memory horse is null (that is, the value of the class path is empty). Therefore, whether the value of the class path corresponding to the target object is empty can be used as a memory horse feature of the Upgrade memory horse, and by judging whether the value of the class path corresponding to the target object is empty, it is determined whether the target object is a memory horse.

[0071] In addition, an attacker can use WebShell to inject the Upgrade memory horse, and the value of the class path corresponding to the target object includes the JSP related path. Therefore, whether the value of the class path corresponding to the target object includes the preset related path can be used as a memory horse feature of the Upgrade memory horse.

[0072] Combining the above two memory horse features, when identifying whether the target object is a memory horse, if the value of the class file path corresponding to the target object is empty, or the class file path corresponding to the target object includes a preset file path, the target object is determined to be a memory horse.

[0073] Further, as an optional implementation, the memory horse detection method provided in the embodiment of the present application also includes: in response to the target object being a memory horse, removing the memory horse and blocking the request instruction of the request header.

[0074] In an embodiment of the present application, after determining that the target object is a memory horse, the memory horse is removed from the memory and the request instruction of the request header is blocked, so that the server or application will not respond to the request header, preventing the attacker from launching an attack on the server or application through the memory horse.

[0075] For example, in an application scenario where the memory horse is the Upgrade memory horse, the attacker adds the Upgrade memory horse to the Map object of httpUpgradeProtocols. After determining that the target object is the Upgrade memory horse, the Upgrade memory horse is removed from the Map object of httpUpgradeProtocols and the request header corresponding to the target object is blocked, so that the attacker cannot call the Upgrade memory horse.

[0076] Furthermore, as an optional implementation, the memory horse detection method provided in the embodiment of the present application also includes: injecting a plug-in package into the target application, wherein the plug-in package is used to traverse the class objects loaded into the memory of the target application; when the traversed class object is the target class object, inserting the memory horse detection code before the code corresponding to the target method in the target class object.

[0077] In the embodiment of the present application, the processing flow of the Tomcat application is analyzed to know that for a Tomcat application, after receiving a request, the Tomcat application will call the target method (i.e., getUpgradeProtocol method) in the target class object (AbstractHttp11Protocol) of the extracted target object according to the request header of the request, extract the target object and perform related operations. If the request header requests the Upgrade memory horse, the attacker can use the Upgrade memory horse to attack the Tomcat application through the above process.

[0078] In order to make the memory horse detection process happen before the target application calls the target method to extract the target object, the plug-in package is injected into the target application. The function of the plug-in package is to traverse the class objects loaded into the memory of the target application. When the traversed class object is the target class object, the memory horse detection code is inserted before the code corresponding to the target method in the target class object.

[0079] By inserting the memory horse detection code (i.e., the function code for memory horse detection) before the target method, when the Tomcat application calls other class objects, the memory horse detection code does not trigger the execution of the memory horse detection. Only when the Tomcat application calls the target method, the memory horse detection code performs the memory horse detection on the target object requested to be accessed including the first identifier, thereby minimizing the impact on the Tomcat application during the memory horse detection process.

[0080] Take Tomcat application as an example, the name is:

[0081] The class object of "org.apache.coyote.http11.AbstractHttp11Protocol" is the target class object. The target class object includes: getUpgradeProtocol method (i.e., target method). When the Tomcat application executes the getUpgradeProtocol method, it extracts the target object and performs related operations. The plug-in package traverses each class object in the memory of the Tomcat application. When it traverses to the target class object, it inserts the memory horse detection code before the getUpgradeProtocol method, so that the Tomcat application executes the memory horse detection code before executing the getUpgradeProtocol method and performs a memory horse detection on the target object.

[0082] To facilitate understanding of the execution logic in the Tomcat application, the following describes three class objects related to processing the Upgrade memory horse in the Tomcat application.

[0083] The org.apache.coyote.http11.Http11Processor class object is a core class in Apache Tomcat. It is a specific processor implementation of the HTTP / 1.1 protocol. It is responsible for processing HTTP requests received from network IO, parsing request messages, calling the corresponding Servlet to process the request, and then constructing and sending response messages back to the client. This class object usually works in collaboration with the org.apache.coyote.http11.AbstractHttp11Protocol class object. The AbstractHttp11Protocol class is responsible for listening and receiving network connections, while the Http11Processor class is responsible for processing specific HTTP request transactions.

[0084] The org.apache.coyote.http11.AbstractHttp11Protocol class object is the abstract base class of the Tomcat HTTP / 1.1 protocol handler. Tomcat, as an open source Java Servlet container, is responsible for processing HTTP requests and responses. The AbstractHttp11Protocol class defines the basic logic and configuration options for HTTP / 1.1 protocol processing.

[0085] org.apache.coyote.UpgradeProtocol is an interface or abstract class in Apache Tomcat (the specific implementation depends on the Tomcat version) that is used to handle HTTP protocol upgrades. When a client initiates an HTTP request with Connection:upgrade and Upgrade request headers, the request data is passed from the Http11Processor object to the AbstractHttp11Protocol object, which then looks for the UpgradeProtocol object corresponding to the request mapping in the httpUpgradeProtocols property to process the request.

[0086] The memory horse detection code in this application is inserted in:

[0087] Before the getUpgradeProtocol method in the org.apache.coyote.http11.Http11Processor class object, the UpgradeProtocol object is tested for memory before the Tomcat application calls the UpgradeProtocol object through the getUpgradeProtocol method (the Upgrade memory horse is implemented in the Tomcat application with the UpgradeProtocol object).

[0088] As an optional implementation, injecting a plug-in package into a target application includes: injecting the plug-in package into the target application through an agent program, wherein the agent program is a program that can execute specified tasks or operations when the target application is running; or, injecting the plug-in package into the target application by modifying a JVM underlying function, wherein the JVM underlying function is used to provide a running environment for the target application.

[0089] In the embodiments of the present application, there are many ways to inject a plug-in package into the target application, thereby realizing the insertion of the memory horse detection code for memory horse detection before the code corresponding to the target method in the target class object, such as: injecting through JavaAgent (agent program), constructing an injection module by modifying the underlying function of JVM (Java Virtual Machine), etc., which is not limited in the present application.

[0090] The specific process of injecting the plug-in package into the target application is exemplarily described below with reference to a specific example.

[0091] like Figure 2As shown, first search for the Tomcat application existing on the host, and then use the Java injection mechanism to inject the protection plug-in package into the Tomcat application. The injection method includes but is not limited to injection through Java Agent or building an injection module by modifying the underlying function of the JVM. After the protection plug-in package is injected, it will traverse the Class objects loaded into the memory and search for the Class object named org.apache.coyote.http11.AbstractHttp11Protocol. Then, through the ASM dynamic bytecode related technology, the functional bytecode for detecting memory horse (i.e., the memory horse detection program) is inserted before the execution of the getUpgradeProtocol method according to the event-driven model; finally, through the custom Transformer object, the merged bytecode is reloaded into the JVM to complete the insertion of the memory horse detection program.

[0092] The following is a specific example to illustrate the process of detecting memory malware when a memory malware detection program is injected into a Tomcat application.

[0093] like Figure 3As shown in the figure, when an attacker requests a Tomcat Upgrade memory-hash object, the request header will carry the Upgrade identifier. If the identifier is included, the Tomcat application will call the getUpgradeProtocol method of AbstractHttp11Protocol to extract the Upgrade memory-hash. At this time, the memory-hash detection code inserted before the getUpgradeProtocol method will be executed first. The memory-hash detection code will extract the corresponding UpgradeProtocol object from the Map object of httpUpgradeProtocols according to the value of the upgradedName attribute of the method parameter, and check whether the UpgradeProtocol matches the memory-hash feature, such as the Class path corresponding to the UpgradeProtocol object is null (for example, the memory-hash injection scenario using a vulnerability), or the Class path corresponding to the UpgradeProtocol object contains a preset file path, such as org / apache / jsp / , / jsp_servlet / , / work / _jsp / and other JSP file paths (for example, the memory-hash injection scenario using WebShell). If the above features are met, it is determined that the UpgradeProtocol object requested to be accessed is an Upgrade memory object. In this case, the object will be removed from the Map object of httpUpgradeProtocols, the warning content will be output, and the runtime exception will be output to block the request process. If the Class path corresponding to the UpgradeProtocol object is a non-null value, or the Class path corresponding to the UpgradeProtocol object does not contain the preset file path, it means that the object requested to be accessed by the request header is not an Upgrade memory object.

[0094] Based on the same inventive concept, the present application also provides a memory horse detection device. Figure 4 , Figure 4 The present invention provides a structural block diagram of a memory horse detection device according to an embodiment of the present application. The memory horse detection device 400 may include:

[0095] The determination module 401 is used to determine whether the request header of the request includes a first identifier when receiving a request to access a target application; wherein the request header includes the first identifier, which is used to indicate that the type of the target object requested to access is the same as the type of the memory horse;

[0096] The detection module 402 is used to call a preset memory horse detection code to identify whether the target object is a memory horse before the target application calls the target method to extract the target object in response to the first identifier included in the request header.

[0097] In an optional implementation, the detection module 402 is specifically used to call the memory horse detection code to determine the target object attributes according to the request header; obtain the target object corresponding to the request header according to the target object attributes; and identify whether the target object is a memory horse according to preset memory horse features.

[0098] In an optional implementation, the memory horse is a Tomcat Upgrade memory horse, the memory horse detection device is used to detect the TomcatUpgrade memory horse, the target object attribute is the upgradedName attribute of the target object, and the detection module 402 is specifically used to match the target data structure object according to the upgradedName attribute of the target object, and determine the target object from the target data structure object, wherein the target data structure object is used to store the upgradedName attribute of the target object and the target object in a key-value pair manner.

[0099] In an optional implementation, the detection module 402 is specifically used to determine whether the value of the class file path corresponding to the target object is empty; if the value of the class file path is not empty, determine whether the class file path of the target object includes a preset file path; if the class file path includes the preset file path, determine that the target object is a memory horse; if the class file path does not include the preset file path, determine that the target object is not a memory horse.

[0100] In an optional implementation, the detection module 402 determines that the target object is a memory horse when the value of the class file path corresponding to the target object is empty and / or the class file path includes a preset file path.

[0101] In an optional embodiment, the device also includes an insertion module 403, which is used to inject a plug-in package into the target application, wherein the plug-in package is used to traverse the class objects loaded into the memory of the target application; when the traversed class object is the target class object, the memory horse detection code is inserted before the code corresponding to the target method in the target class object.

[0102] In an optional embodiment, the insertion module is specifically used to inject the plug-in package into the target application through an agent program, wherein the agent program is a program that can perform specified tasks or operations when the target application is running; or, inject the plug-in package into the target application by modifying the JVM underlying function, wherein the JVM underlying function is used to provide a running environment for the target application.

[0103] In an optional embodiment, the device further comprises a processing module for removing the memory horse and blocking the request instruction of the request header in response to the target object being a memory horse.

[0104] See also Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device 500 of an embodiment of the present application, and the electronic device 500 includes: at least one processor 501, at least one communication interface 502, at least one memory 503 and at least one bus 504. Among them, the bus 504 is used to realize the direct connection and communication of these components, the communication interface 502 is used to communicate signaling or data with other node devices, and the memory 503 stores machine-readable instructions executable by the processor 501. When the electronic device 500 is running, the processor 501 communicates with the memory 503 through the bus 504, and the machine-readable instructions are executed when the processor 501 calls the memory horse detection method as described above.

[0105] The processor 501 can be an integrated circuit chip with signal processing capabilities. The above-mentioned processor 501 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. It can implement or execute various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.

[0106] The memory 503 may include but is not limited to random access memory (RAM), read only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable read-only memory (EEPROM), etc.

[0107] Understandably, Figure 5 The structure shown is for illustration only. The electronic device 500 may also include Figure 5 More or fewer components as shown, or with Figure 5 Different configurations shown. Figure 5 Each component shown in can be implemented by hardware, software or a combination thereof. In the embodiment of the present application, the electronic device 500 can be, but is not limited to, a physical device such as a desktop computer, a laptop computer, a smart phone, a smart wearable device, a vehicle-mounted device, etc., and can also be a virtual device such as a virtual machine. In addition, the electronic device 500 is not necessarily a single device, but can also be a combination of multiple devices, such as a server cluster, etc.

[0108] In addition, an embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a computer, the memory horse detection method in the above embodiment is executed.

[0109] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0110] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0111] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0112] It should be noted that if the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM) random access memory (RAM), disk or optical disk, and other media that can store program codes.

[0113] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0114] The embodiments or examples of the present disclosure are not exhaustive, but are only illustrative of some embodiments or examples, and are not intended to be specific limitations on the scope of protection of the present disclosure. In the absence of contradiction, each step in a certain embodiment or example can be implemented as an independent example, and the steps can be combined arbitrarily. For example, the scheme after removing some steps in a certain embodiment or example can also be implemented as an independent example, and the order of the steps in a certain embodiment or example can be arbitrarily exchanged. In addition, the optional methods or optional examples in a certain embodiment or example can be combined arbitrarily; in addition, the various embodiments or examples can be combined arbitrarily, for example, some or all steps of different embodiments or examples can be combined arbitrarily, and a certain embodiment or example can be combined arbitrarily with the optional methods or optional examples of other embodiments or examples.

[0115] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A memory horse detection method, characterized in that: include: In the case of receiving a request to access a target application, determining whether a request header of the request includes a first identifier; wherein the request header includes the first identifier, which is used to indicate that the type of the target object requested to access is the same as the type of the memory horse; In response to the request header including the first identifier, before the target application calls the target method to extract the target object, a preset memory horse detection code is called to identify whether the target object is a memory horse.

2. The memory horse detection method according to claim 1, characterized in that: The calling of the preset memory horse detection code to identify whether the target object is a memory horse includes: Call the memory horse detection code to determine the target object attributes according to the request header; Acquire the target object corresponding to the request header according to the target object attribute; According to the preset memory horse feature, identify whether the target object is a memory horse.

3. The memory horse detection method according to claim 2, characterized in that: The memory horse is a Tomcat Upgrade memory horse, the target object attribute is an upgradedName attribute of the target object, and obtaining the target object corresponding to the request header according to the target object attribute includes: A match is performed in a target data structure object according to the upgradedName attribute of the target object, and the target object is determined from the target data structure object, wherein the target data structure object is used to store the upgradedName attribute of the target object and the target object in a key-value pair manner.

4. The memory horse detection method according to claim 2, characterized in that: The step of identifying whether the target object is a memory malware according to a preset memory malware feature includes: Determine whether the value of the class file path corresponding to the target object is empty; If the value of the class file path is not empty, determining whether the class file path of the target object includes a preset file path; If the class file path includes a preset file path, determining that the target object is a memory horse; If the class file path does not include a preset file path, it is determined that the target object is not a memory horse.

5. The memory horse detection method according to claim 2, characterized in that: The step of identifying whether the target object is a memory malware according to a preset memory malware feature includes: When the value of the class file path corresponding to the target object is empty, and / or the class file path includes a preset file path, it is determined that the target object is a memory horse.

6. The memory horse detection method according to any one of claims 1 to 5, characterized in that: The method further comprises: Injecting a plug-in package into the target application, wherein the plug-in package is used to traverse class objects loaded into the memory of the target application; When the traversed class object is a target class object, the memory horse detection code is inserted before the code corresponding to the target method in the target class object.

7. The memory horse detection method according to claim 6, characterized in that: The injecting the plug-in package into the target application comprises: Injecting a plug-in package into the target application through an agent program, wherein the agent program is a program that can perform a specified task or operation when the target application is running; or The plug-in package is injected into the target application by modifying the JVM underlying function, wherein the JVM underlying function is used to provide a running environment for the target application.

8. A memory horse detection device, characterized in that: include: A determination module, configured to determine, upon receiving a request to access a target application, whether a request header of the request includes a first identifier; wherein the request header includes the first identifier, which is used to indicate that the type of the target object requested to access is the same as the type of the memory horse; The detection module is used to call a preset memory horse detection code to identify whether the target object is a memory horse before the target application calls a target method to extract the target object in response to the first identifier included in the request header.

9. An electronic device, characterized in that: The electronic device comprises: a processor, a memory and a bus; The processor and the memory communicate with each other via the bus; The memory stores computer program instructions that can be executed by the processor, and the processor calls the computer program instructions to execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, which, when executed by a computer, cause the computer to perform the method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Memory horse identification and defense method

    CN121580399A