Replay attack prevention method based on Token authentication and related device
Through the request sequence verification corresponding to the token, the unreliability problem based on clock verification in the prior art is solved, and the interface security and financial transaction security are improved.
Patent Information
- Application Number
- CN202411739976.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-11-29
AI Technical Summary
The existing anti-replay attack method based on Token authentication relies on clock verification, and there are problems such as clock synchronization, clock backtracking attack and playback attack window management, resulting in unreliable verification.
Verification of the request sequence corresponding to the token, including determining whether the token and the request sequence have been processed, to obtain more reliable and accurate anti-replay attack verification results.
It improves interface security, effectively overcomes the unreliable problem based on timestamp verification, and enhances the security of financial transactions in financial scenarios such as banks.
Smart Images

Figure CN119520141A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of security technology, and in particular to a Token authentication-based anti-replay attack method and related devices. Background Art
[0002] In computer networks and distributed systems, a token usually refers to a credential that proves a digital identity or access authorization, and can be used to implement authorization control over user access to services. Tokens have the advantages of being stateless, preventing cross-site request forgery (CSRF) attacks, and being single sign-on friendly, and have been widely used in mobile and microservice authentication. However, tokens also have the problem of being stolen and used to impersonate others, which can easily bring risks of information leakage and interface replay attacks; moreover, once a token is issued, the server cannot actively invalidate the token.
[0003] As network security issues in Internet scenarios become more and more serious, the design of interface anti-replay attack is becoming more and more important. Especially in financial scenarios such as banks, the design of interface anti-replay attack can increase interface security and avoid the repetition of important financial transactions, thereby increasing the security of important financial transactions.
[0004] However, the current anti-replay attack based on Token authentication is usually verified based on the clock of the client and server, and the verification result is not reliable enough. Based on this, it is urgent to provide a more reliable and secure anti-replay attack method based on Token authentication to improve the interface security, thereby improving the security of financial transactions in financial scenarios such as banks. Summary of the invention
[0005] In order to solve the above technical problems, the present application provides a Token authentication-based anti-replay attack method and related devices, which verifies whether the request message including the Token and the request sequence has been processed through the request sequence corresponding to the Token, so as to obtain a more reliable and accurate Token authentication-based anti-replay attack verification result, thereby improving the interface security.
[0006] In order to achieve the above objectives, the technical solutions provided by this application are as follows:
[0007] In a first aspect, the present application provides a method for preventing replay attacks based on Token authentication, which is applied to a server, and the method includes:
[0008] receiving a first request message, wherein the first request message includes encryption information;
[0009] Decrypting the encrypted information to obtain a first Token and a first request sequence, where the first request sequence is used to indicate an order of the first request messages;
[0010] If the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is invalid, the first request message is rejected, and the request sequence set is used to store the request sequence in the valid request message for the first Token authentication.
[0011] Optionally, the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is invalid, including:
[0012] The request sequence set corresponding to the first Token includes the first request sequence;
[0013] Alternatively, the request sequence set corresponding to the first Token does not include the first request sequence, but the first request sequence is less than or equal to a lower limit on the number of requests, and the lower limit on the number of requests is determined based on a concurrent request quantity threshold and the largest second request sequence in the request sequence set currently corresponding to the first Token.
[0014] Optionally, the method further comprises:
[0015] It is determined that the first request message is a replay attack against the first Token authentication.
[0016] Optionally, the method further comprises:
[0017] If the first request sequence and the request sequence set corresponding to the first Token indicate that the first Token is valid, in response to processing the first request message, user information corresponding to the first Token is obtained.
[0018] Optionally, the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is valid, including:
[0019] The request sequence set corresponding to the first Token is empty;
[0020] Alternatively, the request sequence set corresponding to the first Token does not include the first request sequence, and the first request sequence is greater than a lower limit on the number of requests, and the lower limit on the number of requests is determined based on a concurrent request number threshold and the largest second request sequence in the request sequence set currently corresponding to the first Token.
[0021] Optionally, the method further comprises:
[0022] Update the request sequence set corresponding to the first Token based on the first request sequence.
[0023] Optionally,
[0024] If the request sequence set corresponding to the first Token is empty, updating the request sequence set corresponding to the first Token based on the first request sequence includes:
[0025] Saving the first request sequence in a request sequence set corresponding to the first Token;
[0026] If the request sequence set corresponding to the first Token does not include the first request sequence, and the first request sequence is greater than the lower limit of the number of requests, then updating the request sequence set corresponding to the first Token based on the first request sequence includes:
[0027] If the number of request sequences included in the request sequence set corresponding to the first Token reaches the concurrent request number threshold, remove the smallest third request sequence in the request sequence set currently corresponding to the first Token, and insert the first request sequence into the request sequence set corresponding to the first Token.
[0028] Optionally, the request sequence set is stored using a Zset structure in Redis, and the data of the Zset structure includes a key-value pair with a Token as a key and a request sequence corresponding to the Token as a value.
[0029] In a second aspect, the present application also provides a method for preventing replay attacks based on Token authentication, which is applied to a client, and the method includes:
[0030] Generate a first request message, where the first request message includes first encrypted information, where the first encrypted information is information obtained by the client encrypting the first token Token and a first request sequence, where the first request sequence is used to indicate an order of the first request messages;
[0031] Send the first request message to the server so that the server processes the first request message based on the authentication result of the first Token in the first request message.
[0032] Optionally, the method further comprises:
[0033] Add one to the first stored request sequence to obtain a second request sequence;
[0034] Generate a second request message, where the second request message includes second encrypted information, where the second encrypted information is information obtained by the client encrypting the first Token and the second request sequence;
[0035] Send the second request message to the server.
[0036] In a third aspect, the present application also provides an anti-replay attack device based on Token authentication, which is applied to a server, including:
[0037] A receiving unit, configured to receive a first request message, wherein the first request message includes encryption information;
[0038] A decryption unit, used to decrypt the encrypted information to obtain a first Token and a first request sequence, where the first request sequence is used to indicate an order of the first request messages;
[0039] A processing unit, configured to refuse to process the first request message if a request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is invalid, wherein the request sequence set is used to store request sequences in valid request messages authenticated for the first Token.
[0040] Optionally, the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is invalid, including:
[0041] The request sequence set corresponding to the first Token includes the first request sequence;
[0042] Alternatively, the request sequence set corresponding to the first Token does not include the first request sequence, but the first request sequence is less than or equal to a lower limit on the number of requests, and the lower limit on the number of requests is determined based on a concurrent request quantity threshold and the largest second request sequence in the request sequence set currently corresponding to the first Token.
[0043] Optionally, the device further comprises:
[0044] A determination unit is used to determine that the first request message is a replay attack against the first Token authentication.
[0045] Optionally, the device further comprises:
[0046] An acquiring unit is configured to acquire user information corresponding to the first Token in response to processing the first request message if the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is valid.
[0047] Optionally, the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is valid, including:
[0048] The request sequence set corresponding to the first Token is empty;
[0049] Alternatively, the request sequence set corresponding to the first Token does not include the first request sequence, and the first request sequence is greater than a lower limit on the number of requests, and the lower limit on the number of requests is determined based on a concurrent request number threshold and the largest second request sequence in the request sequence set currently corresponding to the first Token.
[0050] Optionally, the device further comprises:
[0051] An updating unit, configured to update a request sequence set corresponding to the first Token based on the first request sequence.
[0052] Optionally,
[0053] If the request sequence set corresponding to the first Token is empty, the updating unit is specifically configured to:
[0054] Saving the first request sequence in a request sequence set corresponding to the first Token;
[0055] If the request sequence set corresponding to the first Token does not include the first request sequence, and the first request sequence is greater than the lower limit of the request quantity, the updating unit is specifically configured to:
[0056] If the number of request sequences included in the request sequence set corresponding to the first Token reaches the concurrent request number threshold, remove the smallest third request sequence in the request sequence set currently corresponding to the first Token, and insert the first request sequence into the request sequence set corresponding to the first Token.
[0057] Optionally, the request sequence set is stored using a Zset structure in Redis, and the data of the Zset structure includes a key-value pair with a Token as a key and a request sequence corresponding to the Token as a value.
[0058] It should be noted that the specific implementation method of the device and the technical effects achieved can refer to the relevant description of the method provided in the first aspect or any implementation method of the first aspect.
[0059] In a fourth aspect, the present application also provides an anti-replay attack device based on Token authentication, which is applied to a client, including:
[0060] A generating unit, configured to generate a first request message, wherein the first request message includes first encrypted information, where the first encrypted information is information obtained by the client encrypting the first Token and a first request sequence, and the first request sequence is used to indicate an order of the first request messages;
[0061] A sending unit is used to send the first request message to the server, so that the server processes the first request message based on the authentication result of the first Token in the first request message.
[0062] Optionally, the device further comprises:
[0063] a calculation unit, configured to add one to the first stored request sequence to obtain a second request sequence;
[0064] The generating unit is further configured to generate a second request message, wherein the second request message includes second encrypted information, where the second encrypted information is information obtained by the client encrypting the first Token and the second request sequence;
[0065] The sending unit is further used to send the second request message to the server.
[0066] It should be noted that the specific implementation method of the device and the technical effects achieved can refer to the relevant description of the method provided in the second aspect or any implementation method of the second aspect.
[0067] In a fifth aspect, the present application further provides a communication system, the communication system comprising a client and a server;
[0068] The client is used to execute the method provided by the second aspect or any one of the implementations of the second aspect;
[0069] The server is used to execute the method provided by the first aspect or any implementation of the first aspect.
[0070] In a sixth aspect, the present application further provides an electronic device, the electronic device comprising: a processor and a memory;
[0071] The memory is used to store instructions or programs;
[0072] The processor is used to execute the instructions or programs in the memory so that the electronic device executes the method provided by the first aspect, any one of the implementations of the first aspect, the second aspect, or any one of the implementations of the second aspect.
[0073] In the seventh aspect, the present application also provides a readable medium, which stores instructions or programs. When the instructions or programs are run on a processor, the processor executes the method provided by the above-mentioned first aspect, any one of the implementations of the first aspect, the second aspect, or any one of the implementations of the second aspect.
[0074] Compared with the prior art, the embodiments of the present application have at least the following advantages:
[0075] The technical solution provided in the present application provides a method for preventing replay attacks based on Token authentication. In the method, after the client generates a first request message including encrypted information, the client sends the first request message to the server. After receiving the first request message, the server decrypts the encrypted information therein to obtain the first Token and the first request sequence. The first request sequence is used to indicate the order of the first request message. Then, if the server determines that the first request sequence and the request sequence set corresponding to the first Token indicate that the first Token is invalid, the first request message can be considered as a replay attack against the first Token authentication, thereby refusing to process the first request message. Among them, the request sequence set corresponding to the first Token is used to store the request sequence in the valid request message for the first Token authentication. In this way, the client encrypts the information after concatenating the Token and the request sequence, and sends the encrypted information as a whole in the request message to the server. The server obtains the Token and the request sequence through decryption, and verifies whether the Token is valid based on the local request sequence set corresponding to the Token and the request sequence obtained in the request message. If it is invalid, the request message is rejected to obtain a more reliable and accurate verification result based on Token authentication and anti-replay attack. It can effectively overcome the problem of unreliable verification due to unreliable timestamps in the interface replay attack based on timestamp verification of whether the request message is for Token authentication, thereby improving the interface security, thereby improving the security of financial transactions in financial scenarios such as banks. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0077] Figure 1 A flowchart of a method for preventing replay attacks based on Token authentication provided in an embodiment of the present application;
[0078] Figure 2 A schematic diagram of a flow chart of an example of a method provided in an embodiment of the present application;
[0079] Figure 3 A schematic diagram of the structure of an anti-replay attack device 300 based on Token authentication provided in an embodiment of the present application;
[0080] Figure 4 A schematic diagram of the structure of an anti-replay attack device 400 based on Token authentication provided in an embodiment of the present application;
[0081] Figure 5 A schematic diagram of the structure of a communication system 500 provided in an embodiment of the present application;
[0082] Figure 6 A schematic diagram of the structure of an electronic device 600 provided in an embodiment of the present application. DETAILED DESCRIPTION
[0083] Traditional tokens are used to maintain session information between clients and servers, and there is a problem of token theft. Moreover, once a token is issued, the server cannot actively invalidate the token. The design of interface anti-replay attack can increase interface security and avoid re-retrieving important data, such as re-retrieving important financial transactions, to increase the security of important data. However, the current design of interface anti-replay attack has problems such as excessive memory usage, low efficiency, and inaccurate timeliness.
[0084] The current interface anti-replay attack process is usually as follows: S11, the client adds a timestamp identifier to the Token; S12, the client sends a request including the Token to the server; S13, the server filter obtains the corresponding timestamp identifier by parsing the Token; S14, the server compares the obtained timestamp identifier with the server clock. If the time corresponding to the timestamp identifier and the server clock interval exceed the specified time window, the request is intercepted. If the time corresponding to the timestamp identifier and the server clock are within the specified time window, the request is released. In this way, through the interface anti-replay attack mechanism of the Token and the timestamp, the user identity can be verified within the specified time and the Token can be prevented from being reused. In theory, the interface security can be effectively improved within the specified time. At the same time, the Token can be set to be valid only within the specified time window, and supports digital signatures, encryption and other means to ensure the security of the transmission process. It has been widely used in the modern Internet.
[0085] Alternatively, as one of the mechanisms for preventing replay attacks on the interface using Token and timestamp, there is also a method for preventing replay attacks on the API interface based on timestamp. In this method, a unique time code is introduced based on timestamp to mark the request, and then the repeated state of the interface is recorded by compressing the binary bit state of the status code. Only two sets of data need to be cached, namely the status code and the latest time code, to differentiate between normal requests and suspected abnormal requests, to optimize and accelerate the normal request interface without verification, and to maintain the state through the left shift operation of the binary state bit of the status code.
[0086] However, no matter which of the above solutions is used, timestamps are involved. Timestamps are used to determine whether a request is replayed. There is a problem of error between the server clock and the timestamp generated by the client. An attacker can tamper with the timestamp generated by the client to achieve the purpose of replay attack interface. Moreover, in the login process of the above solution, a timestamp is generated on the client, stored in the Token and sent to the server. The server verifies whether the timestamp is within the specified time window of the replay attack (also called the replay attack window). There may be problems such as clock synchronization, clock backtracking attack, time zone difference, etc., which may cause the server timestamp verification to fail in extreme cases.
[0087] In summary, the defects of the current Token and timestamp interface anti-replay attack mechanism include: First, the clock synchronization problem. This mechanism relies on the clock synchronization of each component in the system. If the clocks of the server and the client are not synchronized, the timestamp verification may fail, thereby misjudging the request as a replay attack. Second, the clock backtracking attack problem. Attackers may try to bypass the timestamp verification by changing their local system clock. To prevent clock backtracking attacks, a secure clock synchronization mechanism needs to be used, and the server may need to consider allowing a certain clock drift. Third, the replay attack window management problem. When setting the timestamp validity period, it is necessary to balance security and system tolerance. If the timestamp validity period is set too short, the system may be susceptible to misjudgment; if it is set too long, it may increase the risk of replay attacks. Setting a reasonable replay attack window is a challenge. Fourth, time zone differences. If system interactions in different time zones are involved, time zone differences may cause problems in timestamp parsing.
[0088] Based on this, the embodiment of the present application provides an anti-replay attack method based on Token authentication. In this method, after the client generates a first request message including encrypted information, the first request message is sent to the server. After receiving the first request message, the server decrypts the encrypted information therein to obtain the first Token and the first request sequence. The first request sequence is used to indicate the order of the first request message. Then, if the server determines that the first request sequence and the request sequence set corresponding to the first Token indicate that the first Token is invalid, the first request message can be considered as a replay attack against the first Token authentication, thereby refusing to process the first request message. Among them, the request sequence set corresponding to the first Token is used to store the request sequence in the valid request message for the first Token authentication.
[0089] In this way, the client encrypts the information after concatenating the Token and the request sequence, and sends the encrypted information as a whole in the request message to the server. The server obtains the Token and the request sequence through decryption, and verifies whether the Token is valid based on the local request sequence set corresponding to the Token and the request sequence obtained in the request message. If it is invalid, the request message is rejected to obtain a more reliable and accurate verification result based on Token authentication and anti-replay attack. It can effectively overcome the problem of unreliable verification due to unreliable timestamps in the interface replay attack based on timestamp verification of whether the request message is for Token authentication, thereby improving the interface security, thereby improving the security of financial transactions in financial scenarios such as banks.
[0090] It should be noted that the subject that implements the anti-replay attack method based on Token authentication may be the communication system provided in the embodiment of the present application. Specifically, the one that executes the steps implemented by the server in the anti-replay attack method based on Token authentication may be the server of the communication system, and the one that executes the steps implemented by the client in the anti-replay attack method based on Token authentication may be the client of the communication system. Alternatively, the subject that implements the anti-replay attack method based on Token authentication may be the anti-replay attack based on Token authentication provided in the embodiment of the present application. Specifically, the one that executes the steps implemented by the server in the anti-replay attack method based on Token authentication may be the anti-replay attack device 300 based on Token authentication described below, and the one that executes the steps implemented by the client in the anti-replay attack method based on Token authentication may be the anti-replay attack device 400 based on Token authentication described below.
[0091] It should be noted that in the embodiments of the present application, the process executed by the client can be used as a separate embodiment, with specific corresponding technical effects; similarly, the process executed by the server can be used as a separate embodiment, with specific corresponding technical effects. The execution of the separate embodiment of the client does not affect the implementation of the separate embodiment of the server, and the execution of the separate embodiment of the server does not affect the implementation of the separate embodiment of the client.
[0092] Some technical terms involved in the embodiments of the present application are introduced and explained below.
[0093] Token, also known as a token, in computer networks and distributed systems, usually refers to a credential that proves digital identity or access authorization, which can realize authorized control of user access to services.
[0094] Client, in a computer network or distributed system, usually refers to the process or application that initiates a request. The client can be deployed on a variety of user devices, such as personal computers (PCs), mobile phones, tablets, etc.
[0095] The server is a process or application that provides computing resources, storage, and service access. It undertakes the core business logic of the system and provides services to a large number of clients through standard interfaces.
[0096] Asymmetric encryption is an important encryption mechanism. The keys are divided into public keys and private keys. Generally, public keys are used for encryption and private keys are used for decryption.
[0097] Microservices Architecture is a distributed software architecture model that splits a complex system into multiple small services, each of which is responsible for implementing an independent business function.
[0098] Figure 1 A flowchart of a Token-authenticated anti-replay attack method provided in an embodiment of the present application. The method is described from the perspective of the interaction between the client and the server. Among them, the client can correspond to the following Token-authenticated anti-replay attack device 400 or the client 520 in the communication system 500, and the server can correspond to the following Token-authenticated anti-replay attack device 300 or the server 510 in the communication system 500.
[0099] like Figure 1 As shown, the method may include, for example, the following S101 to S105:
[0100] S101, the client generates a first request message, the first request message includes first encrypted information, the first encrypted information is information obtained by the client encrypting a first Token and a first request sequence, and the first request sequence is used to indicate the order of the first request messages.
[0101] The request sequence can be understood as a string that can indicate the order of the request message. By splicing the Token and the request sequence and encrypting the spliced content as a whole, the encrypted content is carried in the request for transmission, which ensures the security of the valid information in the request message. The reasons are: first, encryption algorithm is used for encryption, and second, even if the encryption is cracked, the splicing of the Token and the request sequence will confuse the attacker, making it impossible for the attacker to accurately obtain the Token.
[0102] Before S101, the method may further include: the client generates a first request sequence corresponding to the first Token.
[0103] As an example, if the client uses the first Token for Token authentication for the first time, then an initial request sequence can be randomly generated and recorded as the first request sequence.
[0104] It should be noted that in order to be able to regularly update the request sequence based on the initial request sequence in the future, so that the updated request sequence can always be used as the credential of the valid request message in the Token authentication, that is, the server can accurately verify whether the request message is valid based on the change pattern of the request sequence in the received request message. The client can save the request sequence used each time. For example, the client can save the first request sequence to the local storage (LocalStorage).
[0105] As another example, if it is not the first time for the client to use the first Token for Token authentication, then the client generating the first request sequence may include: first, the client obtains the second request sequence used last time; receiving, the client obtains the first request sequence according to the second request sequence.
[0106] If the client saves the last used first request sequence to LocalStorage, then the client obtaining the last used second request sequence may include: the client obtaining the second request sequence corresponding to the first Token from LocalStorage.
[0107] Among them, the client obtains the first request sequence according to the second request sequence, and the client may update the second request sequence to the first request sequence according to the rule of updating the request sequence. For example, the rule of updating the request sequence is to increase the request sequence by one, then the client obtains the first request sequence according to the second request sequence as follows: the client increases the second request sequence by one to obtain the first request sequence. In this way, the form of increasing the request sequence can prevent direct access by application programming interface (Application Programming Interface, API) access tools such as POSTMAN, enhance the security of the interface against replay attacks, and make the replay attack module of the conventional penetration tool BurpSuite invalid, which greatly increases the difficulty of penetration testing and helps to maintain the interface security within the system.
[0108] It should be noted that, in this example, after generating the first request sequence, the client may update the saved second request sequence corresponding to the first Token to the first request sequence.
[0109] In some implementations, after the client generates the first request sequence, S101 may include: the client may generate a first request message based on the first Token and the first request sequence. As an example, the client may concatenate the first Token and the first request sequence, and encrypt the concatenated information to obtain the first encrypted information; and carry the first encrypted information in the request message to generate the first request message. Among them, the first Token and the first request sequence are concatenated in a manner such as splicing the first request sequence to the first Token (it can also be understood as using the first request sequence as a suffix of the first Token). An asymmetric encryption algorithm may be used to encrypt the concatenated information, and the asymmetric encryption algorithm may be SM2, which is an elliptic curve public key cryptography algorithm. The first encrypted information may be carried in the request header of the first request message. It should be noted that the embodiment of the present application provides examples of the concatenation method of the first Token and the first request sequence, the encryption algorithm used for the information concatenated by the first Token and the first request sequence, and the manner in which the first encrypted information is carried in the first request message, without specific limitation thereto.
[0110] S102: The client sends a first request message to the server.
[0111] S103, the server receives the first request message.
[0112] Among them, the server can process the first request message based on the authentication result of the first Token in the first request message.
[0113] In some other implementations, after S101, the method may further include: the client adds one to the stored first request sequence to obtain a third request sequence; the client generates a second request message, the second request message includes second encrypted information, and the second encrypted information is information obtained by encrypting the first Token and the third request sequence by the client; the client sends the second request message to the server. The steps performed by the client and the server in this implementation can be found in Figure 1 The relevant description of the illustrated embodiment will not be repeated here.
[0114] S104, the server decrypts the first encrypted information to obtain a first Token and a first request sequence.
[0115] In specific implementation, after the server receives the first request message, the Token filter (TokenFilter) in the server parses and processes the first request message, that is, TokenFilter executes S104 and S105.
[0116] As an example, S104 may include: TokenFilter obtains first encrypted information from the first request message; TokenFilter decrypts the first encrypted information to obtain a first Token and a first request sequence.
[0117] S105: If the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is invalid, the server refuses to process the first request message, and the request sequence set is used to store the request sequence in the valid request message for the first Token authentication.
[0118] The invalidity of the first Token can be understood as the invalidity of the first Token in the first request message.
[0119] It should be noted that the server can store the request sequence set corresponding to each Token. The request sequence set can be stored using the Zset structure in Redis. The data of the Zset structure includes: a key-value pair with the Token as the key and the request sequence corresponding to the Token as the value. In this way, the use of the Zset structure in Redis can greatly optimize the storage space of the request sequence set. In addition, a sliding window with a concurrent request threshold (such as 10) can be maintained to ensure that the corresponding request sequence set of each user can accommodate a maximum of the concurrent request threshold request sequences. There is no need to store all the user's request sequences, and when the number of request sequences reaches the concurrent request threshold, the smallest request sequence can be automatically removed and a new request sequence can be inserted. While ensuring the legitimacy of the request sequence verification, the storage space can be optimized to the maximum extent.
[0120] After S104 and before S105, the server may use the first Token as a key to query the request sequence set corresponding to the first Token.
[0121] Among them, the request sequence set corresponding to the first request sequence and the first Token in S105 indicates that the first Token is invalid, which can be understood as the server determining that the first request message is a replay attack against the first Token authentication. The request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is invalid, which can correspond to two situations: situation one, the request sequence set corresponding to the first Token includes the first request sequence; situation two, the request sequence set corresponding to the first Token does not include the first request sequence, but the first request sequence is less than or equal to the lower limit of the number of requests, and the lower limit of the number of requests is determined based on the concurrent request number threshold and the largest fourth request sequence in the request sequence set currently corresponding to the first Token. Assuming that the concurrent request number threshold is 10, and the largest fourth request sequence in the request sequence set currently corresponding to the first Token is 1015, then the lower limit of the number of requests is (1015-10)=1005. If the first request sequence is 999, because 999 is less than 1005, the first Token in the first request message is invalid.
[0122] In case one, it can be understood that the server has received a request message for the first Token, and the request sequence in the request message is also the first request sequence. Then, the first request message for the first Token authentication including the first request sequence can be considered as an interface replay attack based on the first Token authentication.
[0123] In the second case, it can be understood that the server determines, based on the request lower limit of the first Token, that the first request sequence belongs to the request sequence of the first Token that was generated longer and has expired. At such a time, the server receives the first request message for the first Token authentication including the first request sequence, which can be considered as an interface replay attack based on the first Token authentication.
[0124] In some other implementations, the method may further include: if the first request sequence and the request sequence set corresponding to the first Token indicate that the first Token is valid, then in response to processing the first request message, obtaining user information corresponding to the first Token.
[0125] Among them, the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is valid, which can be understood as the server determining that the first request message is a legitimate request for authentication of the first Token. The request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is valid, which can correspond to two situations: situation three, the request sequence set corresponding to the first Token is empty; situation four, the request sequence set corresponding to the first Token does not include the first request sequence, and the first request sequence is greater than the lower limit of the request quantity. Still taking the lower limit of the request quantity as 1005 as an example, if the first request sequence is 1010, because 1010 is greater than 1005, the first Token in the first request message is valid.
[0126] In case three, it can be understood that the server has not received a request message for the first Token. Therefore, the first request message for the first Token authentication, which includes the first request sequence, cannot be considered as an interface replay attack based on the first Token authentication and must be a legitimate message.
[0127] Case four can be understood as the server determining, based on the request lower limit of the first Token, that the first request sequence belongs to a request sequence with a shorter generation time in the request sequence of the first Token and is still within the validity period. At such a time, the first request message for the authentication of the first Token including the first request sequence received can be considered a legitimate message.
[0128] In this implementation, after determining that the first Token in the first request message is valid, in addition to obtaining the user information corresponding to the first Token, the server can also update the request sequence set corresponding to the first Token based on the first request sequence. In this way, the subsequent verification of the anti-replay attack of the first Token authentication by this method is more accurate.
[0129] Corresponding to situation three, the server updates the request sequence set corresponding to the first Token based on the first request sequence, which may include: saving the first request sequence in the request sequence set corresponding to the first Token.
[0130] Corresponding to situation 4, the server updates the request sequence set corresponding to the first Token based on the first request sequence, which may include: if the number of request sequences included in the request sequence set corresponding to the first Token reaches the request concurrency threshold, then remove the smallest fifth request sequence in the request sequence set currently corresponding to the first Token, and insert the first request sequence into the request sequence set corresponding to the first Token. In this way, the idea of sliding window is adopted to maintain the validity of the request sequence. For the conventional hash storage structure, each request sequence needs to be stored in the memory. The use of a jump list (such as Zset) structure can ensure query efficiency while achieving space controllability.
[0131] The token is highly secure to use. The token returned by the server is concatenated with a random string and asymmetrically encrypted using the public key. The server uses the private key to decrypt it. During the entire interaction, even if a third party obtains the request message, it cannot identify the specific information. At the same time, the server maintains request records for the token to ensure that even if the message is intercepted, the token cannot be reused, thus avoiding the possibility of the authentication token being stolen.
[0132] It is understandable that the Token splicing request sequence and SM2 encryption are used. This obfuscated encryption transmission method can ensure the security of the request message including the Token during the transmission process. In addition, the server maintains the request record corresponding to each Token (i.e., the request sequence set) for authentication. If a third party captures the request message and sends the corresponding request message, the server will decrypt the request message and verify whether the random string spliced by the Token (i.e., the request sequence) has been used. If it has been used, the service will be rejected to ensure that the request message cannot be reused even after being captured. In addition, the Zset structure in Redis is used to greatly compress the storage space of the server for the request sequence set.
[0133] It can be seen that in the embodiment of the present application, the client uses asymmetric encryption such as SM2 to encrypt obfuscated information including the Token and the request sequence, and the server uses the Zset structure in Redis to maintain a request sequence set with a fixed step size, and detects whether the request sequence corresponding to each Token has been initiated, thereby preventing the problem of repeated requests for the same Token. In addition, in the embodiment of the present application, the server uses a unified TokenFilter to parse and verify the Token in each request message to ensure the consistency and validity of the verification results. This method can provide an effective response to interface replay attacks based on Token authentication in important scenarios such as banking and finance, and improve network security.
[0134] In order to make the introduction of the method provided in the embodiment of the present application clearer and more complete, Figure 2An example is given below to illustrate.
[0135] like Figure 2 As shown, the processing flow of the server for the received request message 1 may include:
[0136] S21, decrypt the encrypted information 1 in the request message 1 to obtain Token 1 and request sequence 1.
[0137] S22, using Token 1 as the key to search for the corresponding request sequence set 1.
[0138] S23, determine whether the request sequence set 1 is empty, if so, execute S24 to S25, otherwise execute S26.
[0139] S24, storing request sequence 1 into request sequence set 1.
[0140] S25, searching for user information corresponding to Token 1.
[0141] S26, determine whether request sequence 1 exists in request sequence set 1, if yes, execute S27, otherwise execute S28.
[0142] S27, refuse to process request message 1.
[0143] S28, determine whether the request sequence 1 is not greater than the lower limit of the request quantity, if so, execute S27, otherwise execute S25 and S29.
[0144] S29, determining whether the number of request sequences in request sequence set 1 reaches the concurrent request number threshold, if yes, executing S30, otherwise executing S24.
[0145] S30, remove the smallest request sequence in request sequence set 1, and return to execute S24.
[0146] Such processing logic can improve the security and reliability of request messages based on Token authentication.
[0147] Accordingly, the embodiment of the present application also provides an anti-replay attack device 300 based on Token authentication, such as Figure 3 The device 300 is applied to the server. The device 300 may correspond to the following Figure 5 The server 510 in can also correspond to Figure 6 The electronic device 600 shown is used as a server. The device 300 may include:
[0148] The receiving unit 301 is configured to receive a first request message, where the first request message includes encryption information;
[0149] A decryption unit 302, configured to decrypt the encrypted information to obtain a first Token and a first request sequence, where the first request sequence is used to indicate an order of the first request messages;
[0150] The processing unit 303 is configured to refuse to process the first request message if the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is invalid, and the request sequence set is used to store the request sequence in the valid request message for authentication of the first Token.
[0151] Optionally, the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is invalid, including:
[0152] The request sequence set corresponding to the first Token includes the first request sequence;
[0153] Alternatively, the request sequence set corresponding to the first Token does not include the first request sequence, but the first request sequence is less than or equal to a lower limit on the number of requests, and the lower limit on the number of requests is determined based on a concurrent request quantity threshold and the largest second request sequence in the request sequence set currently corresponding to the first Token.
[0154] Optionally, the device 300 further includes:
[0155] A determination unit is used to determine that the first request message is a replay attack against the first Token authentication.
[0156] Optionally, the device 300 further includes:
[0157] An acquiring unit is configured to acquire user information corresponding to the first Token in response to processing the first request message if the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is valid.
[0158] Optionally, the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is valid, including:
[0159] The request sequence set corresponding to the first Token is empty;
[0160] Alternatively, the request sequence set corresponding to the first Token does not include the first request sequence, and the first request sequence is greater than a lower limit on the number of requests, and the lower limit on the number of requests is determined based on a concurrent request number threshold and the largest second request sequence in the request sequence set currently corresponding to the first Token.
[0161] Optionally, the device 300 further includes:
[0162] An updating unit, configured to update a request sequence set corresponding to the first Token based on the first request sequence.
[0163] Optionally,
[0164] If the request sequence set corresponding to the first Token is empty, the updating unit is specifically configured to:
[0165] Saving the first request sequence in a request sequence set corresponding to the first Token;
[0166] If the request sequence set corresponding to the first Token does not include the first request sequence, and the first request sequence is greater than the lower limit of the request quantity, the updating unit is specifically configured to:
[0167] If the number of request sequences included in the request sequence set corresponding to the first Token reaches the concurrent request number threshold, remove the smallest third request sequence in the request sequence set currently corresponding to the first Token, and insert the first request sequence into the request sequence set corresponding to the first Token.
[0168] Optionally, the request sequence set is stored using a Zset structure in Redis, and the data of the Zset structure includes a key-value pair with a Token as a key and a request sequence corresponding to the Token as a value.
[0169] It should be noted that the specific implementation method of the device 300 and the technical effects achieved can be found in Figure 1 The method shown is related to the description of the steps implemented by the server.
[0170] Accordingly, the embodiment of the present application also provides an anti-replay attack device 400 based on Token authentication, such as Figure 4 The device 400 is applied to a client. The device 400 may correspond to the following Figure 5 The client 520 in may also correspond to Figure 6 The electronic device 600 shown is used as a client. The apparatus 400 may include:
[0171] A generating unit 401 is configured to generate a first request message, where the first request message includes first encrypted information, where the first encrypted information is information obtained by the client encrypting the first Token and a first request sequence, where the first request sequence is used to indicate an order of the first request messages;
[0172] The sending unit 402 is used to send the first request message to the server, so that the server processes the first request message based on the authentication result of the first Token in the first request message.
[0173] Optionally, the device 400 further includes:
[0174] a calculation unit, configured to add one to the first stored request sequence to obtain a second request sequence;
[0175] The generating unit 401 is further configured to generate a second request message, where the second request message includes second encrypted information, where the second encrypted information is information obtained by the client encrypting the first Token and the second request sequence;
[0176] The sending unit 402 is further configured to send the second request message to the server.
[0177] It should be noted that the specific implementation method of the device 400 and the technical effects achieved can be found in Figure 1 The method shown is related to the description of the steps implemented by the client.
[0178] In addition, the embodiment of the present application also provides a communication system 500, such as Figure 5 The communication system 500 may include a client 520 and a server 510. The server 510 is used to execute any implementation method executed by the server in the method provided in the embodiment of the present application; the client 520 is used to execute any implementation method executed by the client in the method provided in the embodiment of the present application.
[0179] In addition, an embodiment of the present application also provides an electronic device, which includes a processor and a memory: the memory is used to store instructions or computer programs; the processor is used to execute the instructions or computer programs in the memory, so that the electronic device executes any implementation of the method provided in the embodiment of the present application.
[0180] See also Figure 6 , which shows a schematic diagram of the structure of an electronic device 600 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0181] like Figure 6 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0182] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0183] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0184] The electronic device provided by the embodiment of the present disclosure and the method provided by the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0185] The embodiment of the present application also provides a computer-readable medium, in which instructions or computer programs are stored. When the instructions or computer programs are executed on a device, the device executes any implementation of the method provided in the embodiment of the present application.
[0186] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0187] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0188] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0189] The computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device can execute the method.
[0190] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0191] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0192] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit / module does not, in some cases, constitute a limitation on the unit itself.
[0193] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0194] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0195] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0196] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0197] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0198] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0199] It should be noted that in the embodiments of the present application, user sensitive information is not involved, and user-related information is obtained, used and determined after user authorization. In one example, before obtaining user-related information, the corresponding interface displays prompt information related to obtaining data use authorization. The prompt information is based on relevant laws and regulations in an appropriate manner to inform the user of the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure, so that the user can determine whether to agree to the authorization based on the prompt information. It can be understood that the above notification and the process of obtaining user authorization are only illustrative and do not constitute a limitation on the implementation method of the present disclosure. Other methods that meet relevant laws and regulations may also be applied to the implementation method of the present disclosure.
[0200] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for preventing replay attacks based on Token authentication, characterized in that: Applied to the server, the method includes: receiving a first request message, wherein the first request message includes encryption information; Decrypting the encrypted information to obtain a first token Token and a first request sequence, where the first request sequence is used to indicate an order of the first request messages; If the request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is invalid, the first request message is rejected, and the request sequence set is used to store the request sequence in the valid request message for the first Token authentication.
2. The method according to claim 1, characterized in that The request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is invalid, including: The request sequence set corresponding to the first Token includes the first request sequence; Alternatively, the request sequence set corresponding to the first Token does not include the first request sequence, but the first request sequence is less than or equal to a lower limit on the number of requests, and the lower limit on the number of requests is determined based on a concurrent request quantity threshold and the largest second request sequence in the request sequence set currently corresponding to the first Token.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: It is determined that the first request message is a replay attack against the first Token authentication.
4. The method according to claim 1, characterized in that The method further comprises: If the first request sequence and the request sequence set corresponding to the first Token indicate that the first Token is valid, in response to processing the first request message, user information corresponding to the first Token is obtained.
5. The method according to claim 4, characterized in that The request sequence set corresponding to the first request sequence and the first Token indicates that the first Token is valid, including: The request sequence set corresponding to the first Token is empty; Alternatively, the request sequence set corresponding to the first Token does not include the first request sequence, and the first request sequence is greater than a lower limit on the number of requests, and the lower limit on the number of requests is determined based on a concurrent request number threshold and the largest second request sequence in the request sequence set currently corresponding to the first Token.
6. The method according to claim 4 or 5, characterized in that: The method further comprises: Update the request sequence set corresponding to the first Token based on the first request sequence.
7. The method according to claim 6, characterized in that If the request sequence set corresponding to the first Token is empty, updating the request sequence set corresponding to the first Token based on the first request sequence includes: Saving the first request sequence in a request sequence set corresponding to the first Token; If the request sequence set corresponding to the first Token does not include the first request sequence, and the first request sequence is greater than the lower limit of the number of requests, then updating the request sequence set corresponding to the first Token based on the first request sequence includes: If the number of request sequences included in the request sequence set corresponding to the first Token reaches the concurrent request number threshold, remove the smallest third request sequence in the request sequence set currently corresponding to the first Token, and insert the first request sequence into the request sequence set corresponding to the first Token.
8. The method according to any one of claims 1 to 7, characterized in that: The request sequence set is stored in a Zset structure in Redis, and the data of the Zset structure includes a key-value pair with a Token as a key and a request sequence corresponding to the Token as a value.
9. A method for preventing replay attacks based on Token authentication, characterized in that: Applied to a client, the method comprises: Generate a first request message, where the first request message includes first encrypted information, where the first encrypted information is information obtained by the client encrypting the first token Token and a first request sequence, where the first request sequence is used to indicate an order of the first request messages; Send the first request message to the server so that the server processes the first request message based on the authentication result of the first Token in the first request message.
10. The method according to claim 9, characterized in that The method further comprises: Add one to the first stored request sequence to obtain a second request sequence; Generate a second request message, where the second request message includes second encrypted information, where the second encrypted information is information obtained by the client encrypting the first Token and the second request sequence; Send the second request message to the server.
Citation Information
Patent Citations
Replay attack prevention method and device
CN109756460A
Method for preventing replay attack of API (Application Program Interface)
CN113382011A
Method and system for defending replay attack based on one-time key
CN113676452A
Replay attack defense method and system
CN116094810A
IPsec anti-replay method based on FPGA
CN116319093A