Spring Cloud Gateway-based network hostile attack defense method and device
By implementing IP and URL filtering and frequency recording of external access signals on Spring Cloud Gateway, combined with the sentinel function and machine learning algorithm, it solves the problems of difficult identification and limited tracking of malicious network attacks in existing technologies, and achieves high efficiency. , low-cost defense effect.
Patent Information
- Application Number
- CN202410797792.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-10-15
AI Technical Summary
In terms of defending against malicious network attacks, existing technologies have problems such as difficulty in identification, limited tracking, weak monitoring, and single defense means, resulting in high costs.
Adopt a network malicious attack defense method based on Spring Cloud Gateway, filter and review the IP and URL of external access signals, identify abnormal IP and URL, record the access frequency, add to the blacklist, block malicious access, and use the sentinel function and Machine learning algorithms enhance defense capabilities.
It achieves efficient identification and blocking of malicious network attacks, reduces maintenance costs, improves the defense capabilities of software systems, and makes defense responses increasingly faster, more accurate, and more intelligent.
Smart Images

Figure CN118784279A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer network defense technology, and specifically to a network malicious attack defense method and device based on Spring Cloud Gateway. Background Art
[0002] Computer software system security is the idea of ensuring that the software can continue to run correctly even when it is attacked maliciously and that the software is used legally within the scope of authorization. However, the current worsening threat environment of computer network attacks has made the software systems of many enterprises and institutions difficult to identify, difficult to track, with limited monitoring, weak defense, and single defense means in terms of defending against external network malicious attacks. Most current network technologies use simple mechanical methods such as firewalls, manual filling of IP whitelists, API access authorization, and data encryption to defend against network malicious attacks. With the upgrading of network attack technology, network attacks are becoming more and more complex and there are more and more scenarios. The simple network defense strategies in the past can no longer meet the current network security requirements. The cost of purchasing third-party network security products to strengthen the security defense of enterprise and institution software systems is getting higher and higher.
[0003] Therefore, a network malicious attack defense method and device based on Spring Cloud Gateway has become an urgent problem to be solved. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a more efficient, lower-cost, and better defensive method and device for defending against malicious network attacks based on Spring Cloud Gateway, which can not only improve the software system's ability to defend against network attacks, but also effectively reduce the cost of maintaining the system for enterprises and institutions.
[0005] In order to solve the above technical problems, the technical solution provided by the present invention is: a network malicious attack defense method based on Spring Cloud Gateway, when the external access signal passes through the security device of Spring Cloud Gateway, the IP and URL of the signal are filtered, reviewed and processed;
[0006] When the security device detects abnormal IP access, such as exceeding the set access threshold or matching the abnormal IP library, the abnormal IP can be added to the blacklist to prohibit the IP from accessing;
[0007] When the security device captures external access to the host software system URL, it matches the URL, URL input parameters, and output parameters with sensitive word libraries, records the number of URL accesses, counts the frequency of URL accesses within a certain time range, and registers sensitive input and output parameter data; when the security device detects abnormal input parameters and maliciously obtains sensitive information, it adds the accessing IP to the blacklist, prohibits the IP from accessing, and closes the URL's access rights, and the software interface stops providing services to the outside world.
[0008] Furthermore, the security device provides a human-machine interface, which can erase the misjudged IP and restore the access of the IP through manual intervention; it is also used to manually erase or add the access rights of the URL.
[0009] Furthermore, the security device obtains the IP address of the access end based on the request instance of ServerHttpRequest of Spring Cloud Gateway, saves the request record of the IP address to a cache database or a relational database, and records the number of accesses of the IP, calculates the IP access frequency within a certain time interval, compares the IP access frequency with the set threshold, identifies whether the IP is a malicious IP, and records it in the IP library.
[0010] Furthermore, when the security device identifies a malicious IP, the Spring Cloud Gateway chain filter chain.filter no longer filters further and directly blocks the IP access, and at the same time returns access-forbidden status information to the access end through the response instance of the ServerHttpResponse of Spring CloudGateway.
[0011] Furthermore, the security device obtains the URL for accessing the system based on the request instance of ServerHttpRequest of Spring Cloud Gateway, saves the URL record to a cache database or a relational database, records the number of times the URL is accessed, calculates the URL access frequency within a certain time interval, compares the URL access frequency with a set threshold, identifies whether the URL is maliciously attacked, and records it in the URL library.
[0012] Furthermore, the security device obtains the data fields and contents returned by the URL accessing the system based on the response instance of ServerHttpRequest of Spring Cloud Gateway, matches the data fields and contents returned by the URL with the sensitive information database, identifies whether the URL is a sensitive information URL, and can identify whether the URL has been maliciously attacked to obtain sensitive information based on the access frequency and input rules, and record it in the sensitive vocabulary.
[0013] Furthermore, the security device has a sentinel function, and the sentinel manually selects whether to participate in the duty. The sentinel marks according to the device's malicious IP registry, malicious URL input parameter characteristics, and sensitive word attack characteristics, and notifies the blocking device; the security device has a blocking access algorithm for receiving sentinel signals, blocking the attack source, and updating the attack characteristics to the IP registry, URL table, and sensitive word library table; the security device has a learning algorithm for the IP library, URL library, and sensitive word library, outputs malicious IP registry information, malicious URL input parameter information, and sensitive word library information, and provides a sentinel duty registration form.
[0014] Furthermore, the safety device provides a configuration file, a human-machine interface or a human-machine operation page, and manually configures whether the sentry participates in the duty and selects the duty period; when the sentry is in the duty state, the sentry works; when the sentry is in the closed state, the sentry stops working.
[0015] Furthermore, the sentinel marks according to the malicious IP registry, malicious URL input parameter characteristics, and sensitive word attack characteristics of the security device. The sentinel's built-in algorithm reads the IP table, the URL library, and the sensitive words, and can perform precise and fuzzy matching with the obtained visiting IP, URL, and RUL input parameters, and identify whether it is a malicious attack, and notify the blocking device.
[0016] The present invention also provides a network malicious attack defense device based on Spring Cloud Gateway, comprising
[0017] The main switch of the device is used to control whether the device is turned on or off;
[0018] Device classification switch, used to control the device classification function, to control the opening or closing of defense categories by classification, and to control the opening or closing of software resources by classification;
[0019] Device threshold configuration items are used to dynamically control the device calculation threshold range, so as to identify effective and invalid risks and find the best threshold setting value or range;
[0020] Algorithm module, used to obtain the IP algorithm for accessing the software system, count the number of IP accesses within a certain time range, IP source, IP routing, and the calculation algorithm for comparing the number of IP accesses with the threshold; it is also used to identify malicious attacks on access IPs, filter access IPs and block access; it is also used to obtain the access interface URL, identify sensitive data for URL return data, store data features, calculate URL access traffic, identify abnormal traffic, monitor URL access frequency, identify malicious access to sensitive information of the interface, self-learn sensitive data features, enhance the sensitive data vocabulary, and improve the robustness of defense functions;
[0021] The storage module is used to record and store access IPs and IP behaviors, assisting the device in self-learning and self-capability enhancement.
[0022] The advantages of the present invention compared with the prior art are: the present invention can identify network malicious attack IPs, track attack IP routing, monitor attacked interfaces, identify sensitive information, monitor abnormal traffic, monitor attack frequency, and automatically block attack sources or shut down attacked software system resources, thereby protecting software system security to the greatest extent. At the same time, the device has sentinel, self-learning, and self-enhancement functions, making the defense response faster, more accurate, and more intelligent. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a partial functional schematic diagram of the present invention.
[0024] Figure 2 It is a schematic diagram of the device deployment of the present invention.
[0025] Figure 3 This is the flow chart of obtaining IP in the present invention.
[0026] Figure 4 This is a flow chart of blocking access to an access IP according to the present invention.
[0027] Figure 5 It is a flow chart of the algorithm for obtaining the access interface URL of the present invention.
[0028] Figure 6 It is a flow chart of the algorithm for identifying sensitive data of URL return data of the present invention.
[0029] Figure 7 It is a schematic diagram of the sentinel function of the present invention.
[0030] Figure 8 The sentinel of the present invention is based on the malicious IP registry of the security device, the malicious URL input parameter characteristics, and the sensitive word attack feature workflow diagram.
[0031] Fig. 9The K-nearest neighbor algorithm used in the present invention uses proximity to classify or predict groups of single data points and find similar points near each other.
[0032] Fig.10 It is a flow chart of the algorithm of the present invention that enhances the ability of the device to identify malicious attacks through a machine learning algorithm. DETAILED DESCRIPTION
[0033] The following is a further detailed description of a network malicious attack defense method and device based on Spring Cloud Gateway of the present invention in conjunction with the accompanying drawings.
[0034] Combined with Figure 1-10 The specific implementation process of the network malicious attack defense method and device based on Spring Cloud Gateway of the present invention is as follows:
[0035] A Spring Cloud-based The network malicious attack defense device of Gateway includes the following: the main switch of the device is installed to control whether the device is turned on or off; the hierarchical switch of the device is installed to control the hierarchical function of the device, hierarchically control the opening or closing of the defense category, and hierarchically control the opening or closing of the software resources; the threshold configuration item of the device is used to dynamically control the threshold range of the device calculation, so as to identify effective risks and invalid risks and find the best threshold setting value or range; the device has an algorithm module, which has several algorithms built in the algorithm module, specifically including an algorithm for obtaining the IP (IP routing) of the access software system, counting the number of IP accesses within a certain time range, the IP source, the IP routing, and the calculation algorithm for comparing the number of IP accesses with the threshold; it has the function of recording and storing the access IP and IP behavior, which is used for the self-learning and self-capability enhancement of the device; it has an algorithm for identifying malicious attacks on the access IP, which can filter the access IP and block the access; it has an algorithm for obtaining the URL of the access interface, an algorithm for identifying sensitive data of the URL return data, a data feature storage function, an algorithm for calculating the URL access traffic, an algorithm for identifying abnormal traffic, an algorithm for monitoring the URL access frequency, an algorithm for identifying malicious acquisition of sensitive information of the interface, and the ability to self-learn the characteristics of sensitive data, enhance the sensitive data vocabulary, and improve the robustness of the defense function.
[0036] In some embodiments of the present application, for the installation of the main switch of the device, the device may provide a configuration file, a human-machine interface or an operable interface, and the device may be manually switched on or off.
[0037] In some embodiments of the present application, for installing a device classification switch, the device may provide a configuration file, a human-machine interface, or an operable interface, and the device classification function may be manually switched on or off.
[0038] In some embodiments of the present application, for device threshold configuration items, the device may provide IP access frequency threshold settings and URL access frequency threshold settings.
[0039] A network malicious attack defense method based on Spring Cloud Gateway, in which a security device can be installed and run in the Spring Cloud framework software system, and the security device can intercept external requests, so that all network requests to the host software system pass through the Spring Cloud Gateway security device. The security device can be selected to be on or off. If the security device is on, the security device begins to guard the host outside the software system. If the host receives an external access signal in the software system, the security device will filter, review and process the external access IP and URL; if the security device is off, the security device will not monitor the host software system.
[0040] When the security device detects abnormal IP access, such as exceeding the set access threshold or matching the abnormal IP library, the abnormal IP can be added to the blacklist to prohibit the IP's access. At the same time, a human-machine interface is provided to erase the misjudged IP through manual intervention and restore the IP's access.
[0041] When the security device captures external access to the URL of the host software system, the security device matches the URL, URL input parameter, and output parameter with a sensitive word library, records the number of URL accesses, counts the frequency of URL accesses within a certain time range, and registers sensitive input and output parameter data. When the security device detects abnormal input parameters and maliciously obtains sensitive information, such as frequent changes in access token rules, excessive deviations between access input parameters and normal input parameters, or the frequency of URL access exceeds the set threshold, the security device will add the accessed IP to the blacklist, prohibit the IP from accessing, and close the access rights of the URL, and the software interface will not provide services to the outside. The security device also provides a human-machine interface that can be used to manually erase or add URL access rights. This effectively prevents external malicious attacks on the host system, thereby ensuring the security of the software system to the greatest extent.
[0042] The security device has the ability to self-learn. With the enrichment of the access IP library and URL input and output parameter vocabulary, and the learning of attack characteristics, the security device can identify effective attacks more and more quickly and accurately, thereby reducing the work of manual secondary judgment.
[0043] In some embodiments of the present application, the security device has the function of obtaining the IP of the access software system (IP routing). The security device can obtain the IP address of the access end based on the request instance of ServerHttpRequest of Spring Cloud Gateway, save the request record of the IP address to a cache database or a relational database, and record the number of accesses of the IP, calculate the IP access frequency within a certain time interval, compare the IP access frequency with the set threshold, identify whether the IP is a malicious IP, and record it in the IP library.
[0044] Among them, some algorithms for obtaining IP (IP routing) are as follows:
[0045]
[0046] Part of the algorithm for calculating IP access frequency is as follows:
[0047]
[0048]
[0049]
[0050] In some embodiments of the present application, when blocking access to an access IP, the security device identifies a malicious IP, and the Spring Cloud Gateway link filter chain.filter no longer filters downwards, but directly blocks access to the IP, and at the same time returns access-prohibited status information to the access end through the response instance of the ServerHttpResponse of the Spring Cloud Gateway.
[0051] In some embodiments of the present application, the security device has an algorithm for obtaining the access interface URL. The security device obtains the URL for accessing the system based on the request instance of ServerHttpRequest of Spring Cloud Gateway, saves the URL record to a cache database or a relational database, and records the number of times the URL is accessed. The URL access frequency is calculated within a certain time interval, and the URL access frequency is compared with a set threshold to identify whether the URL is maliciously attacked and record it in the URL library.
[0052] Among them, part of the algorithm for obtaining the access interface URL is as follows:
[0053] ServerHttpRequest request=exchange.getRequest();
[0054] ServerHttpResponse response=exchange.getResponse();
[0055] String path=request.getURI().getPath();
[0056] Part of the algorithm for obtaining the input parameters of the visited URL is as follows:
[0057] ServerHttpRequest request=exchange.getRequest();
[0058] ServerHttpResponse response=exchange.getResponse();
[0059] Flux <databuffer>body = request.getBody();
[0060] In some embodiments of the present application, when identifying sensitive data in URL return data, the security device obtains the data fields and content returned by the URL accessing the system based on the response instance of ServerHttpRequest of Spring Cloud Gateway, matches the data fields and content returned by the URL with the sensitive information database, and identifies whether the URL is a sensitive information URL. It can identify whether the URL has been maliciously attacked to obtain sensitive information based on the access frequency and input rules, and record it in the sensitive vocabulary.
[0061] In some embodiments of the present application, the security device has a sentinel function, and the sentinel can manually choose whether to participate in the duty. The sentinel can mark according to the malicious IP registry of the security device, the malicious URL input parameter characteristics, and the sensitive word attack characteristics, and notify the blocking device; the security device has a blocking access algorithm for receiving the sentinel signal, blocking the attack source, and updating the attack characteristics to the IP registry, URL table and sensitive word library table; the security device has a learning algorithm for the IP library, URL library and sensitive word library, outputs the malicious IP registry information, malicious URL input parameter information, sensitive word library information, and provides a sentinel duty registration form.
[0062] Part of the algorithm of the blocking device is as follows:
[0063] log.info("========No permission to access========");
[0064] String responseDataStr = JSON.toJSON(ResponseData.error(HttpStatus.FORBIDDEN.value(),"forbidden to acc interface is closed or not authorized to access")).toString();
[0065] byte[]bytes=responseDataStr.getBytes(StandardCharsets.UTF_8);
[0066] DataBuffer buffer=response.bufferFactory().wrap(bytes);
[0067] response.setStatusCode(HttpStatus.FORBIDDEN);
[0068] return response.writeWith(Mono.just(buffer));
[0069] In some embodiments of the present application, the security device provides a configuration file, and the human-machine interface or human-machine operation page manually configures whether the sentinel participates in duty and selects the duty period. The security device only works when the sentinel is in duty state, and stops working when the sentinel is in off state.
[0070] In some embodiments of the present application, the Sentinel can mark according to the malicious IP registry of the security device, the malicious URL input parameter characteristics, and the sensitive word attack characteristics. The Sentinel's built-in algorithm reads the IP table, the URL library, and the sensitive words, and can perform precise matching and fuzzy matching with the obtained visiting IP, URL, and RUL input parameters, and identify whether it is a malicious attack, and notify the blocking device.
[0071] In some embodiments of the present application, the security device can prohibit further access by the IP through the filter algorithm of Spring Cloud Gateway to achieve a blocking effect. The security device has a built-in algorithm for receiving sentinel signals, receives and processes sentinel messages, and updates the attack features to the IP registry, URL table, and sensitive word library table.
[0072] In some embodiments of the present application, the security device has a learning algorithm for the IP library, URL library and sensitive word library, outputs malicious IP registration table information, malicious URL input parameter information, sensitive word library information, and provides a sentinel duty registration table. The security device stores the acquired IP information, URL information, and sensitive word information, extracts and summarizes the IP attack frequency, URL input parameters, and sensitive words through a feature extraction algorithm, classifies the IP type, URL importance level, and sensitive word frequency through a classification algorithm, performs classification processing through a k-nearest neighbor algorithm (KNN algorithm), and other machine learning algorithms to provide a set of identifiable malicious attack registration tables for the sentinel to extract.
[0073] K-Nearest Neighbors algorithm is a machine learning technique and algorithm that can be used for regression and classification tasks. Fig. 9 , which uses proximity to classify or predict groupings of individual data points, finding similar points near each other.
[0074] In order to determine which IP segments are closer to the malicious IPs that have been captured, which URL input fields are closer to the preset sensitivity fields, and which data words are closest to the given sensitive data, it is necessary to calculate the distance between the sensitive words and the captured data. The Euclidean distance calculation formula in KNN needs to be used, as shown in Formula 1.
[0075]
[0076] The K-nearest neighbor algorithm is as follows:
[0077] from sklearn.neighbors import KNeighborsClassifier
[0078] model_name='K-Nearest Neighbor Classifier'
[0079] `kNN`Classifier=KNeighborsClassifier(n_neighbors=5,metric='minkowski',p=2)
[0080] `kNN`_model=Pipeline(steps=[('preprocessor',preprocessorForFeatures),('classifier',`kNN`Classifier)])
[0081] `kNN`_model.fit(X_train,y_train)
[0082] Enhance the device's ability to identify malicious attacks through machine learning algorithms. The algorithm flow is as follows Fig.10 As shown, part of the algorithm uses a recursive algorithm.
[0083] F(1)=1, F(2)=1, F(n)=F(n-1)+F(n-2)(n>=3, n∈N*)
[0084] The present invention and its embodiments are described above, and such description is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. In short, if ordinary technicians in the field are inspired by it, without departing from the purpose of the invention, they can design a structure and embodiment similar to the technical solution without creativity, which should belong to the protection scope of the present invention.< / databuffer>
Claims
1. A network malicious attack defense method based on Spring Cloud Gateway, characterized by: When external access signals pass through the security device of Spring Cloud Gateway, the IP and URL of the signal are filtered, reviewed, and processed; When the security device detects abnormal IP access, such as exceeding the set access threshold or matching the abnormal IP library, the abnormal IP can be added to the blacklist to prohibit the IP from accessing; When the security device captures external access to the URL of the host software system, it matches the URL, URL input parameter, and output parameter with a sensitive word library, records the number of URL accesses, counts the frequency of URL accesses within a certain time range, and registers the sensitive input and output parameter data; When the security device detects abnormal input parameters and maliciously obtains sensitive information, the access IP is added to the blacklist, prohibiting the IP from accessing, and closing the access rights of the URL. The software interface does not provide services to the outside world.
2. According to claim 1, a network malicious attack defense method based on Spring Cloud Gateway is characterized in that: The security device provides a human-machine interface to erase the misjudged IP and restore the access of the IP through manual intervention; it is also used to manually erase or add URL access rights.
3. According to claim 2, a network malicious attack defense method based on Spring Cloud Gateway is characterized in that: The security device obtains the IP address of the access end based on the request instance of ServerHttpRequest of Spring Cloud Gateway, saves the request record of the IP address to a cache database or a relational database, records the number of visits of the IP, calculates the IP access frequency within a certain time interval, compares the IP access frequency with the set threshold, identifies whether the IP is a malicious IP, and records it in the IP library.
4. According to claim 3, a network malicious attack defense method based on Spring Cloud Gateway is characterized in that: When the security device identifies a malicious IP, the Spring Cloud Gateway chain filter chain.filter no longer filters further and directly blocks IP access. At the same time, it returns access-forbidden status information to the access end through the response instance of Spring CloudGateway's ServerHttpResponse.
5. According to claim 4, a network malicious attack defense method based on Spring Cloud Gateway is characterized in that: The security device obtains the URL for accessing the system based on the request instance of ServerHttpRequest of Spring Cloud Gateway, saves the URL record to a cache database or a relational database, records the number of times the URL is accessed, calculates the URL access frequency within a certain time interval, compares the URL access frequency with a set threshold, identifies whether the URL is maliciously attacked, and records it in the URL library.
6. According to claim 5, a network malicious attack defense method based on Spring Cloud Gateway is characterized in that: The security device obtains the data fields and content returned by the URL accessing the system based on the response instance of ServerHttpRequest of Spring Cloud Gateway, matches the data fields and content returned by the URL with the sensitive information database, identifies whether the URL is a sensitive information URL, and can identify whether the URL is maliciously attacked to obtain sensitive information based on the access frequency and input rules, and record it in the sensitive vocabulary.
7. A network malicious attack defense method based on Spring Cloud Gateway according to any one of claims 1 to 6, characterized in that: The security device has a sentinel function. The sentinel manually selects whether to participate in the guard duty. The sentinel marks according to the device malicious IP registry, malicious URL input parameter characteristics, and sensitive word attack characteristics, and notifies the blocking device; the security device has a blocking access algorithm for receiving sentinel signals, blocking the attack source, and updating the attack characteristics to the IP registry, URL table, and sensitive word library table; The security device has a learning algorithm for the IP library, URL library and sensitive word library, outputs malicious IP registration table information, malicious URL input parameter information, sensitive word library information, and provides a sentinel duty registration table.
8. According to claim 7, a network malicious attack defense method based on Spring Cloud Gateway is characterized in that: The safety device provides a configuration file, a human-machine interface or a human-machine operation page, and manually configures whether the sentry participates in the duty and selects the duty period; when the sentry is in the duty state, the sentry works; when the sentry is in the closed state, the sentry stops working.
9. According to claim 8, a network malicious attack defense method based on Spring Cloud Gateway is characterized in that: The sentinel marks according to the malicious IP registry, malicious URL input characteristics, and sensitive word attack characteristics of the security device. The sentinel's built-in algorithm reads the IP table, the URL library, and the sensitive words, and can perform precise and fuzzy matching with the obtained visiting IP, URL, and RUL input parameters, and identify whether it is a malicious attack, and notify the blocking device.
10. A network malicious attack defense device based on Spring Cloud Gateway, characterized by: include The main switch of the device is used to control whether the device is turned on or off; Device classification switch, used to control the device classification function, to control the opening or closing of defense categories by classification, and to control the opening or closing of software resources by classification; Device threshold configuration items are used to dynamically control the device calculation threshold range, so as to identify effective and invalid risks and find the best threshold setting value or range; Algorithm module, used to obtain the IP algorithm for accessing the software system, count the number of IP accesses within a certain time range, IP source, IP routing, and compare the IP accesses with the threshold value. It is also used to identify malicious attacks on access IPs, filter access IPs, and block access. It is also used to obtain access interface URLs, identify sensitive data in URL return data, store data features, calculate URL access traffic, identify abnormal traffic, monitor URL access frequency, identify malicious access to interface sensitive information, self-learn sensitive data features, enhance sensitive data vocabulary, and improve the robustness of defense functions; The storage module is used to record and store access IPs and IP behaviors, assisting the device in self-learning and self-capability enhancement.
