Injection protection method, device, electronic device and computer readable storage medium

By using filtering links in the Tomcat server to implement class detection and execution of HTTP requests, the problem of injection attacks is solved and the security of the server is improved.

CN115314280BInactive Publication Date: 2024-08-27CHINA PING AN LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210933349.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-04
Publication Date
2024-08-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

It is difficult for Tomcat server to effectively prevent Java code injection level attacks in the configuration parameter mode, and baseline security measures are not enough to deal with injection attacks.

Method used

By obtaining the HTTP request, the filtering link implementation class of the Tomcat server detects the request parsing information, configures it into the execution instance and executes it, and schedules processing according to the code execution results, thereby solving the problem of injection attacks at the code level.

Benefits of technology

Effectively detects and intercepts injection attacks, prevents injection attacks at the code level, and improves the security of the Tomcat server.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115314280B
    Figure CN115314280B
Patent Text Reader

Abstract

The present application relates to the field of data processing, and provides an injection protection method, device, electronic device and computer-readable storage medium, the method comprising: obtaining a Hypertext Transfer Protocol HTTP request; parsing the HTTP request based on a Tomcat server to obtain request parsing information; detecting the request parsing information based on a filter link implementation class of the Tomcat server to obtain a detection request source code; configuring the detection request source code to an execution instance of the filter link implementation class and executing the execution instance to obtain a code execution result; scheduling the HTTP request according to the code execution result. The above technical solution can solve the injection attack problem at the code level.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to but are not limited to the field of data processing, and in particular, to an injection protection method, device, electronic device, and computer-readable storage medium. Background Art

[0002] The Tomcat server is a free, open source World Wide Web (Web) application server. It is a lightweight application server and is widely used in small and medium-sized systems and in situations where there are not many concurrent users. It is the first choice for developing and debugging Java Server Pages (JSP) programs. JSP technology provides a simple way to process dynamically generated Hyper Text Markup Language (HTML) pages. These HTML pages are directly compiled into server-side applets for fast execution. Tomcat can increase security by configuring parameters, but this approach can usually only achieve baseline security, but is basically ineffective against attacks at the Java code injection level. Summary of the invention

[0003] The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.

[0004] In order to solve the problems mentioned in the above background technology, the embodiments of the present application provide an injection protection method, device, electronic device and computer-readable storage medium, which can solve the injection attack problem at the code level.

[0005] In a first aspect, an embodiment of the present application provides an injection protection method, the method comprising:

[0006] Get the Hypertext Transfer Protocol HTTP request;

[0007] Parsing the HTTP request based on the Tomcat server to obtain request parsing information;

[0008] Detecting the request parsing information based on the filtering link implementation class of the Tomcat server to obtain a detection request source code;

[0009] configuring the detection request source code into the execution instance of the filtering link implementation class and executing the execution instance to obtain a code execution result;

[0010] The HTTP request is scheduled according to the code execution result.

[0011] The injection protection method according to the embodiment provided in the present application has at least the following beneficial effects: first, a Hypertext Transfer Protocol HTTP request is obtained; then, the request parsing information is detected based on the filtering link implementation class of the Tomcat server to obtain the detection request source code; then, the detection request source code is configured to the execution instance of the filtering link implementation class and the execution instance is executed to obtain the code execution result; finally, the HTTP request is scheduled according to the code execution result; through the above technical solution, the detection request source code is configured to the execution instance of the filtering link implementation class and the code execution result can be obtained according to the execution instance, and finally, the scheduling process is performed according to the code execution result, thereby being able to solve the injection attack problem at the code level.

[0012] According to some embodiments of the present application, the Tomcat server includes a connector and a container, and the step of parsing the HTTP request based on the Tomcat server to obtain the request parsing information includes:

[0013] Performing a first analysis on the HTTP request based on the connector to obtain request attribution information;

[0014] The set resolution information in the container is matched with the request attribution information to obtain the request resolution information.

[0015] According to some embodiments of the present application, the Tomcat server includes a detection request implementation class, and the filtering link implementation class based on the Tomcat server detects the request parsing information to obtain the detection request source code, including:

[0016] Performing a first detection process on the request parsing information based on the filter link implementation class to obtain request execution information;

[0017] Based on the detection request implementation class, a second detection process is performed on the request execution information to obtain the detection request source code.

[0018] According to some embodiments of the present application, configuring the detection request source code into the execution instance of the filtering link implementation class and executing the execution instance to obtain a code execution result includes:

[0019] Configuring the detection request source code to the beginning of the execution instance to obtain the detection code;

[0020] The HTTP request is executed based on the detection code to obtain a code execution result.

[0021] According to some embodiments of the present application, scheduling the HTTP request according to the code execution result includes:

[0022] Performing a second analysis on the code execution result to obtain request feedback information;

[0023] The HTTP request is scheduled according to the request feedback information.

[0024] According to some embodiments of the present application, the request feedback information is request approval information or request rejection information, and the scheduling of the HTTP request according to the request feedback information includes:

[0025] When the request feedback information is the request passing information, performing response processing on the corresponding HTTP request;

[0026] When the request feedback information is information that the request is not passed, the corresponding HTTP request is intercepted.

[0027] According to some embodiments of the present application, the Tomcat server further includes an encapsulation implementation class, and before the filtering link implementation class based on the Tomcat server detects the request parsing information to obtain the detection request source code, the method further includes:

[0028] Encapsulate the request parsing information based on the encapsulation implementation class;

[0029] The encapsulated request parsing information is cached in a preset system cache area.

[0030] In a second aspect, an embodiment of the present application further provides an injection protection device, the device comprising:

[0031] A first processing module, used for obtaining a Hypertext Transfer Protocol HTTP request;

[0032] A second processing module is used to parse the HTTP request based on the Tomcat server to obtain request parsing information;

[0033] A third processing module is used to detect the request parsing information based on the filtering link implementation class of the Tomcat server to obtain a detection request source code;

[0034] A fourth processing module, configured to configure the detection request source code into the execution instance of the filtering link implementation class and execute the execution instance to obtain a code execution result;

[0035] The fifth processing module is used to schedule the HTTP request according to the code execution result.

[0036] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the injection protection method as described in the first aspect above is implemented.

[0037] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the injection protection method as described in the first aspect above.

[0038] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.

[0040] Figure 1 is a flow chart of an injection protection method provided by an embodiment of the present application;

[0041] Figure 2 It is a flowchart of generating request parsing information in an injection protection method provided by an embodiment of the present application;

[0042] Figure 3 It is a flowchart of generating a detection request source code in an injection protection method provided by an embodiment of the present application;

[0043] Figure 4 It is a flowchart of generating code execution results in an injection protection method provided by an embodiment of the present application;

[0044] Figure 5 This is a flowchart of scheduling HTTP requests in an injection protection method provided by an embodiment of the present application;

[0045] Figure 6 This is a flowchart of scheduling according to request feedback information in an injection protection method provided by an embodiment of the present application;

[0046] Figure 7 This is a flowchart of encapsulating request parsing information in an injection protection method provided by an embodiment of the present application;

[0047] Figure 8 is a schematic diagram of an injection protection device provided by an embodiment of the present application;

[0048] Fig. 9 It is a schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0050] It should be noted that although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification and claims and the above drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0051] It should be noted that, unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0052] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0053] AI is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. Artificial intelligence is a branch of computer science. Artificial intelligence attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robots, language recognition, image recognition, natural language processing and expert systems. Artificial intelligence can simulate the information process of human consciousness and thinking. Artificial intelligence is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0054] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0055] Artificial intelligence is AI. AI is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0056] The servers involved in artificial intelligence technology can be independent servers or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.

[0057] The present application provides an injection protection method, device, electronic device and computer-readable storage medium, which first obtain a Hypertext Transfer Protocol HTTP request; then, based on the filtering link implementation class of the Tomcat server, the request parsing information is detected to obtain the detection request source code; then, the detection request source code is configured to the execution instance of the filtering link implementation class and the execution instance is executed to obtain the code execution result; finally, the HTTP request is scheduled according to the code execution result; through the above technical solution, the detection request source code is configured to the execution instance of the filtering link implementation class and the code execution result can be obtained according to the execution instance, and finally, the scheduling process is performed according to the code execution result, thereby solving the injection attack problem at the code level.

[0058] The injection protection method provided in the embodiment of the present application relates to the field of data processing technology. The injection protection method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, and can also be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the injection protection method, etc., but is not limited to the above forms.

[0059] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0060] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with the relevant laws, regulations, and standards of the relevant countries and regions. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.

[0061] The embodiments of the present application are further described below in conjunction with the accompanying drawings.

[0062] like Figure 1 As shown, Figure 1 It is a flowchart of an injection protection method provided by an embodiment of the present application, and the injection protection method includes but is not limited to steps S100 to S600.

[0063] Step S100, obtaining a Hypertext Transfer Protocol HTTP request;

[0064] Step S200, parsing the HTTP request based on the Tomcat server to obtain request parsing information;

[0065] Step S300, detecting the request parsing information based on the filtering link implementation class of the Tomcat server to obtain the detection request source code;

[0066] Step S400, configuring the detection request source code into the execution instance of the filtering link implementation class and executing the execution instance to obtain the code execution result;

[0067] Step S500, scheduling HTTP requests according to the code execution result.

[0068] It should be noted that, first, a Hypertext Transfer Protocol HTTP request is obtained; then, based on the filtering link implementation class of the Tomcat server, the request parsing information is detected to obtain the detection request source code; then, the detection request source code is configured to the execution instance of the filtering link implementation class and the execution instance is executed to obtain the code execution result; finally, the HTTP request is scheduled according to the code execution result; through the above technical solution, the detection request source code is configured to the execution instance of the filtering link implementation class and the code execution result can be obtained according to the execution instance, and finally, the scheduling process is performed according to the code execution result, thereby being able to solve the injection attack problem at the code level.

[0069] It is worth noting that the Hyper Text Transfer Protocol (HTTP) is a simple request-response protocol that usually runs on top of the Transmission Control Protocol (TCP); it specifies what kind of messages the client may send to the server and what kind of responses it may get. HTTP is an application layer protocol. Like other application layer protocols, it is a protocol for implementing a certain type of specific application, and its functions are implemented by an application running in user space; HTTP is a protocol specification, which is recorded in a document and is the implementation program of HTTP that actually communicates through HTTP. HTTP is based on the client / server model and is connection-oriented. A typical HTTP transaction has the following process: the client establishes a connection with the server, the client makes a request to the server, the server accepts the request and returns the corresponding file as a response according to the request, and the client and server close the connection. HTTP is a stateless protocol, that is, the server does not retain any state when trading with the client, which greatly reduces the memory burden of the server, thereby maintaining a faster response speed. HTTP is an object-oriented protocol that allows the transmission of any type of data object. It identifies the content and size of the transmitted data by data type and length, and allows data to be compressed and transmitted. Among them, HTTP request refers to the request message from the client to the server, including: the request method for the resource, the resource identifier and the used protocol in the first line of the message. The request message from the client to the server includes: the request method for the resource, the resource identifier and the used protocol in the first line of the message.

[0070] It should be noted that Tomcat server is a free and open source network application server. It is a lightweight application server and is widely used in small and medium-sized systems and occasions where there are not many concurrent users. It is the first choice for developing and debugging Java Server Pages (JSP) programs. Tomcat server can run well and support network application deployment when running on Java. Tomcat server is a free and open source network application server. Due to its advanced technology and stable performance, it is deeply loved by Java enthusiasts and is currently a popular network application server.

[0071] It is worth noting that the filter chain implementation class in the Tomcat server is actually a variant implementation of the responsibility chain pattern; the filter chain implementation class includes three basic components, the first is the caller interface, there are two implementation classes: the first is the final call terminator; the second is the caller that calls the filter method. The second is the filter interface; the third is the filter chain constructor, which has two main functions, one is to load filters according to various conditions and various mechanisms, and the other is to construct the caller interface based on these filters.

[0072] It is worth noting that in object-oriented programming, a "class" is called an "instance" after instantiation; a "class" is static and does not occupy process memory, while an "instance" has dynamic memory; in a database, it represents a collection of some programs. Instances and objects are basically synonyms, and they can often be used interchangeably. An object represents a specific instance of a class, and an object has two characteristics: identity and attribute value; an instance is a specific representation of an object, operations can act on instances, instances can store operation results in a stateful manner, and instances are used to simulate concrete or prototype things that exist in the real world. An object is an instance of a class, and all objects are instances, but not all instances are objects; for example, an associated instance is not an object, it is just an instance, a connection, and common instances are instances of classes. At this time, there is no difference between the two, and instances other than instances of classes are not objects. In object-oriented programming, the process of creating objects using classes is usually called instantiation.

[0073] It can be understood that HTTP requests can be parsed and processed based on the Tomcat server, and then the request parsing information corresponding to the HTTP request can be obtained; and the request parsing information can be detected based on the filtering link implementation class of the Tomcat server to obtain the corresponding detection request source code; the detection request source code obtained above is configured into the execution instance of the filtering link implementation class and the code execution result can be obtained during the execution of the execution instance; finally, the corresponding HTTP request can be scheduled and processed according to the code execution result.

[0074] It is understandable that the injection in the embodiments of the present application may refer to structured query language injection, command injection, small text file tampering, sensitive file downloading, arbitrary file reading, slow database query, and printing of sensitive log information. Injection protection is to prevent the above injection behaviors from occurring. Exemplarily, injection protection can be to prevent structured query language injection, command injection, small text file tampering, sensitive file downloading, arbitrary file reading, slow database query, and printing of sensitive log information.

[0075] In some embodiments, Figure 2 As shown, the Tomcat server includes a connector and a container, and the above step S200 may include but is not limited to steps S210 to S220.

[0076] Step S210, performing a first analysis on the HTTP request based on the connector to obtain request attribution information;

[0077] Step S220: Match the set resolution information in the container with the request attribution information to obtain the request resolution information.

[0078] It should be noted that the Tomcat server includes a connector and a container; when obtaining request resolution information, the HTTP request is first analyzed and processed based on the connector to obtain the request attribution information; then the collection resolution information in the container is matched with the request attribution information to obtain the request resolution information.

[0079] It is worth noting that the highest level of abstraction of the entire Tomcat server kernel can be modularized and can be seen as consisting of connectors and containers. The connector is responsible for receiving and responding to HTTP requests, generating request objects and response objects and handing them over to the container for processing, while the container finds the responding container according to the request path for processing. An intermediate connection component is required to transmit the request response object from the connector to the container. Among them, the connector receives HTTP requests and responds to generate request attribution information; then the collection resolution information in the container is matched with the request attribution information obtained in the above steps to obtain the corresponding request resolution information.

[0080] It is understandable that the container carries the set resolution information, and the corresponding request resolution information can be obtained by simply comparing and matching the request attribution information obtained by the connector analysis with the set resolution information in the container.

[0081] It should be noted that the connector can obtain the request attribution information by performing a first analysis on the HTTP request; and can obtain the relevant request resolution information by matching and comparing the set resolution information with the request attribution information.

[0082] It is worth noting that the first analysis of the HTTP request is to analyze and process the relevant information of the HTTP request; the first analysis is only used to distinguish different execution entities, and does not mean that the analysis operations are different.

[0083] In some embodiments, Figure 3 As shown, the Tomcat server also includes a detection request implementation class, and the above step S300 includes but is not limited to steps S310 to S320.

[0084] Step S310, performing a first detection process on the request parsing information based on the filter link implementation class to obtain request execution information;

[0085] Step S320: Perform a second detection process on the request execution information based on the detection request implementation class to obtain the detection request source code.

[0086] It should be noted that the Tomcat server also includes a detection request implementation class. In the process of generating the detection request source code, the request parsing information is first subjected to a first detection process based on the filtering link implementation class to obtain the request execution information; then, the request execution information is subjected to a second detection process based on the detection request implementation class to obtain the detection request source code.

[0087] It is worth noting that by performing a first detection process on the request parsing information based on the filtering link implementation class, the request execution information can be obtained, and the detection request implementation class can perform a second detection process on the request execution information to obtain the detection request source code; among them, the filtering link implementation class and the detection request implementation class are both related implementation classes of the Tomcat server.

[0088] It should be noted that the detection request source code is obtained by performing a second detection process on the request execution information by the detection request implementation class. The detection request source code can enable the injection protection level to reach the code level, thereby solving the injection attack problem at the code level.

[0089] It should be noted that the first detection processing and the second detection processing in the embodiment of the present application are only used to distinguish the execution subjects, and do not mean that the two detection processing methods are different. The specific steps of the first detection processing and the second detection processing can be the same or different, which is not limited here.

[0090] It is understandable that the injection in the embodiments of the present application may refer to structured query language injection, command injection, small text file tampering, sensitive file downloading, arbitrary file reading, slow database query, and printing of sensitive log information. Injection protection is to prevent the above injection behaviors from occurring. Exemplarily, injection protection can be to prevent structured query language injection, command injection, small text file tampering, sensitive file downloading, arbitrary file reading, slow database query, and printing of sensitive log information.

[0091] In some embodiments, Figure 4 As shown, the above step S400 includes but is not limited to step S410 to step S420.

[0092] Step S410, configuring the detection request source code to the beginning of the execution instance to obtain the detection code;

[0093] Step S420: Execute the HTTP request based on the detection code to obtain a code execution result.

[0094] It should be noted that the detection code can be obtained by configuring the detection request source code to the beginning of the execution instance; the code execution result can be obtained by executing and processing the HTTP request based on the detection code.

[0095] It is worth noting that the detection code can be obtained by configuring the detection request source code to the beginning of the execution instance; then the code execution result can be obtained by executing the HTTP request based on the detection code, and finally the HTTP request can be scheduled and processed according to the code execution result. In the embodiment of the present application, in the process of scheduling and processing the HTTP request according to the code execution result, if the code execution result indicates that it is passed, the HTTP request will be responded to, and if the code execution result indicates that it is not passed, the HTTP request will be intercepted to prevent injection problems at the code level.

[0096] It should be noted that the detection request source code is configured to the beginning of the execution instance, so that the detection request source code can be executed first during the execution of the detection code, and then the code execution result can be quickly obtained, so as to facilitate the subsequent scheduling and processing of HTTP requests according to the code execution result.

[0097] It is worth noting that the HTTP request message consists of four parts: request line, request header, blank line and request data. Among them, the request line is divided into three parts: request method, request address and protocol version; the request header adds some additional information to the request message, consisting of "name / value" pairs, one pair per line, and the name and value are separated by a colon; the HTTP response message mainly consists of a status line, a response header, a blank line and response data.

[0098] It should be noted that by configuring the detection request source code to the beginning of the execution instance, the corresponding detection code can be obtained; then, the HTTP request can be executed based on the corresponding detection code to obtain the corresponding code execution result, and the corresponding HTTP request can be scheduled and processed by subsequent analysis of the code execution result.

[0099] In some embodiments, Figure 5 As shown, the above step S500 includes but is not limited to step S510 to step S520.

[0100] Step S510, performing a second analysis on the code execution result to obtain request feedback information;

[0101] Step S520: Schedule the HTTP request according to the request feedback information.

[0102] It should be noted that the request feedback information can be obtained by performing a second analysis on the code execution result; then the HTTP request can be scheduled and processed according to the request feedback information.

[0103] It is worth noting that the second analysis of the code execution result can obtain the request feedback information, which represents the detection result of the HTTP request. The subsequent scheduling of the HTTP request needs to be based on the corresponding request feedback information. For example, if the request feedback information represents that the detection is passed, the corresponding HTTP request will be responded to, and if the request feedback information represents that the detection is not passed, the corresponding HTTP request will be intercepted.

[0104] It should be noted that the second analysis is only used to distinguish different execution entities and does not mean that the analysis operations are different.

[0105] In some embodiments, the request feedback information is request approval information or request rejection information, such as Figure 6 As shown, the above step S520 includes but is not limited to step S521 to step S522.

[0106] Step S521, when the request feedback information is request approval information, respond to the corresponding HTTP request;

[0107] Step S522: When the request feedback information is request failure information, the corresponding HTTP request is intercepted.

[0108] It should be noted that when the request feedback information is request approval information, the corresponding HTTP request will be responded to and processed; when the request feedback information is request failure information, the corresponding HTTP request will be intercepted and processed to prevent injection problems at the code level.

[0109] It is worth noting that when the request feedback information is request approval information, the corresponding HTTP request will be responded to; when the request feedback information is request rejection information, the corresponding HTTP request will be intercepted; and the corresponding HTTP request will be scheduled according to the request feedback information, making the scheduling process of HTTP requests more accurate, stable and reliable.

[0110] In some embodiments, Figure 7 As shown, the Tomcat server also includes an encapsulation implementation class, which includes but is not limited to steps S230 to S240 before step S300.

[0111] Step S230, encapsulating the request parsing information based on the encapsulation implementation class;

[0112] Step S240: Cache the encapsulated request resolution information into a preset system cache area.

[0113] It should be noted that before detecting the request resolution information, the encapsulation implementation class in the Tomcat server can be used to encapsulate the request resolution information, and then cache the encapsulated request resolution information in a preset system cache area; and in the subsequent detection process, the corresponding request resolution information can be extracted from the system cache area and input into the filtering link implementation class of the Tomcat server for detection and processing.

[0114] It is worth noting that the request parsing information is encapsulated based on the encapsulation implementation class so that the encapsulated request parsing information can be cached in the system cache area.

[0115] In addition, if Figure 8 As shown, an embodiment of the present application further provides an injection protection device 10, comprising:

[0116] The first processing module 100 is used to obtain a Hypertext Transfer Protocol HTTP request;

[0117] The second processing module 200 is used to parse the HTTP request based on the Tomcat server to obtain request parsing information;

[0118] The third processing module 300 is used to detect the request parsing information based on the filtering link implementation class of the Tomcat server to obtain the detection request source code;

[0119] The fourth processing module 400 is used to configure the detection request source code into the execution instance of the filtering link implementation class and execute the execution instance to obtain a code execution result;

[0120] The fifth processing module 500 is used to schedule the HTTP request according to the code execution result.

[0121] In one embodiment, a Hypertext Transfer Protocol HTTP request is first obtained; then, the request parsing information is detected based on the filtering link implementation class of the Tomcat server to obtain the detection request source code; then, the detection request source code is configured to the execution instance of the filtering link implementation class and the execution instance is executed to obtain the code execution result; finally, the HTTP request is scheduled according to the code execution result; through the above technical solution, the detection request source code is configured to the execution instance of the filtering link implementation class and the code execution result can be obtained according to the execution instance, and finally, the scheduling process is performed according to the code execution result, thereby being able to solve the injection attack problem at the code level.

[0122] It should be noted that Tomcat server is a free and open source network application server. It is a lightweight application server and is widely used in small and medium-sized systems and occasions where there are not many concurrent users. It is the first choice for developing and debugging Java Server Pages (JSP) programs. Tomcat server can run well and support network application deployment when running on Java. Tomcat server is a free and open source network application server. Due to its advanced technology and stable performance, it is deeply loved by Java enthusiasts and is currently a popular network application server.

[0123] It is worth noting that the filter chain implementation class in the Tomcat server is actually a variant implementation of the responsibility chain pattern; the filter chain implementation class includes three basic components, the first is the caller interface, there are two implementation classes: the first is the final call terminator; the second is the caller that calls the filter method. The second is the filter interface; the third is the filter chain constructor, which has two main functions, one is to load filters according to various conditions and various mechanisms, and the other is to construct the caller interface based on these filters.

[0124] It is worth noting that in object-oriented programming, a "class" is called an "instance" after instantiation; a "class" is static and does not occupy process memory, while an "instance" has dynamic memory; in a database, it represents a collection of some programs. Instances and objects are basically synonyms, and they can often be used interchangeably. An object represents a specific instance of a class, and an object has two characteristics: identity and attribute value; an instance is a specific representation of an object, operations can act on instances, instances can store operation results in a stateful manner, and instances are used to simulate concrete or prototype things that exist in the real world. An object is an instance of a class, and all objects are instances, but not all instances are objects; for example, an associated instance is not an object, it is just an instance, a connection, and common instances are instances of classes. At this time, there is no difference between the two, and instances other than instances of classes are not objects. In object-oriented programming, the process of creating objects using classes is usually called instantiation.

[0125] It can be understood that HTTP requests can be parsed and processed based on the Tomcat server, and then the request parsing information corresponding to the HTTP request can be obtained; and the request parsing information can be detected based on the filtering link implementation class of the Tomcat server to obtain the corresponding detection request source code; the detection request source code obtained above is configured into the execution instance of the filtering link implementation class and the code execution result can be obtained during the execution of the execution instance; finally, the corresponding HTTP request can be scheduled and processed according to the code execution result.

[0126] It is understandable that the injection in the embodiments of the present application may refer to structured query language injection, command injection, small text file tampering, sensitive file downloading, arbitrary file reading, slow database query, and printing of sensitive log information. Injection protection is to prevent the above injection behaviors from occurring. Exemplarily, injection protection can be to prevent structured query language injection, command injection, small text file tampering, sensitive file downloading, arbitrary file reading, slow database query, and printing of sensitive log information.

[0127] The specific implementation of the injection protection device is basically the same as the specific implementation example of the above-mentioned injection protection method, and will not be repeated here.

[0128] In addition, if Fig. 9 As shown, an embodiment of the present application further provides an electronic device 700 , which includes: a memory 720 , a processor 710 , and a computer program stored in the memory 720 and executable on the processor 710 .

[0129] The processor 710 and the memory 720 may be connected via a bus or in other ways.

[0130] The non-transient software programs and instructions required to implement the injection protection methods of the above embodiments are stored in the memory 720. When executed by the processor 710, the injection protection methods of the above embodiments are executed, for example, the above described injection protection methods are executed. Figure 1 Steps S100 to S500 of the method, Figure 2 Steps S210 to S220 of the method, Figure 3 Steps S310 to S320 of the method, Figure 4 Steps S410 to S420 of the method, Figure 5 Steps S510 to S520 of the method, Figure 6 Steps S521 to S522 of the method and Figure 7 Method steps S230 to S240 in.

[0131] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0132] In addition, an embodiment of the present application further provides a computer-readable storage medium, which stores computer-executable instructions, which are executed by a processor 710 or a controller, for example, by a processor 710 in the above-mentioned device embodiment, so that the above-mentioned processor 710 can execute the injection protection method in the above-mentioned embodiment, for example, execute the above-mentioned Figure 1 Steps S100 to S500 of the method, Figure 2 Steps S210 to S220 of the method, Figure 3 Steps S310 to S320 of the method, Figure 4 Steps S410 to S420 of the method, Figure 5 Steps S510 to S520 of the method, Figure 6 Steps S521 to S522 of the method and Figure 7 Method steps S230 to S240 in.

[0133] The above embodiments may be used in combination, and modules with the same name in different embodiments may be the same or different.

[0134] The above describes specific embodiments of the present application, and other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily have to be performed in the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0135] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and computer-readable storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0136] The apparatus, device, computer-readable storage medium and method provided in the embodiments of the present application correspond to each other. Therefore, the apparatus, device and non-volatile computer storage medium also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the corresponding apparatus, device and computer storage medium will not be repeated here.

[0137] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0138] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.

[0139] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0140] For the convenience of description, the above devices are described in terms of functions and are divided into various units. Of course, when implementing the embodiments of the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0141] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the embodiments of the present application may adopt the form of complete hardware embodiments, complete software embodiments, or embodiments in combination with software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0142] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0143] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0144] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0145] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0146] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0147] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0148] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0149] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.

[0150] Embodiments of the present application may be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. Embodiments of the present application may also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0151] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

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

Claims

1. An injection protection method, characterized in that: The method comprises: Get the Hypertext Transfer Protocol HTTP request; Parsing the HTTP request based on the Tomcat server to obtain request parsing information; Detecting the request parsing information based on the filtering link implementation class of the Tomcat server to obtain a detection request source code; configuring the detection request source code into the execution instance of the filtering link implementation class and executing the execution instance to obtain a code execution result; Scheduling the HTTP request according to the code execution result; The Tomcat server further includes a detection request implementation class, and the filtering link implementation class based on the Tomcat server detects the request parsing information to obtain the detection request source code, including: Performing a first detection process on the request parsing information based on the filter link implementation class to obtain request execution information; Performing a second detection process on the request execution information based on the detection request implementation class to obtain the detection request source code; The scheduling of the HTTP request according to the code execution result includes: Performing a second analysis on the code execution result to obtain request feedback information; Scheduling the HTTP request according to the request feedback information; The request feedback information is request passing information or request failing information, and the scheduling of the HTTP request according to the request feedback information includes: When the request feedback information is the request passing information, performing response processing on the corresponding HTTP request; When the request feedback information is information that the request is not passed, the corresponding HTTP request is intercepted.

2. The injection protection method according to claim 1, characterized in that: The Tomcat server includes a connector and a container, and the step of parsing the HTTP request based on the Tomcat server to obtain request parsing information includes: Performing a first analysis on the HTTP request based on the connector to obtain request attribution information; The set resolution information in the container is matched with the request attribution information to obtain the request resolution information.

3. The injection protection method according to claim 1, characterized in that: The configuring the detection request source code into the execution instance of the filtering link implementation class and executing the execution instance to obtain the code execution result includes: Configuring the detection request source code to the beginning of the execution instance to obtain the detection code; The HTTP request is executed based on the detection code to obtain a code execution result.

4. The injection protection method according to claim 1, characterized in that: The Tomcat server further includes an encapsulation implementation class. Before the filtering link implementation class based on the Tomcat server detects the request parsing information to obtain the detection request source code, the method further includes: Encapsulate the request parsing information based on the encapsulation implementation class; The encapsulated request parsing information is cached in a preset system cache area.

5. An injection protection device, characterized in that: The device comprises: A first processing module, used for obtaining a Hypertext Transfer Protocol HTTP request; A second processing module is used to parse the HTTP request based on the Tomcat server to obtain request parsing information; A third processing module is used to detect the request parsing information based on the filtering link implementation class of the Tomcat server to obtain a detection request source code; A fourth processing module, configured to configure the detection request source code into the execution instance of the filtering link implementation class and execute the execution instance to obtain a code execution result; A fifth processing module, configured to schedule the HTTP request according to the code execution result; The Tomcat server further includes a detection request implementation class, and the filtering link implementation class based on the Tomcat server detects the request parsing information to obtain the detection request source code, including: Performing a first detection process on the request parsing information based on the filter link implementation class to obtain request execution information; Performing a second detection process on the request execution information based on the detection request implementation class to obtain the detection request source code; The scheduling of the HTTP request according to the code execution result includes: Performing a second analysis on the code execution result to obtain request feedback information; Scheduling the HTTP request according to the request feedback information; The request feedback information is request passing information or request failing information, and the scheduling of the HTTP request according to the request feedback information includes: When the request feedback information is the request passing information, performing response processing on the corresponding HTTP request; When the request feedback information is information that the request is not passed, the corresponding HTTP request is intercepted.

6. An electronic device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the injection protection method as described in any one of claims 1 to 4 when executing the computer program.

7. A computer-readable storage medium storing computer-executable instructions, characterized in that: The computer executable instructions are used to execute the injection protection method described in any one of claims 1 to 4.