Authorized communication method, device, computer equipment and storage medium

By using random numbers and port number ranges for SPA authentication between the client and the gateway, the problem of single-packet authorization authentication being easily bypassed in NAT scenarios is solved, improving security and port privacy protection, and reducing the burden on the server. overhead.

CN118300899BActive Publication Date: 2024-10-18XINHUA SAN IND INTERNET CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410720217.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-05
Publication Date
2024-10-18
Estimated Expiration
2044-06-05

AI Technical Summary

Technical Problem

In a Network Address Translation (NAT) scenario, Single Package Authorization (SPA) authentication can easily be bypassed, allowing illegal terminals to access the server without authentication, posing security risks.

Method used

By randomly generating a random number and specifying a port number range on the client, the SPA message is encapsulated and sent to the gateway. The gateway selects the destination port number from the port number range according to the preset mapping rules, and opens access permissions after successful authentication. The client and server communicate based on random ports to prevent accurate access by illegal terminals.

Benefits of technology

Effectively prevent knocking and amplifying vulnerabilities, improve security, ensure port privacy, and reduce server overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118300899B_ABST
    Figure CN118300899B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of communication technology, and discloses an authorized communication method, device, computer equipment and storage medium, the method comprising: randomly generating a random number, and specifying a port number range of a server to be accessed; encapsulating a SPA message according to authentication information; the authentication information comprises a random number, a port number range and a source IP address of a client; based on a user datagram protocol, sending a SPA message to a server, instructing a gateway to open the permission to access a destination port corresponding to a destination port number; the destination port number is a port number within a port number range mapped from a random number according to a preset mapping rule. In the present invention, communication between a client and a server is realized based on a random port, so that an illegal terminal that has not been authenticated by SPA is difficult to accurately access the server based on the random port, thereby effectively preventing a knock-on amplification vulnerability and improving security; the gateway can also determine whether the source port number in the connection message is consistent, further ensuring communication security.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to an authorization communication method, device, computer equipment and storage medium. Background Art

[0002] In a zero-trust architecture, the legitimacy of the terminal is generally authenticated through single packet authorization (SPA) authentication, and the public network source IP address of the legitimate terminal is released to shield most network attacks from illegal users.

[0003] However, in the Network Address Translation (NAT) scenario, multiple terminals in the LAN may use the same public source IP address, causing other terminals to bypass single-packet authorization authentication without SPA authentication and access the server normally, posing a security risk. Summary of the invention

[0004] In view of this, the present invention provides an authorization communication method, apparatus, computer equipment and storage medium to solve the problem that single-packet authorization authentication is easily bypassed.

[0005] In a first aspect, the present invention provides an authorization communication method, applied to a client, comprising:

[0006] Generate a random number randomly and specify the port number range of the server to be accessed;

[0007] Encapsulating a SPA message according to authentication information; the authentication information includes the random number, the port number range and the source IP address of the client;

[0008] Based on the User Datagram Protocol, the SPA message is sent to the gateway, instructing the gateway to open access to the destination port corresponding to the destination port number; the destination port number is mapped to the port number within the port number range by the random number according to a preset mapping rule.

[0009] In some optional embodiments, the method further comprises:

[0010] According to the preset mapping rule, mapping the random number to the destination port number within the port number range;

[0011] After sending the SPA message to the gateway, a first connection message for establishing a communication connection with a destination port corresponding to the destination port number is sent to the gateway; the first connection message includes a first source port number.

[0012] In a second aspect, the present invention provides an authorization communication method, applied to a gateway, comprising:

[0013] Obtain SPA message sent by the client based on the User Datagram Protocol;

[0014] Parsing the SPA message to extract corresponding authentication information; the authentication information includes a random number, a port number range of the server requested by the client to access, and a source IP address of the client;

[0015] Performing authentication processing on the client according to the authentication information;

[0016] If the authentication is successful, the random number is mapped to a port number within the port number range according to the preset mapping rule as the destination port number allowed to be accessed by the client, and the source IP address is allowed to access the destination port corresponding to the destination port number.

[0017] In some optional implementations, the step of opening the permission for the source IP address to access the destination port corresponding to the destination port number includes:

[0018] A first firewall rule is set; the first firewall rule is used to allow the source IP address to access the destination port.

[0019] In some optional embodiments, the method further comprises:

[0020] Determining whether the client has a network address translation according to the SPA message;

[0021] In the case where network address translation exists on the client, a second firewall rule is set according to a first connection message sent by the client; the first connection message includes a first source port number, and the second firewall rule is used to prevent other source ports corresponding to the source IP address, except the source port corresponding to the first source port number, from accessing the destination port.

[0022] In some optional implementations, setting a second firewall rule according to the first connection message sent by the client includes:

[0023] Setting a conversion mark for the authentication information of the client to indicate that a network address conversion exists on the client;

[0024] After obtaining the first connection message sent by the client, determining whether the authentication information of the client is provided with a conversion mark;

[0025] In a case where the authentication information of the client is provided with a conversion mark, a second firewall rule is set according to the first connection message sent by the client.

[0026] In some optional implementations, after setting the second firewall rule, the method further includes:

[0027] In the case of obtaining a second connection message from the source IP address for establishing a communication connection with the destination port, determining a second source port number in the second connection message;

[0028] According to the second firewall rule, determining whether the second source port number is the same as the first source port number;

[0029] When the second source port number is the same as the first source port number, forwarding the second connection message to the server;

[0030] When the second source port number is different from the first source port number, the second connection message is intercepted.

[0031] In some optional implementations, determining whether the client has network address translation according to the SPA message includes:

[0032] Parsing the first source IP address in the message header and the second source IP address in the message payload of the SPA message;

[0033] Determine whether the first source IP address is the same as the second source IP address;

[0034] When the first source IP address is different from the second source IP address, it is determined that network address translation exists on the client.

[0035] In a third aspect, the present invention provides an authorization communication device, applied to a client, the device comprising:

[0036] A preprocessing module is used to randomly generate random numbers and specify the port number range of the server requested to access;

[0037] An encapsulation module, used to encapsulate the SPA message according to the authentication information; the authentication information includes the random number, the port number range and the source IP address of the client;

[0038] The sending module is used to send the SPA message to the gateway based on the User Datagram Protocol, instructing the gateway to open the permission to access the destination port corresponding to the destination port number; the destination port number is the port number within the port number range mapped by the random number according to the preset mapping rule.

[0039] In a fourth aspect, the present invention provides an authorization communication device, applied to a gateway, the device comprising:

[0040] An acquisition module, used to acquire SPA messages sent by the client based on the User Datagram Protocol;

[0041] A parsing module, used to parse the SPA message and extract corresponding authentication information; the authentication information includes a random number, a port number range of the server requested by the client to access, and a source IP address of the client;

[0042] An authentication module, used to authenticate the client according to the authentication information;

[0043] The processing module is used to select a destination port number that the client is allowed to access from the port number range according to the random number in accordance with a preset mapping rule when the authentication is successful, and to open the source IP address to the destination port corresponding to the destination port number.

[0044] In a fifth aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the authorization communication method of the first aspect, the second aspect or any corresponding embodiment thereof by executing the computer instructions.

[0045] In a sixth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the authorization communication method of the first aspect, the second aspect or any corresponding embodiment thereof.

[0046] In a seventh aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the authorization communication method of the first aspect, the second aspect or any corresponding embodiment thereof.

[0047] In the embodiment of the present invention, the client encapsulates the SPA message based on the random number and the port number range to perform SPA authentication. The gateway can randomly select the destination port number from the port number range according to the random number. The client and the server communicate based on the random port, making it difficult for illegal terminals that have not passed the SPA authentication to accurately access the server based on the random port, thereby effectively preventing the door-knocking amplification vulnerability and improving security. In addition, the client performs authorization authentication through the UDP SPA method, which can ensure port privacy and has little impact on the server's overhead. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0049] Figure 1 It is a flowchart of single-package authorization authentication;

[0050] Figure 2 It is a flow chart of the third-generation single-package authorization authentication;

[0051] Figure 3 is a flow chart of an authorization communication method according to an embodiment of the present invention;

[0052] Figure 4 This is a schematic diagram of SPA message encapsulation and parsing according to an embodiment of the present invention;

[0053] Figure 5 is a flow chart of another authorization communication method according to an embodiment of the present invention;

[0054] Figure 6 This is a communication schematic diagram in a NAT scenario according to an embodiment of the present invention;

[0055] Figure 7 is a flow chart of another authorization communication method according to an embodiment of the present invention;

[0056] Figure 8 is a structural block diagram of an authorization communication device of a client according to an embodiment of the present invention;

[0057] Fig. 9 is a structural block diagram of an authorization communication device of a gateway according to an embodiment of the present invention;

[0058] Fig.10 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0059] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0060] With the rapid development of the Internet era, digital transformation of enterprises has become a must for survival. Enterprises need to use digital technology to fundamentally change their business models and operating methods, helping them capture new data insights and achieve faster decision-making and innovation. In the context of digital transformation, enterprises are facing significant changes in personnel cooperation and access methods:

[0061] Cloud services and applications: Enterprises are increasingly relying on cloud infrastructure and applications to support remote collaboration and data sharing among employees.

[0062] Mobile office: With the popularity of smartphones and tablets, employees can access corporate resources through these mobile devices anytime and anywhere, facilitating the possibility of working from home, working on the road, or working on-site at a client's site.

[0063] Collaboration tools: There has been an increase in the use of video conferencing, instant messaging, project management software, and shared workspaces, which enable real-time communication, file sharing, and project collaboration.

[0064] Together, these changes have shaped a more dynamic and flexible work environment, improving productivity and employee satisfaction, while also bringing new challenges to corporate management strategies.

[0065] In scenarios such as mobile office, users are increasingly using remote connections to access corporate networks to meet various office needs. However, the access ports that provide services for remote connections are exposed on the Internet, becoming a major disaster area for network malicious attacks. Through such an exposed portal, hackers use all means to find service vulnerabilities, compromise remote connection servers, and enter corporate networks to steal resources or cause damage. Enterprises are in urgent need of upgrading the security capabilities of remote connections and using zero-trust systems to upgrade the security capabilities of remote connections.

[0066] Zero-trust architecture prevents network threats and has introduced a core technology: single packet authorization authentication, namely SPA (Single Packet Authorization) authentication. This is a special authentication method that protects service ports from attacks, that is, a single data packet carries authentication and identification information, so that authorization is obtained after authentication is completed, and then access to the business is allowed. The gateway (a firewall can be deployed in the gateway) will only open the specified destination port to the client's IP after receiving the SPA message sent by the client and verifying its legitimacy. With SPA technology, unauthenticated clients cannot see the business assets hidden behind, let alone access or attack. This can block most network attacks from illegal users and make vulnerability detection, DDoS (Distributed Denial of Service) and other attack methods ineffective.

[0067] The first generation of SPA authentication uses UDP (User Datagram Protocol) SPA technology, such as Figure 1 As shown in the figure, the interaction process mainly includes:

[0068] 1) Single-packet knocking initiation: The client encapsulates a SPA message and sends the SPA message to the gateway to initiate a single-packet knocking to the gateway; the SPA message can also be called a SPA data packet, a SPA knocking packet, etc.

[0069] 2) Authentication verification and authorization release: After the gateway verifies the SPA message, it releases the client's public network source IP and opens the destination port to the client.

[0070] 3) Normal access to applications: The terminal where the public network source IP is located (that is, the terminal where the knocking client is located) can normally access the protected application on the server side.

[0071] The first generation of SPA authentication has a knock-on amplification vulnerability problem, that is, in a scenario with Network Address Translation (NAT), if multiple LAN terminals with the same public source IP address succeed in knocking on the door, the other terminals can pass the SPA verification and access the server normally.

[0072] The second generation of SPA authentication uses TCP SPA, which carries authentication information in the TLS (Transport Layer Security) phase of the TCP (Transmission Control Protocol) connection, ensuring that terminals are distinguished by connection, and there is no problem of knock-on amplification vulnerability. However, compared with UDP SPA, this method lacks the port stealth effect and is easily attacked by attackers using TCP flood and TCP syn-flood.

[0073] The third generation of SPA authentication adopts the UDP SPA + TCP SPA method, combining the strengths of both to become an enhanced version. Based on UDP port knocking, it supports TCP SPA, which can not only achieve port hiding, but also solve the knock amplification vulnerability problem of traditional UDP knocking.

[0074] Among them, TCP SPA is performed after the TCP three-way handshake succeeds and the connection is established. It adds an extra field to the Extensions field in the Client Hello handshake packet of the TLS protocol, and attaches information such as the TOTP (Time-based One-time Password) token value calculated based on the SPA seed (the same as the seed of UDP SPA). When the server turns on TCP SPA, the server will verify this extra field in the TLS negotiation. If the verification fails, the server will terminate the TLS negotiation and return an error. For the interaction process between the client and the server with the third-generation zero-trust component, see Figure 2 shown.

[0075] However, UDP SPA knocks on each terminal, and after the knock is successful, it is necessary to add and delete IP port rules regularly. TCP SPA is a connection-level SPA, which requires verification for each connection, which will increase the pressure of server verification. When a large number of users go online and offline, the cost of the server is greatly affected; and when the client is in a weak network, the TCP connection is not stable enough and is prone to disconnection, affecting the user experience.

[0076] The authorized communication method provided by the embodiment of the present invention realizes communication between the server and the client that has passed SPA authentication based on a random port. It is difficult for an illegal terminal that has not passed SPA authentication to accurately access the server based on the random port, thereby effectively preventing the door-knock amplification vulnerability and improving security.

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

[0078] In this embodiment, an authorization communication method is provided, which can be applied to the above-mentioned client, and the client can specifically be a client in a terminal for accessing a server. Figure 3 is a flow chart of an authorization communication method according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps S301 to S303.

[0079] Step S301, randomly generate a random number and specify the port number range of the server requested to access.

[0080] In this embodiment, when the client needs to access a server, it needs to initiate a single packet authorization authentication. The client needs to randomly generate a random number, such as a 16-bit random string. In addition, the client also specifies a port number range. As the name implies, the port number range is a range that includes multiple port numbers; and the port number is the port number of the above server.

[0081] For example, the client can specify the port number range by enumeration. For example, the port number range is: 11, 12, 15, that is, the port number range includes three port numbers. Alternatively, the client can also specify the first port number and the last port number to form a port number range between the first port number and the last port number, and the port number range includes the first port number and the last port number. For example, the client can specify the port number range as 11~30, where 11 is the first port number and 30 is the last port number.

[0082] Step S302, encapsulating the SPA message according to the authentication information; the authentication information includes a random number, a port number range and a source IP address of the client.

[0083] In this embodiment, in order to implement single-packet authorization authentication, the client needs to determine the corresponding authentication information, encapsulate the authentication information, and generate a SPA message to be sent to the gateway. The authentication information includes the above-mentioned random number and port number range, and the authentication information also includes the source IP address of the client, that is, the IP address of the terminal where the client is located. In addition, the authentication information may also include a terminal identifier, a timestamp (date / hour / minute), etc.

[0084] Figure 4 A schematic diagram of SPA message encapsulation and parsing is shown. For example, see Figure 4As shown, when encapsulating the SPA message, the client can calculate the SPA key based on the authentication information such as the random number and the shared key shared with the server through the encryption algorithm. The SPA key is a message authentication code. The encryption algorithm may include, for example, the HOTP (HMAC-based One-Time Password) algorithm, that is, a one-time password generation method based on the HMAC (Hash-based Message Authentication Code) algorithm encryption. For example, the process of generating the SPA key based on the shared key K and the random number C can be expressed as: HOTP (K, C) = Truncate (HMAC-SHA-1 (K, C)), where the Truncate function is how to intercept the encrypted string and which fields of the encrypted string are taken to form a number. The HMAC-SHA-1 function is a type of HMAC algorithm, which uses the SHA-1 hash function; the SPA key and the authentication information are packaged to generate the SPA message. Among them, the UDP (User Datagram Protocol) packaging method can be used for packaging, and the source IP address is located in the header.

[0085] Step S303, based on the User Datagram Protocol, a SPA message is sent to the gateway, instructing the gateway to open access to the destination port corresponding to the destination port number; the destination port number is a port number within a port number range mapped from a random number according to a preset mapping rule.

[0086] In this embodiment, after the client generates the SPA message, it can send the SPA message to the gateway, so that the gateway performs single-packet authorization authentication, i.e., SPA authentication, on the client. The client adopts the UDP SPA authentication method, i.e., the client sends the SPA message to the gateway based on the User Datagram Protocol (UDP).

[0087] Among them, the random number generated by the client and the specified port number range are used to randomly determine the destination port number, and both the client and the gateway can determine the same destination port number. Specifically, after the gateway obtains the random number and the port number range, it can map the random number to a port number within the port number range according to the preset mapping rule, and use the port number mapped to the random number as the destination port number. Since the destination port number is based on a random number, the destination port number is equivalent to a port number randomly selected from the port number range. For other terminals that use the same public network source IP address as the client, if they do not know the destination port number, they cannot access the server normally, thereby effectively avoiding the behavior of illegal terminals maliciously accessing the server.

[0088] In some optional implementations, after sending the SPA message to the gateway, the client further executes a process of establishing a communication connection with the server, wherein the method further includes the following steps A1 to A2.

[0089] Step A1, mapping the random number to a destination port number within a port number range according to a preset mapping rule.

[0090] In this embodiment, after the client sends the SPA message to the gateway, it can try to establish a communication connection with the server. Specifically, in the same way as the gateway determines the target port number, the client also determines the mapped destination port number from the port number range according to the same preset mapping rule based on the random number.

[0091] For example, the preset mapping rule may be a remainder rule, that is, a random number is used as the dividend, the number of port numbers in the port number range is used as the divisor, a remainder operation is performed, and then the corresponding port number is selected as the destination port number according to the calculated remainder and the first port number in the port number range. Of course, other mapping rules may also be used, and this embodiment does not limit this.

[0092] Step A2: after sending the SPA message to the gateway, sending a first connection message to the gateway for establishing a communication connection with a destination port corresponding to the destination port number; the first connection message includes a first source port number.

[0093] In this embodiment, after the client sends the SPA message to the gateway, it can then send a corresponding connection message to the gateway to request to establish a communication connection with the destination port of the server; for the convenience of description, the connection message is called the first connection message.

[0094] In addition, the first connection message includes the port number of the source end, that is, the first source port number, such as the port number that the client side requests to establish a communication connection with the server. Based on the first source port number, the gateway can further determine whether the client is legitimate, which can further improve communication security, which will be described in detail later.

[0095] In the authorized communication method provided in this embodiment, the client encapsulates the SPA message based on the random number and the port number range and performs SPA authentication, so that the gateway can randomly select the destination port number from the port number range according to the random number, and the client and the server communicate based on the random port, making it difficult for illegal terminals that have not passed SPA authentication to accurately access the server based on the random port, thereby effectively preventing the door-knocking amplification vulnerability and improving security. In addition, the client performs authorization authentication through the UDP SPA method, which can ensure port privacy and has little impact on the server's overhead.

[0096] In this embodiment, an authorization communication method is provided, which can be applied to the above-mentioned gateway. Figure 5 is a flow chart of an authorization communication method according to an embodiment of the present invention. Figure 5 As shown, the process includes the following steps S501 to S504.

[0097] Step S501: Acquire a SPA message sent by a client based on the User Datagram Protocol.

[0098] In this embodiment, when the client needs to perform single packet authorization authentication, it can send a corresponding SPA message to the gateway based on the User Datagram Protocol to request UDP SPA authentication; wherein, the process of the client encapsulating and sending the SPA message can be referred to Figure 3 The relevant description of the illustrated embodiment will not be repeated here.

[0099] Step S502, parse the SPA message to extract corresponding authentication information; the authentication information includes a random number, a port number range of the server that the client requests to access, and a source IP address of the client.

[0100] After the gateway receives the SPA message sent by the client, it can parse it and extract the information contained in it. Figure 3 As can be seen from the illustrated embodiment, the SPA message includes authentication information, and the authentication information includes a random number, a port number range of the server that the client requests to access, and a source IP address of the client.

[0101] Step S503: Authentication processing is performed on the client according to the authentication information.

[0102] In this embodiment, after the gateway parses the authentication information, it can perform authentication processing on the client based on the authentication information to implement single-packet authorization authentication and verify whether the client is legitimate.

[0103] For example, see Figure 4 As shown in the figure, after receiving the SPA message, the gateway can parse the SPA message and extract the SPA key contained in the SPA message (that is, the SPA key generated by the client); and the SPA key can also be calculated based on the same encryption algorithm as the client. The gateway compares the SPA key contained in the SPA message and obtains the SPA key. If the two SPA keys are the same, it can be considered that the SPA message has not been tampered with, and the client authentication is successful, that is, the client can be determined to be legitimate.

[0104] In addition, the gateway can also detect whether the SPA message is replayed to prevent replay attacks. For example, when the authentication information contains a timestamp, it is also possible to detect whether the SPA message is replayed based on the timestamp. Alternatively, since the random number generated by the client each time is generally different, after the gateway receives an SPA message sent by a client, it can detect whether the random number in the SPA message is the same as the random number in other SPA messages sent by the client (for example, SPA messages from the same source IP address). If the two random numbers are the same, it can be considered that the SPA message this time is a replay attack. In other words, in addition to being used to select a random destination port, the random number in this embodiment can also be used for replay detection.

[0105] If the SPA message has not been tampered with and there is no replay problem, the SPA message passes the authentication, that is, the client authentication is successful.

[0106] Step S504, when the authentication is successful, the random number is mapped to a port number within the port number range according to the preset mapping rule as the destination port number allowed to be accessed by the client, and the source IP address is given permission to access the destination port corresponding to the destination port number.

[0107] In this embodiment, if the authentication is successful, the client is considered legitimate, and the port allowed to be accessed, i.e., the destination port, can be opened to the client. The destination port is not fixed, but is generated based on the random number in the SPA message and the port number range.

[0108] Specifically, the gateway can determine which port number in the port number range is mapped to the random number according to the preset mapping rule, and use the port number mapped to the random number as the destination port allowed for the client to access; wherein the preset mapping rule is a rule pre-agreed with the client, such as a remainder rule, so that the client can also determine the same destination port based on the random number and the port number range.

[0109] Optionally, after the gateway determines the destination port, a corresponding firewall rule may be set. The above step of "opening the source IP address to the destination port corresponding to the destination port number" may include: setting a first firewall rule; the first firewall rule is used to allow the source IP address to access the destination port, thereby opening the source IP address to the destination port corresponding to the destination port number, allowing the terminal of the source IP address to access the destination port of the server. The source IP address is generally a public network source IP address.

[0110] In the authorization communication method provided in this embodiment, after the gateway obtains the SPA message sent by the client, it authenticates it, and after the authentication is successful, it selects the destination port open to the client based on the parsed random number and port number range, thereby allowing the client to access the destination port. Since the destination port is random and not fixed, it can effectively prevent illegal terminals from forging messages. When illegal terminals that have not passed SPA authentication do not correctly access the destination port, the access behavior of illegal terminals can be prohibited, thereby effectively preventing the door-knocking amplification vulnerability and improving security. In addition, the client performs authorization authentication through UDP SPA, which can ensure port privacy, and the server requires less overhead, which has little impact on the server's overhead.

[0111] In some optional implementations, after receiving the SPA message sent by the client, the gateway may also receive a first connection message sent by the client for establishing a communication connection, and further establish corresponding firewall rules. Specifically, the method further includes steps B1 to B2.

[0112] Step B1, judging whether there is network address translation at the client according to the SPA message.

[0113] If the client does not have a network address translation (NAT), there is generally no problem of the door-knock amplification vulnerability; in this embodiment, firewall rules are mainly set for the client in the NAT scenario.

[0114] Optionally, the above step B1 "determining whether there is network address translation on the client according to the SPA message" may include the following steps B11 to B13.

[0115] Step B11, parse out the first source IP address in the message header and the second source IP address in the message payload of the SPA message.

[0116] Step B12, determining whether the first source IP address is the same as the second source IP address.

[0117] Step B13: When the first source IP address is different from the second source IP address, it is determined that a network address translation exists on the client.

[0118] In this implementation, a source IP address is set in both the message header and the message payload of the SPA message. Generally, the two source IP addresses are the same; but in a NAT scenario, the first source IP address in the message header will change, resulting in the first source IP address being different from the second source IP address. Therefore, by determining whether the first source IP address is the same as the second source IP address, it is possible to simply and conveniently determine whether there is network address translation on the client.

[0119] Figure 6A communication diagram in a NAT scenario is shown. Figure 6 As shown, client A and client B are located in the same LAN, and their source IP addresses are 1.1.1.1 and 2.2.2.2 respectively; and both client A and client B need to access the server through a NAT gateway (for example, a router), and the public IP address of the NAT gateway is 3.3.3.3, and the public IP address of the server is 4.4.4.4.

[0120] When client A initiates single-packet authorization authentication, it encapsulates an SPA message and sends it to the NAT gateway. At this time, the source IP addresses in the message header and message payload of the SPA message are both 1.1.1.1; but after being processed by the NAT gateway, the source IP address in the SPA message header is modified to the public IP address of the NAT gateway and sent to the gateway on the server side (that is, the gateway that executes the authorization communication method mentioned above), so that in the SPA message received by the gateway, the source IP address in the message header is 3.3.3.3, which is different from the source IP address in the message payload (1.1.1.1). Therefore, the gateway can determine that client A is in the NAT scenario.

[0121] After the SPA message of client A is successfully authenticated, the gateway can open the destination port to the source IP address. It can be understood that the source IP address is the source IP address in the message header. In the NAT scenario, the gateway actually opens the destination port to the first source IP address, that is, opens the destination port to the NAT gateway. Specifically, the gateway can build corresponding firewall rules based on the public IP address of the server (for example, 4.4.4.4), the randomly selected destination port, and the source IP address in the received message header (for example, 3.3.3.3) for subsequent connection matching.

[0122] Step B2, in the case of network address translation on the client, a second firewall rule is set according to the first connection message sent by the client, wherein the first connection message includes a first source port number, and the second firewall rule is used to prevent other source ports corresponding to the source IP address, except the source port corresponding to the first source port number, from accessing the destination port.

[0123] In this embodiment, as shown in the relevant description of the above step A1, after the client sends the SPA message to the gateway, it can try to establish a communication connection with the destination port of the server, that is, the client can send a first connection message to the gateway, and the first connection message is used to establish a communication connection with the destination port of the server; accordingly, the gateway can receive the first connection message sent by the client. In addition, the first connection message includes a first source port number, such as the source port number of the terminal where the client is located.

[0124] If the gateway receives the SPA message sent by the client and then receives the first connection message sent by the client, the gateway allows the client to access the destination port of the server through the corresponding source port (the source port corresponding to the first source port number). In addition, the gateway can also set the corresponding second firewall rule, which is used to prevent the source ports corresponding to the source IP address, except the source port corresponding to the first source port number, from accessing the destination port. In other words, other source ports of the source IP address cannot access the destination port.

[0125] Among them, when the gateway receives the SPA message sent by the client, if it receives the connection message from the source IP address for the first time, it can be considered that the connection message is the first connection message sent by the client, and a communication connection is established with the client, and the second firewall rule is set so that the client can access the server normally.

[0126] Optionally, based on the conversion flag, it can be indicated whether the client has network address translation. Specifically, Figure 7 As shown, the authorization communication method provided in this embodiment may include the following steps S701 to S710.

[0127] Step S701: Acquire a SPA message sent by a client based on the User Datagram Protocol.

[0128] Step S702: parse the SPA message to extract corresponding authentication information; the authentication information includes a random number, a port number range of the server that the client requests to access, and a source IP address of the client.

[0129] Step S703: Authenticate the client according to the authentication information.

[0130] Step S704: If the authentication is successful, a first firewall rule is set, wherein the first firewall rule is used to allow the source IP address to access the destination port.

[0131] Step S705, judging whether the client has network address translation according to the SPA message. If the client has network address translation, execute step S706; otherwise, directly execute step S707.

[0132] Step S706: Set a conversion mark for the authentication information of the client to indicate that a network address translation exists on the client.

[0133] Step S707: Acquire a first connection message sent by the client for establishing a communication connection with the destination port; the first connection message includes a first source port number.

[0134] It can be understood that step S707 can be executed after step S701, that is, the gateway can first execute step S707 and then execute step S705, etc.; at this time, when it is determined that the client has network address translation based on the SPA message, if the first connection message sent by the client is received, the subsequent step S708 is executed.

[0135] Step S708, determine whether the client's authentication information is set with a conversion mark. If the client's authentication information is set with a conversion mark, execute step S709; otherwise, directly execute step S710, that is, no additional firewall rules need to be set at this time.

[0136] Step S709, setting a second firewall rule; the second firewall rule is used to prevent other source ports corresponding to the source IP address, except the source port corresponding to the first source port number, from accessing the destination port.

[0137] Step S710: forwarding a first connection message to a server to establish a communication connection between the server and the client.

[0138] In this embodiment, for the client in the NAT scenario, a second firewall rule is set based on its source port number (i.e., the first source port number), which can limit the access of only the first source port number of the source IP address to the destination port of the server, thereby further improving communication security and preventing malicious attacks.

[0139] Specifically, after establishing the second firewall rule, the method further includes the following steps C1 to C4.

[0140] Step C1: When the gateway obtains a second connection message from a source IP address for establishing a communication connection with a destination port, the gateway determines a second source port number in the second connection message.

[0141] Step C2, determining whether the second source port number is the same as the first source port number.

[0142] Step C3: forwarding the second connection message to the server when the second source port number is the same as the first source port number.

[0143] Step C4: intercepting the second connection message when the second source port number is different from the first source port number.

[0144] In this embodiment, after the gateway sets a second firewall rule that only allows the source port corresponding to the first source port number of the source IP address to establish a communication connection with the destination port, if a second connection message from the source IP address for establishing a communication connection with the destination port is obtained again, the legitimacy of the corresponding terminal can be further judged based on the source port number (i.e., the second source port number) in the second connection message.

[0145] Specifically, in the NAT scenario, different clients will be assigned different source ports after passing through the NAT gateway. If the second source port number in the current second connection message is different from the first source port number that has passed SPA authentication, it can be determined that the client that initiated the second connection message at this time has not passed the SPA authentication, and the second connection message can be intercepted, thereby refusing to establish a communication connection with the client; if the second source port number is the same as the first source port number, it can be considered that the client that initiates the second connection message again is still the client that initially sent the SPA message, so the gateway can forward the second connection message to the server to establish a communication connection.

[0146] For example, see Figure 6 As shown in the figure, after client A passes SPA authentication, it can establish a communication connection with the random destination port of the server through the NAT gateway. If during the period when the destination port is open, client B (a normal user's client or a client used by an attacker) in the same LAN as client A also initiates a second connection message to the gateway, although the source IP address of the second connection message is also the public IP address of the NAT gateway, if client B does not correctly specify the destination port to be accessed, the server refuses to establish a connection with client B.

[0147] Furthermore, even if client B specifies the correct destination port in some way, since the source port number in its connection message (i.e., the second source port number) is different from the first source port number in the second firewall rule, the gateway can also determine that client B is a client of an illegal terminal. At this time, the second connection message can also be intercepted, that is, only the first connection is allowed to be established, which can prevent subsequent client connections that exploit the knock vulnerability, effectively avoid the problem of knock amplification vulnerability, and further improve security.

[0148] In this embodiment, an authorization communication device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made are not repeated here. As used below, the term "module" may be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0149] This embodiment provides an authorization communication device, which is applied to a client, such as Figure 8 As shown, including:

[0150] The preprocessing module 801 is used to randomly generate a random number and specify a port number range of the server to be accessed;

[0151] Encapsulation module 802, used to encapsulate the SPA message according to the authentication information; the authentication information includes the random number, the port number range and the source IP address of the client;

[0152] The sending module 803 is used to send the SPA message to the gateway based on the User Datagram Protocol, instructing the gateway to open access to the destination port corresponding to the destination port number; the destination port number is the port number within the port number range mapped by the random number according to the preset mapping rule.

[0153] In some optional implementations, the sending module 803 is further configured to:

[0154] According to the preset mapping rule, mapping the random number to the destination port number within the port number range;

[0155] After sending the SPA message to the gateway, a first connection message for establishing a communication connection with a destination port corresponding to the destination port number is sent to the gateway; the first connection message includes a first source port number.

[0156] This embodiment provides an authorization communication device, which is applied to a gateway, such as Fig. 9 As shown, including:

[0157] The acquisition module 901 is used to acquire the SPA message sent by the client based on the User Datagram Protocol;

[0158] The parsing module 902 is used to parse the SPA message and extract the corresponding authentication information; the authentication information includes a random number, a port number range of the server requested by the client to access, and a source IP address of the client;

[0159] An authentication module 903 is used to authenticate the client according to the authentication information;

[0160] Processing module 904 is used to, when authentication is successful, map the random number to a port number within the port number range according to a preset mapping rule as a destination port number allowed for access by the client, and grant the source IP address permission to access the destination port corresponding to the destination port number.

[0161] In some optional implementations, the processing module 904 grants the source IP address permission to access the destination port corresponding to the destination port number, including:

[0162] A first firewall rule is set; the first firewall rule is used to allow the source IP address to access the destination port.

[0163] In some optional implementations, the processing module 904 is further configured to:

[0164] Determining whether the client has a network address translation according to the SPA message;

[0165] In the case where network address translation exists on the client, a second firewall rule is set according to a first connection message sent by the client; the first connection message includes a first source port number, and the second firewall rule is used to prevent other source ports corresponding to the source IP address, except the source port corresponding to the first source port number, from accessing the destination port.

[0166] In some optional implementations, the processing module 904 sets a second firewall rule according to the first connection message sent by the client, including:

[0167] Setting a conversion mark for the authentication information of the client to indicate that a network address conversion exists on the client;

[0168] After obtaining the first connection message sent by the client, determining whether the authentication information of the client is provided with a conversion mark;

[0169] In a case where the authentication information of the client is provided with a conversion mark, a second firewall rule is set according to the first connection message sent by the client.

[0170] In some optional implementations, after setting the second firewall rule, the processing module 904 is further configured to:

[0171] In the case where the acquisition module 901 acquires a second connection message from the source IP address for establishing a communication connection with the destination port, determining a second source port number in the second connection message;

[0172] According to the second firewall rule, determining whether the second source port number is the same as the first source port number;

[0173] When the second source port number is the same as the first source port number, forwarding the second connection message to the server;

[0174] When the second source port number is different from the first source port number, the second connection message is intercepted.

[0175] In some optional implementations, the processing module 904 determines whether the client has a network address translation according to the SPA message, including:

[0176] Parsing the first source IP address in the message header and the second source IP address in the message payload of the SPA message;

[0177] Determine whether the first source IP address is the same as the second source IP address;

[0178] When the first source IP address is different from the second source IP address, it is determined that network address translation exists on the client.

[0179] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0180] The authorization communication device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, including a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0181] The embodiment of the present invention also provides a computer device having the above Figure 8 or Fig. 9 The authorized communication device shown. For example, the computer device may be a gateway, or a terminal where a client is located.

[0182] See also Fig.10 , Fig.10 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Fig.10 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig.10 A processor 10 is taken as an example.

[0183] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0184] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.

[0185] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0186] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0187] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.

[0188] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0189] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.

[0190] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. An authorized communication method, It is characterized in that Applied to a client, the method comprises: Generate a random number randomly and specify the port number range of the server to be accessed; Encapsulating a SPA message according to authentication information; the authentication information includes the random number, the port number range and the source IP address of the client; Based on the User Datagram Protocol, the SPA message is sent to the gateway to instruct the gateway to open the permission to access the destination port corresponding to the destination port number; the destination port number is mapped from the random number to the port number within the port number range according to a preset mapping rule; the SPA message is also used to instruct the gateway to determine whether the client has a network address translation; According to the preset mapping rule, mapping the random number to the destination port number within the port number range; After sending the SPA message to the gateway, a first connection message for establishing a communication connection with the destination port corresponding to the destination port number is sent to the gateway; the first connection message includes a first source port number; the first connection message is used to instruct the gateway: in the case where network address translation exists on the client, set a second firewall rule according to the first connection message sent by the client; the second firewall rule is used to prevent other source ports corresponding to the source IP address, except the source port corresponding to the first source port number, from accessing the destination port.

2. An authorized communication method, It is characterized in that Applied to a gateway, the method comprises: Obtain SPA message sent by the client based on the User Datagram Protocol; Parsing the SPA message to extract corresponding authentication information; the authentication information includes a random number, a port number range of the server requested by the client to access, and a source IP address of the client; Performing authentication processing on the client according to the authentication information; If the authentication is successful, the random number is mapped to a port number within the port number range according to a preset mapping rule as the destination port number allowed to be accessed by the client, and the source IP address is given permission to access the destination port corresponding to the destination port number; Determining whether the client has a network address translation according to the SPA message; In the case where network address translation exists on the client, a second firewall rule is set according to a first connection message sent by the client; the first connection message includes a first source port number, and the second firewall rule is used to prevent other source ports corresponding to the source IP address, except the source port corresponding to the first source port number, from accessing the destination port.

3. The method according to claim 2, It is characterized in that The permission to open access to the destination port corresponding to the destination port number to the source IP address includes: A first firewall rule is set; the first firewall rule is used to allow the source IP address to access the destination port.

4. The method according to claim 2, It is characterized in that The step of setting a second firewall rule according to the first connection message sent by the client includes: Setting a conversion mark for the authentication information of the client to indicate that a network address conversion exists on the client; After obtaining the first connection message sent by the client, determining whether the authentication information of the client is provided with a conversion mark; In a case where the authentication information of the client is provided with a conversion mark, a second firewall rule is set according to the first connection message sent by the client.

5. The method according to claim 2, It is characterized in that After setting the second firewall rule, the method further includes: In the case of obtaining a second connection message from the source IP address for establishing a communication connection with the destination port, determining a second source port number in the second connection message; According to the second firewall rule, determining whether the second source port number is the same as the first source port number; When the second source port number is the same as the first source port number, forwarding the second connection message to the server; When the second source port number is different from the first source port number, the second connection message is intercepted.

6. The method according to claim 2, It is characterized in that The determining, according to the SPA message, whether the client has a network address translation includes: Parsing the first source IP address in the message header and the second source IP address in the message payload of the SPA message; Determine whether the first source IP address is the same as the second source IP address; When the first source IP address is different from the second source IP address, it is determined that network address translation exists on the client.

7. An authorized communication device, It is characterized in that Applied to a client, the device comprises: A preprocessing module is used to randomly generate random numbers and specify the port number range of the server requested to access; An encapsulation module, used to encapsulate the SPA message according to the authentication information; the authentication information includes the random number, the port number range and the source IP address of the client; A sending module, configured to send the SPA message to a gateway based on a user datagram protocol, instructing the gateway to open access to a destination port corresponding to a destination port number; the destination port number is a port number mapped from the random number to a port number within the port number range according to a preset mapping rule; the SPA message is also configured to instruct the gateway to determine whether a network address translation exists for the client; The sending module is also used for: According to the preset mapping rule, mapping the random number to the destination port number within the port number range; After sending the SPA message to the gateway, a first connection message for establishing a communication connection with the destination port corresponding to the destination port number is sent to the gateway; the first connection message includes a first source port number; the first connection message is used to instruct the gateway: in the case where network address translation exists on the client, set a second firewall rule according to the first connection message sent by the client; the second firewall rule is used to prevent other source ports corresponding to the source IP address, except the source port corresponding to the first source port number, from accessing the destination port.

8. An authorized communication device, It is characterized in that Applied to a gateway, the device comprises: An acquisition module, used to acquire SPA messages sent by the client based on the User Datagram Protocol; A parsing module, used to parse the SPA message and extract corresponding authentication information; the authentication information includes a random number, a port number range of the server requested by the client to access, and a source IP address of the client; An authentication module, used to authenticate the client according to the authentication information; A processing module, configured to select a destination port number that the client is allowed to access from the port number range according to the random number in accordance with a preset mapping rule when the authentication is successful, and grant the source IP address permission to access the destination port corresponding to the destination port number; The processing module is also used for: Determining whether the client has a network address translation according to the SPA message; In the case where network address translation exists on the client, a second firewall rule is set according to a first connection message sent by the client; the first connection message includes a first source port number, and the second firewall rule is used to prevent other source ports corresponding to the source IP address, except the source port corresponding to the first source port number, from accessing the destination port.

9. A computer device, It is characterized in that include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the authorization communication method according to any one of claims 1 to 6 by executing the computer instructions.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the authorization communication method according to any one of claims 1 to 6.

11. A computer program product, It is characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the authorization communication method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Authentication method and device of industrial micro-service system and computer medium

    CN116232683A

  • UDP (User Datagram Protocol) port authentication method, network equipment and storage medium

    CN116996257A