RPC protocol security detection method and device, and storage medium
The RPC protocol is adapted and combined with the detection engine through plug-in technology, which solves the problem that existing tools are difficult to detect the enterprise's self-developed RPC protocol, and improves the versatility and security detection efficiency of detection tools.
Patent Information
- Application Number
- CN202410714677.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-10-15
AI Technical Summary
Existing RPC protocol detection tools are difficult to adapt to the high-security RPC protocols developed by enterprises, resulting in the inability to effectively detect these protocols, limiting the versatility and scope of application of the detection tools.
Adapt the RPC protocol through plug-in technology, and combine it with the detection engine to realize the identification and detection of RPC protocol communication data. The plug-in is inserted into the target function of the application, extracts the RPC request and request context, marks the tainted data and sends it to the detection engine for processing. Security testing.
It reduces the difficulty of adapting and developing different RPC protocols, improves the versatility and scope of application of detection tools, and enhances the accuracy and efficiency of security detection.
Smart Images

Figure CN118779879A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of RPC protocol security detection, and in particular to an RPC protocol security detection method, device and storage medium. Background Art
[0002] In current technology applications, large applications generally adopt a distributed architecture, which generally includes multiple services and implements communication between services through RPC (remote procedure call). However, the calling relationship between services is complicated. If tools that focus on single service detection are used, such as gray box detection tools based on application instrumentation and taint analysis technology, to perform security detection on calls between services in actual applications, these tools will expose their defects in identifying data propagation in the entire system, which will lead to the inability to perform security detection on communication between services. Therefore, it is necessary to adapt and develop detection tools for the RPC protocol so that the detection tools can track and identify the data flow between different services.
[0003] Different distributed development frameworks use different RPC protocols, such as TCP (Transmission Control Protocol), UDP (User Datagram Protocol) or HTTP (Hypertext Transfer Protocol). For some open source RPC protocol frameworks (such as Dubbo, gRpc), it is relatively convenient to adapt the detection tools, and it is easy to build relevant functions into the detection tools, so that the detection tools can identify and detect the communication data of the protocol. However, for RPC protocols developed by enterprises with higher security levels, it is impossible to view their source code and protocol implementation details, resulting in the inability to adapt the detection tools accordingly, and thus it is impossible to use existing detection tools to detect these enterprises' self-developed RPC protocols. This undoubtedly limits the versatility and scope of application of the detection tools, making these tools unable to be applied to complex and changeable distributed systems. Summary of the invention
[0004] The purpose of the present invention is to provide an RPC protocol security detection method, device and storage medium, which adapts the RPC protocol through plug-in technology, and cooperates with the detection engine to realize the identification and detection of RPC protocol communication data, which is conducive to reducing the difficulty of developing detection tools for adaptation of different RPC protocols, effectively improving the versatility and scope of application of the detection tools, and improving the accuracy and efficiency of security detection.
[0005] In order to achieve the above object, the present invention discloses a RPC protocol security detection method, which comprises:
[0006] The probe side inserts the plug-in into the target function of the application;
[0007] The application executes the target function and calls the plug-in;
[0008] The probe end injects the probe context into the called plug-in;
[0009] The plug-in extracts the RPC request and the request context from the parameters of the target function and the environment in which the application runs the target function;
[0010] The plug-in extracts probe tracing data from the RPC request;
[0011] The plug-in marks at least part of the RPC request as tainted data according to the probe tracking data;
[0012] The plug-in encapsulates the RPC request and the request context into an RPC request object;
[0013] The plug-in sends the RPC request object and the taint data to the detection engine using the probe context;
[0014] The detection engine performs security detection on the data passed in by the plug-in.
[0015] Furthermore, the “probe end inserting the plug-in into the target function of the application program” includes:
[0016] The probe end registers the instrumentation system to the JVM virtual machine;
[0017] The probe end extracts the class file of the plug-in and loads it into the JVM virtual machine;
[0018] The JVM virtual machine calls the plug-in system to process the class file of the plug-in;
[0019] The probe end registers the target function to the instrumentation system, and loads the class file of the target function to the instrumentation system;
[0020] The instrumentation system injects the entry code of the plug-in into the target function.
[0021] Furthermore, before “the plug-in extracts the RPC request and the request context from the parameters of the target function and the environment in which the application runs the target function”, it also includes:
[0022] The plug-in determines whether the current target function is a function executed when the application processes the RPC protocol.
[0023] Furthermore, the RPC request and the request context include a request protocol, a protocol version, a request path, request parameters, a request header, a port and an IP address.
[0024] Furthermore, before the “probe end inserts the plug-in into the target function of the application program”, it also includes:
[0025] The server distributes the plug-in to the probe side of the corresponding application.
[0026] Furthermore, before the “probe end inserts the plug-in into the target function of the application program”, it also includes:
[0027] The probe end obtains information of plug-ins required by the current application from the server end;
[0028] The probe terminal determines whether the current application has the required plug-in, and if the required plug-in does not exist, downloads the required plug-in from the server terminal;
[0029] The probe terminal determines whether the plug-in in the current application is the latest version of the plug-in. If it is not the latest version of the plug-in, the probe terminal downloads the latest version of the plug-in from the server terminal.
[0030] Furthermore, the probe end is provided with an interaction module, and before the “the detection engine performs security detection on the data transmitted by the plug-in”, it also includes:
[0031] The interaction module performs format conversion on the data sent by the plug-in to the detection engine.
[0032] In order to achieve the above object, the present invention discloses an electronic device, which includes:
[0033] one or more processors;
[0034] One or more memories are used to store one or more programs. When one or more of the programs are executed by the processor, the processor implements the RPC protocol security detection method as described above.
[0035] In order to achieve the above-mentioned purpose, the present invention discloses a computer-readable storage medium, on which a program is stored, and when the program is executed by a processor, the RPC protocol security detection method as described above is implemented.
[0036] In this application, the data of the RPC protocol is identified by means of a plug-in, and the probe end of the application inserts the plug-in into the target function of the application, so that when the application executes the target function, it can call the plug-in to extract the RPC request and request context from the parameters of the target function and the environment in which the application runs the target function. Then the plug-in extracts the probe tracking data from the RPC request to mark the tainted data according to the probe tracking data, and then sends the RPC request object encapsulated with the RPC request and the request context and the marked tainted data to the detection engine, so that the detection engine can perform security detection on these data. Adapting the RPC protocol through plug-in technology and cooperating with the detection engine to realize the identification and detection of RPC protocol communication data is conducive to reducing the difficulty of developing detection tools for adaptation of different RPC protocols, effectively improving the versatility and scope of application of detection tools, and improving the accuracy and efficiency of security detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 The present invention is a flowchart of an RPC protocol security detection method according to an embodiment of the present invention.
[0038] Figure 2 4 is a system diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to explain the technical content, structural features, achieved objectives and effects of the present invention in detail, the following is a detailed description in conjunction with the implementation methods and the accompanying drawings.
[0040] Embodiment 1
[0041] See also Figure 1 The present invention discloses a RPC protocol security detection method, which includes:
[0042] It should be noted that for protocols that the new probe is not adapted to, especially private protocols within the enterprise, it is necessary to first develop plug-ins through the RPC parsing plug-in development kit. Developers need to refer to the interface specification document to complete the plug-in code that implements the PluginInterceptor interface. By developing new plug-ins to flexibly adapt to new RPC protocols, the flexibility and scalability of detection tools can be effectively improved.
[0043] The RPC parsing plug-in development kit aims to provide developers with a complete RPC parsing plug-in development environment, including commonly used development tool classes that facilitate the writing and development of plug-in code; detailed description of the interface specifications that the RPC parsing plug-in needs to implement, including interface documents such as input parameters, output format, and exception handling; and demonstration of how to develop an RPC parsing plug-in, including sample code for the basic framework for handling different RPC protocols and the implementation of common functions, etc., to support developers in quickly and efficiently developing RPC parsing plug-ins that meet the requirements.
[0044] Next, use a build tool (such as Maven or Gradle) to package the developed plug-in code into a jar package, and upload the jar package to the server through the server-side plug-in management page for subsequent distribution and use.
[0045] It is understandable that before "the probe end inserts the plug-in into the target function running the application", it also includes:
[0046] 11. The server distributes the plug-in to the probe end of the corresponding application;
[0047] It should be noted that the server is provided with a first plug-in management module, which is responsible for supporting developers to upload the developed RPC parsing plug-ins to the server; searching, finding and selecting suitable plug-ins according to user needs; deleting plug-ins that are no longer needed; distributing the server-side plug-ins to the probe end of the corresponding application, and supporting users to select plug-ins on the server-side plug-in management page, and then distributing the selected plug-ins to the specified Java application; it is beneficial for the application to use the latest RPC parsing plug-in to parse RPC communication data.
[0048] It is understandable that before "the probe end inserts the plug-in into the target function running the application", it also includes:
[0049] 12. The probe end obtains the information of the plug-in required by the current application from the server end;
[0050] 13. The probe determines whether the current application has the required plug-in. If not, the probe downloads the required plug-in from the server.
[0051] 14. The probe determines whether the plug-in in the current application is the latest version of the plug-in. If it is not the latest version of the plug-in, the probe downloads the latest version of the plug-in from the server.
[0052] It should be noted that the probe in the application will periodically call the server's interface to check the plug-ins and their versions required by the current application, and download or update the plug-ins. This is conducive to the probe automatically downloading and updating plug-ins as needed, realizing dynamic updating and loading of plug-ins, and improving the flexibility and ease of use of the system.
[0053] It should be noted that the probe end is provided with a second plug-in management module, which is responsible for downloading the required RPC parsing plug-in from the server end; detecting and downloading the latest version of the plug-in; loading the downloaded plug-in into the probe end; and uninstalling plug-ins that are no longer needed, which is conducive to cooperating with the first plug-in management module to realize the full process management of the plug-in.
[0054] 101. The probe end inserts the plug-in into the target function of the application program;
[0055] Furthermore, "the probe side inserts the plug-in into the target function of the application program" includes:
[0056] 1011. The probe end registers the instrumentation system to the JVM virtual machine;
[0057] 1012. The probe end extracts the class file of the plug-in and loads it into the JVM virtual machine;
[0058] 1013. The JVM virtual machine calls the plug-in system to process the class file of the plug-in;
[0059] It should be noted that the plug-in code is saved in the class file. The probe end loads the plug-in class file into the JVM virtual machine to facilitate it to obtain the plug-in code information and execute it. Then, the JVM virtual machine calls the plug-in system and passes the plug-in class file to the plug-in system, so that the plug-in system can process the plug-in class file according to the preset strategy.
[0060] 1014. The probe end registers the target function to the instrumentation system, and loads the class file of the target function to the instrumentation system;
[0061] 1015. The plug-in system injects the entry code of the plug-in into the target function.
[0062] It should be noted that the instrumentation system modifies the content of the class file of the target function according to the set instrumentation logic, and injects the entry code of the plug-in into the specified position of the target function, so that the function of the plug-in can be called when the application executes the target function. For example, the probe needs to be instrumented at the entry and exit of the target function respectively. The instrumentation system injects methodEnter(request) at the entry of the target function Invoker.invoke(request), and injects methodExit(request) at the exit, so that the application's probe calls the relevant code of the plug-in at the entry of the target function, that is, in methodEnter, so that the plug-in performs corresponding logical processing.
[0063] 102. The application executes the target function and calls the plug-in;
[0064] It can be understood that gray box detection based on probe technology (IAST) is a passive detection. Because the relevant code logic has been inserted into the target function, when the application being instrumented executes the target function that processes the RPC protocol, it will trigger the entry function of the plug-in to execute the instrumentation logic of the probe at the same time.
[0065] 103. The probe end injects the probe context (AgentContext) into the called plug-in;
[0066] It is understandable that when the application starts to execute the plug-in code, it will call the plug-in code through the probe. At this time, the probe end will pass the probe context as a parameter to the plug-in function, and the probe context contains relevant information of the probe. Subsequent plug-ins can communicate with the detection engine with the help of the probe context.
[0067] Further, before "the plugin extracts the RPC request and request context from the target function's parameters and the environment in which the application runs the target function", it also includes:
[0068] 1040. The plug-in determines whether the current target function is a function executed when the application processes the RPC protocol.
[0069] It can be understood that the target function is the function executed when the application specifically processes the RPC protocol. The plug-in must first match the target function to determine whether the current target function is a related function for processing the RPC protocol, and then start to extract the RPC request information from the current target function, effectively ensuring accurate parsing of the RPC communication data.
[0070] 104. The plug-in extracts the RPC request and the request context from the parameters of the target function and the environment in which the application runs the target function;
[0071] It should be noted that, generally, the required information can be extracted through the parameters of the RPC parsing function (target function) executed by the application. The plug-in parses the parameters of the RPC request in the target function into a format recognizable by the detection engine, so as to facilitate the use of the detection engine to perform in-depth analysis and detection of RPC communication data. However, in some cases, it is necessary to obtain information other than function parameters, such as from environment variables, system parameters, thread context, etc.
[0072] 105. The plug-in extracts probe tracking data from the RPC request;
[0073] It should be noted that the context of the RPC request in the RPC protocol generally provides corresponding functions for injecting additional parameters into the RPC request or obtaining additional parameters from the RPC request. For example, the dubbo protocol provides the RpcContext.setAttachment(key,value) function for injecting parameters, and provides the RpcContext.getAttachment(key) function for obtaining parameters. Furthermore, the HTTP protocol can carry additional parameters by adding a request header. The plug-in calls the function to extract the data tracked by the probe, so that the tainted data can be accurately tracked based on the extracted data in the future, and potential security risks in the RPC protocol can be discovered in a timely manner.
[0074] 106. The plug-in marks at least part of the RPC request as tainted data according to the probe tracking data;
[0075] Furthermore, the RPC request and request context include request protocol, protocol version, request path, request parameters, request header, port and IP address.
[0076] It should be noted that the probe tracking data extracted by the plug-in is combined to identify the tainted data of the request parameters in the RPC request. If the probe tracking data is not extracted, all request parameters are considered unreliable, and all request parameters are marked as tainted data. If the probe tracking data is extracted, only the data in the request parameters that has been tracked by the probe is marked as tainted data, which facilitates the subsequent detection engine to identify and process these request parameters according to the marked tainted data, and is not limited to this.
[0077] 107. The plug-in encapsulates the RPC request and request context into an RPC request object;
[0078] 108. The plug-in uses the probe context to send the RPC request object and taint data to the detection engine;
[0079] For example, the RPC request object is passed to the probe detection engine through the resolveRequest method of the probe context AgentContext, and the tainted data is passed to the detection engine through the rpcReceive method of the probe context AgentContext, which facilitates the detection engine to perform in-depth security detection on the RPC communication data, but is not limited to this.
[0080] Furthermore, the probe end is provided with an interactive module, and before the "detection engine performs security detection on the data passed in by the plug-in", it also includes:
[0081] 1090. The interaction module converts the format of the data sent by the plug-in to the detection engine.
[0082] It should be noted that the RPC parsing plug-in exchanges data with the gray box detection engine through the interaction module. The interaction module is responsible for defining the data exchange interface between the RPC parsing plug-in and the detection engine to ensure accurate data transmission; performing necessary format conversion and data processing on the data output by the RPC parsing plug-in according to the requirements of the detection engine; performing anomaly detection and anomaly processing during the data exchange process to ensure that the plug-in accurately passes the complete parsed data to the detection engine, so that the plug-in can send the RPC communication data to the detection engine for security detection in real time, effectively realizing real-time monitoring and protection of RPC communication, and improving the scalability of the gray box detection engine.
[0083] 109. The detection engine performs security checks on the data passed in by the plug-in.
[0084] It is understandable that after the detection engine receives the data transmitted by the RPC parsing plug-in, it will perform corresponding deep detection, vulnerability discovery, and data reporting. Through the close cooperation between the RPC parsing plug-in and the gray box detection engine, it can accurately identify the data propagation path in the RPC protocol and improve the accuracy and efficiency of security detection. There are relatively mature detection engine solutions on the market, so I will not go into details.
[0085] In this application, the data of the RPC protocol is identified by means of a plug-in, and the probe end of the application inserts the plug-in into the target function of the application, so that when the application executes the target function, it can call the plug-in to extract the RPC request and request context from the parameters of the target function and the environment in which the application runs the target function. Then the plug-in extracts the probe tracking data from the RPC request and request context to mark the tainted data according to the probe tracking data, and then sends the RPC request object encapsulated by the RPC request and request context and the marked tainted data to the detection engine, so that the detection engine can perform security detection on these data. Adapting the RPC protocol through plug-in technology and cooperating with the detection engine to realize the identification and detection of RPC protocol communication data is conducive to reducing the difficulty of developing detection tools for adaptation of different RPC protocols, effectively improving the versatility and scope of application of detection tools, and improving the accuracy and efficiency of security detection.
[0086] Embodiment 2
[0087] See also Figure 1 and Figure 2 , the present invention discloses an electronic device, comprising:
[0088] One or more processors 201;
[0089] One or more memories 202 are used to store one or more programs. When the one or more programs are executed by the processor, the processor implements the RPC protocol security detection method as described above.
[0090] Embodiment 3
[0091] An embodiment of the present application discloses a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the RPC protocol security detection method as described above is implemented.
[0092] Embodiment 4
[0093] The embodiment of the present application discloses a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of an electronic device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the electronic device executes the above-mentioned RPC protocol security detection method.
[0094] It should be understood that in the embodiments of the present application, the processor referred to may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0095] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by hardware related to computer program instructions, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0096] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of rights of the present invention. Therefore, equivalent changes made according to the scope of the patent application of the present invention are still within the scope covered by the present invention.
Claims
1. A RPC protocol security detection method, characterized in that: include: The probe side inserts the plug-in into the target function of the application; The application executes the target function and calls the plug-in; The probe end injects the probe context into the called plug-in; The plug-in extracts the RPC request and the request context from the parameters of the target function and the environment in which the application runs the target function; The plug-in extracts probe tracing data from the RPC request; The plug-in marks at least part of the RPC request as tainted data according to the probe tracking data; The plug-in encapsulates the RPC request and the request context into an RPC request object; The plug-in sends the RPC request object and the taint data to the detection engine using the probe context; The detection engine performs security detection on the data passed in by the plug-in.
2. The RPC protocol security detection method according to claim 1, characterized in that: The "probe end inserting the plug-in into the target function of the application program" includes: The probe end registers the instrumentation system to the JVM virtual machine; The probe end extracts the class file of the plug-in and loads it into the JVM virtual machine; The JVM virtual machine calls the plug-in system to process the class file of the plug-in; The probe end registers the target function to the instrumentation system, and loads the class file of the target function to the instrumentation system; The instrumentation system injects the entry code of the plug-in into the target function.
3. The RPC protocol security detection method according to claim 1, characterized in that: Before the "the plug-in extracts the RPC request and the request context from the parameters of the target function and the environment in which the application runs the target function", it also includes: The plug-in determines whether the current target function is a function executed when the application processes the RPC protocol.
4. The RPC protocol security detection method according to claim 1, characterized in that: The RPC request and the request context include a request protocol, a protocol version, a request path, request parameters, a request header, a port, and an IP address.
5. The RPC protocol security detection method according to claim 1, characterized in that: Before the "probe end inserts the plug-in into the target function of the application program", it also includes: The server distributes the plug-in to the probe side of the corresponding application.
6. The RPC protocol security detection method according to claim 1, characterized in that: Before the "probe end inserts the plug-in into the target function of the application program", it also includes: The probe end obtains information of plug-ins required by the current application from the server end; The probe terminal determines whether the current application has the required plug-in, and if the required plug-in does not exist, downloads the required plug-in from the server terminal; The probe terminal determines whether the plug-in in the current application is the latest version of the plug-in. If it is not the latest version of the plug-in, the probe terminal downloads the latest version of the plug-in from the server terminal.
7. The RPC protocol security detection method according to claim 1, characterized in that: The probe end is provided with an interaction module, and before the "the detection engine performs security detection on the data transmitted by the plug-in", it also includes: The interaction module performs format conversion on the data sent by the plug-in to the detection engine.
8. An electronic device, characterized in that: include: one or more processors; One or more memories are used to store one or more programs. When one or more of the programs are executed by the processor, the processor implements the RPC protocol security detection method as described in any one of claims 1 to 7.
9. A computer-readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, the RPC protocol security detection method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Method, system, device and medium for externally analyzing private confidentiality protocol
CN119449924A
