NFC relay attack detection method and system based on federated learning
Through federated learning and deep convolutional neural network models, the problem of recognition accuracy and generalization in NFC relay attack detection is solved, achieving high-accuracy detection and defense in diverse scenarios, and is suitable for real-time performance and resources of NFC applications. Restricted scenarios.
Patent Information
- Application Number
- CN202410520977.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-28
- Publication Date
- 2024-10-11
AI Technical Summary
When detecting and defending against NFC relay attacks, existing technologies have problems such as high recognition accuracy requirements, environment dependence, and model generalization, making it difficult to effectively apply in diverse scenarios.
Adopting a method based on federated learning, a deep convolutional neural network model is used to extract the fingerprint features of the transmitting source device from the NFC signal waveform. Through the federated learning system of the client-server architecture, a robust model is trained to distinguish legitimate and illegal signals. and terminates communications when a relay attack is recognized.
It achieves high-accuracy NFC relay attack detection in diverse scenarios, avoids data privacy issues, reduces resource overhead, adapts to feature drift caused by hardware aging, and meets the real-time requirements of NFC applications.
Smart Images

Figure CN118760939A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical fields of deep learning, big data, federated learning, and NFC security, and in particular to an NFC relay attack detection method and system based on federated learning. Background Art
[0002] NFC technology in radio frequency identification (RFID) has been widely used in smart cards, mobile payments, access control systems, and keyless entry systems (PKES) for its convenience and high security. However, NFC has the potential security risk of being attacked by relays, and there are many problems that need to be solved.
[0003] Traditional solutions have certain limitations, such as requiring too high detection and recognition accuracy, or requiring the collection of specific sensor parameters in the application scenario, which affects their promotion and implementation. The radio frequency fingerprint technology that has emerged in recent years has been proven to be feasible for identifying the source device, but there is a problem of model generalization.
[0004] Peer-related technologies, technologies in similar industries:
[0005] Technology 1: Relay attack defense based on the distance boundary protocol, which uses the round-trip time (RTT) of the challenge bit when establishing communication to infer the upper limit of the physical distance between the two entities. However, due to the extremely fast flight speed of RF signals and the usually short communication range channel noise, this type of solution requires extremely high flight time detection accuracy (nanosecond level). In addition, current research shows that in commercial contactless products such as NXP Mifare, the distance boundary protocol is not enabled by default or lacks reference in technical documents, which makes it theoretically feasible but has not yet been put into practical use on a large scale to defend against relay attacks.
[0006] Technology 2: Based on the environmental detection method, the surrounding environment parameters are collected to verify the consistency of the environments of the two communicating entities to defend against relay attacks. However, this type of solution is highly related to the specific usage scenario. It is difficult to reach a consensus on the collection parameters of the proposed solutions and requirements are put forward for the scenario; when the sensor fails, the accuracy of this method will also drop significantly or even fail.
[0007] Technology 3: RF signal fingerprint recognition methods are used to identify specific emission sources, and in recent years they are often combined with deep learning methods. However, the original training data reported in this type of method are mostly collected from controlled or single experimental environments; there are generalization issues with RF fingerprint recognition models based on deep learning; and there is currently no easy-to-implement and feasible solution for NFC relay attack defense. Summary of the invention
[0008] The technical problem to be solved by the present invention is to address the shortcomings of the background technology. The present invention provides an NFC relay attack detection method and system based on federated learning. By using a deep convolutional neural network model, the fingerprint of the transmitting source device in the transmitted NFC signal waveform is captured as a specific device feature for identification and classification, and the legitimate NFC device signal and the illegal NFC signal are effectively distinguished. When an NFC relay attack is detected and identified, the communication is terminated to realize the relay attack defense on the terminal side.
[0009] The present invention adopts the following technical solutions to solve the above technical problems:
[0010] A method for detecting NFC relay attacks based on federated learning specifically comprises the following steps:
[0011] Step 1, select the NFC reader device: a universal reader based on NXP's NFC chip; select the NFC tag that has been authenticated as legal; the device used to simulate the NFC relay attack as the illegal NFC tag; assign a classification label to each NFC tag; record the NFC reader instance ID; and proceed to step 2;
[0012] Step 2: On each NFC reader side, record and collect the original NFC signal generated by the interaction between the NFC tag and the NFC reader and the relayed NFC signal data. After data collection, data frame analysis, data clipping, and data cleaning in sequence, only save the NFC tag reply to the reader instruction; direction: NFC tag → NFC reader; ATQA command signal waveform, generate the NFC ATQA waveform data set, and then enter step 3;
[0013] Step 3: Build a deep convolutional neural network model for signal recognition and classification and distinguishing between legitimate and relay NFC signals; use this model as the network structure to be trained in the federated learning framework; build a federated learning training system and proceed to step 4;
[0014] Step 4: Use the client-server architecture to build a horizontal federated learning training system; select several NFC reader terminals as the participating clients of federated learning; select a central server node to play the role of orchestration, which receives the model parameters sent by each participating client, performs central aggregation and sends the parameters of the new round of aggregation model; each node in the federated learning system realizes distributed point-to-point communication;
[0015] Step 5: With the NFC waveform dataset generated and held by the client of the participant as input and the category label to which the data sample is classified as output, each client node of the participant jointly trains a federated model for detecting and identifying NFC relay attacks in a federated learning manner under the arrangement of the central server based on the adopted model structure and initial state, the data sample on the client side, the true value of the label, and the considered evaluation index; and runs the federated learning training until the iteration target is reached;
[0016] Step 6: The client side of the participant saves two copies of model parameters: a model for continuous federated training and a model for inference. The end side uses the federated training model to participate in the continuous iteration of the federated model. Until the next update of the inference model parameters, the end side uses the federated model that meets the iteration target as the inference model, that is, the model used to detect and identify NFC relay attacks.
[0017] Step 7: When an NFC interaction occurs, the terminal device relies on its own computing power to pre-process the transmitted NFC signal in real time, and inputs the inference model to obtain the classification and identification result of the signal, and then detects and identifies the NFC relay attack based on the preset judgment logic; when it is identified as an NFC relay attack, the NFC reader terminal terminates the NFC communication to defend against the NFC relay attack.
[0018] As a further preferred solution of the NFC relay attack detection method based on federated learning of the present invention, in step 2, specifically, the format of saving the NFC signal data is a WAV file;
[0019] NFC data frame analysis is based on the data frame representation specified by the ISO-14443A protocol. Real-time analysis of NFC data frames is performed in both the NFC tag-NFC reader and NFC tag-NFC reader directions. However, the waveform of the signal replied by the NFC tag in the NFC tag-NFC reader direction is retained as the data sample.
[0020] As a further preferred solution of the NFC relay attack detection method based on federated learning of the present invention, the data frame parsing of NFCTypeA performs symbol matching based on signal cross-correlation values to complete real-time parsing of the data frame.
[0021] As a further preferred solution of the NFC relay attack detection method based on federated learning of the present invention, the label of the data sample is assigned as the label of the corresponding NFC card; the data sample is saved separately according to the ID of each NFC reader and a one-to-one mapping is achieved from a certain reader ID to the data set generated at the corresponding reader.
[0022] As a further preferred solution of the NFC relay attack detection method based on federated learning of the present invention, step 2 specifically includes the following steps:
[0023] Step 2.1, place the NFC tag within the working magnetic field of the NFC reader; start the recording and NFC decoding program; power on the NFC reader; record the NFC signal of the interaction between the reader and the tag for a period of time;
[0024] Step 2.2, based on the data frame analysis results and NFC protocol knowledge, the data processing and cropping program locates the sampling points of the start and end positions of the ATQA instructions in all recorded files for the data frame types and frame contents before and after any data frame, accurately captures the ATQA segment waveform and writes it into a WAV file; the classification label of the data sample is the label of the NFC tag;
[0025] The input of the data decoding and cropping program is the original digital signal output by the AirSpy SDR hardware device. The signal is converted into a wav format file corresponding to all the original digital signals and a json file corresponding to its decoding and parsing results based on signal cross-correlation and knowledge of the ISO / IEC 14443 protocol specification that NFC Type A complies with by the data parsing program written in C++. The content includes all the signals sent by the NFC reader and NFC tag. The correlation value calculation method of the signal is:
[0026]
[0027] Among them, the correlation value C(x,y) in the interval [n1,n2] is a real number that is independent of n;
[0028] By calculating the correlation value between the original signal and the reference signal S0, S1 and their magnitude relationship, the corresponding symbol mode and logic 1 or logic 0 can be mapped. The correlation value calculation formula is:
[0029]
[0030]
[0031] in
[0032]
[0033] x(t) is the original baseband signal;
[0034] The data clipping program uses Python to first read the decoding result of the NFC data frame in json, and based on the numpy library, intercepts and retains the waveform of the ATQA command signal determined by the start and end sampling points from the original wav according to the decoding result as the data sample;
[0035] Step 2.3, similar to steps 2.1 to 2.2, collect waveform samples under different channel conditions at multiple readers located in multiple scenes; after verifying the correctness of the data samples, use them as a local data set unique to the NFC reader terminal at that location and form a one-to-one mapping from each reader ID to its private local data set.
[0036] As a further preferred embodiment of the NFC relay attack detection method based on federated learning of the present invention, in step 3, the proposed convolutional neural network structure is specifically a CNN comprising three convolutional layers, each convolutional layer is followed by a ReLu activation function, and the activation function of the third convolutional layer is followed by a Flatten layer and a Dense layer.
[0037] As a further preferred embodiment of the NFC relay attack detection method based on federated learning of the present invention, the relevant model evaluation indicators are accuracy, precision, recall rate and F1 score; in the evaluation of the federated model, the average accuracy of the last 5 rounds of model accuracy after training a certain number of rounds is used as the main evaluation indicator; wherein the certain number of rounds is 250 rounds.
[0038] As a further preferred embodiment of the NFC relay attack detection method based on federated learning of the present invention, in step 5, quantization based on lossy compression is introduced during federated learning training, and the original data represented by the 32-bit single-precision floating point data type tf.float32 is quantized into an 8-bit integer value, thereby reducing the amount of data uploaded by the client to the server.
[0039] As a further preferred solution of the NFC relay attack detection method based on federated learning of the present invention, in step 5, the goal of the federated optimization problem is to find the model parameter w that minimizes the loss function of the entire data set:
[0040]
[0041] Among them, the loss function is:
[0042]
[0043] For n data samples, each sample (x i ,y i ), for the model weight parameter w, the expected loss from running the model inference;
[0044] For each round of federated learning with K participants, D k represents the local data set held by the kth participant, the above formula can be written as:
[0045]
[0046] Among them, F k (w) is the average loss of all k samples on one participant’s side;
[0047] The federated learning training system runs the federated average algorithm, and one complete iteration is called a round. A round of federated learning iteration includes the following steps 5.1 to 5.4:
[0048] Step 5.1: Federated learning initialization. The central server node first sends a shared initial model state w0 to each participating client. In specific implementation, w0 is the parameter of the imported pre-trained model.
[0049] Step 5.2: In any round t, select K participating NFC terminals participating in the current round of federated training based on their local data and the current round t starting model state w t Compute local gradients:
[0050]
[0051] In practical applications, whether a participant participates in the current round of federated training iteration depends on whether it is in a stable activity state;
[0052] Step 5.3, in the central aggregation phase, the central server calculates and aggregates the model parameters and performs model updates:
[0053]
[0054]
[0055] in, The model sharing weight w issued by the central server in the round is used by the participant k in the tth round t The model weight parameters are updated after local iteration; the parameters are combined into a weighted average, where the weight is the ratio of the data samples at each participant's client to the total number of data samples of all global participants, so that clients with larger data volumes have greater influence in model iteration;
[0056] For data quantization, consider a distributed average estimation problem, that is, the average of several vectors To estimate, Represents the maximum and minimum values of all coordinates of each d-dimensional vector. The proposed random uniform quantization method assigns the quantized value of each coordinate as follows:
[0057]
[0058] Among them, the quantization level And we can make; E(Y i (j)) = X i(j) thereby achieving The estimate and bring The mean square error of
[0059] Step 5.4, the central server node sends w t+1 ;
[0060] Through the federated learning model training running in a cyclic manner and the federated averaging algorithm, federated learning achieves model training and iteration without directly accessing the data and taking into account data security and privacy.
[0061] A system for detecting and identifying NFC relay attacks based on federated learning, comprising an NFC waveform data acquisition and processing module, a horizontal federated learning module, a model inference module, and an NFC relay attack detection alarm module;
[0062] The data generation and processing module is used to generate and persist data sets, and supports adding new data generated by the system during continuous operation to the global data to incrementally expand the data set;
[0063] The horizontal federated learning module is used in the federated learning system with client-server architecture. With the help of the federated learning framework, the federated model training based on the deep convolutional neural network structure is carried out based on the local data set of the NFC reader terminal of each participant, the selected loss function and the iteration target;
[0064] The model inference module is used to run the model inference under the parameter state based on the model parameters persisted on the terminal side, and output the results of NFC relay attack detection and identification for the current communication in real time;
[0065] The detection and alarm module is used to interact with the user through the platform interface or mobile phone App interface based on the output of the model inference module during each NFC interaction; when an NFC relay attack is detected, the current communication is terminated and the alarm information is pushed to the user interface; the user interface can choose to provide feedback, or choose to take over the detection and identification system for manual authentication.
[0066] Compared with the prior art, the present invention adopts the above technical solution and has the following technical effects:
[0067] 1. The present invention adopts a method based on RF signal fingerprint recognition, which uses the waveform of the transmitted NFC signal to identify the specific transmitting source device, and can detect and identify NFC relay attacks at the physical layer, and achieve a high recognition accuracy rate; compared with the distance boundary protocol-based and environmental monitoring-based methods, it is a new and feasible method based on machine learning. No patent invention related to the use of machine learning methods and RF signal fingerprints for NFC relay attack defense has been found in previous relevant studies or patents;
[0068] 2. The federated learning scheme adopted in the present invention organizes multiple NFC readers to train the federated model without sharing the original data; this scheme ensures data privacy, enables the use of a large amount of fragmented data that cannot be shared due to data security concerns, and solves the problem of difficulty in collecting data sets based on machine learning methods in current field problems;
[0069] 3. The federated learning adopted in the present invention organizes multiple NFC card reader terminals as participating clients to jointly train the federated model, and integrates the diverse NFC waveform data from different card readers under different channel conditions. Compared with the centralized training method in previous studies or patents, it can train a more robust and better generalized federated model;
[0070] 4. The present invention is aimed at the scenario where low-power, resource-constrained terminal devices are the main type in NFC applications. Federated learning only shares model parameters instead of directly uploading original data to reduce resource overhead on the terminal side device; in addition, the present invention proposes lossy compression quantization based on the client parameter upload stage to further reduce the data transmission volume and save bandwidth overhead;
[0071] 5. The solution of the present invention for detecting NFC relay attacks based on machine learning methods can meet the real-time nature of NFC applications while identifying NFC relay attacks with a high accuracy rate: the ATQA instruction waveform based on the NFC tag designed in this patent can detect and identify relay attacks before an NFC transaction, rather than processing them afterwards;
[0072] 6. In the present invention, since the RF signal fingerprint is essentially the defect feature of the hardware circuit of the transmitting source device, the fingerprint may produce feature drift over time due to hardware aging in the long run; the federated learning adopted in this patent is more suitable for the current scenario. New data is continuously added during the operation of the system, and the federated learning is continuously iterated and deployed, so that the model can adapt to the feature offset;
[0073] 7. The present invention has designed a function for the user to evaluate the model inference results. For the model inference results, the user can provide feedback on the correctness of the current judgment result through the platform or mobile phone App interface, and downgrade to traditional identity authentication with user intervention when the model misjudges or when necessary;
[0074] 8. In real-world applications, RFID / NFC technology is commonly used in vehicle keyless entry and start (PKES) systems, access control, smartphone payments, etc. Successful implementation of an NFC relay attack may result in considerable property losses; relay attacks are usually difficult to detect and prevent, and the NFC relay attack detection and identification solution of this solution can effectively solve this NFC security issue. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] 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 of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0076] Figure 1 It is a schematic diagram of data collection of the present invention;
[0077] Figure 2 It is a data sample and decoding schematic diagram of the present invention;
[0078] Figure 3 It is a flow chart of the overall collection and processing of NFC-ATQA waveform data of the present invention;
[0079] Figure 4 It is a schematic diagram of the CNN network structure model implemented by the present invention using Tensorflow Keras;
[0080] Figure 5 It is a framework diagram of the federated learning system of the client-server architecture of the present invention;
[0081] Figure 6 The federated algorithm used in the present invention can achieve faster convergence and higher performance than the original FedAvg algorithm, and is a schematic diagram of the model accuracy performance. DETAILED DESCRIPTION
[0082] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings:
[0083] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. The present invention is described in detail below based on the drawings and preferred embodiments, and the purpose and effect of the present invention will become clearer. It should be understood that the specific embodiments described here are only used to explain the present invention and are not used to limit the present invention.
[0084] Glossary:
[0085] NFC (Near Field Communication): is a set of communication protocols that allows two electronic devices (one of which is usually a mobile device, such as a smartphone) to communicate within a few centimeters of each other; it is a radio frequency identification (RFID) technology that has been widely used in recent years. It can realize short-range contactless communication functions on smartphones and other devices, and provide convenient services such as mobile payment, wearable devices, and passive keyless entry and start systems (PKES).
[0086] ATQA (Answer To reQuest code A): In RFID / NFC technology, the RFID / NFC responds to the reader's polling request command REQuest Command Type A (REQA), after which the NFC tag enters the ready state. The ATQA command is a data segment that the NFC tag must send under the constraints of the NFC-A specification. Other related details are in the ISO / IEC14443-3 specification.
[0087] Relay Attack: In an open wireless channel, wirelessly transmitted information can be easily eavesdropped or relayed. RFID / NFC communication systems are vulnerable to relay attacks. The attacker of a relay attack is located between two legitimate communication entities, deceiving the two communication entities into believing that they are communicating in the near field. Relay attacks are a special type of man-in-the-middle attack, but the difference is that relay attacks only forward signals without parsing or modifying data. For this reason, methods based on data encryption, cryptographic protocols, etc. at the application layer are difficult to resolve this type of relay attack at the physical layer.
[0088] In order to solve the security risk of NFC relay attack, this method uses a deep convolutional neural network model to capture the fingerprint of the transmitting source device in the transmitted NFC signal waveform as a specific device feature for identification and classification, effectively distinguishing between legitimate NFC device signals and illegal (relayed) NFC signals, and terminating the communication when an NFC relay attack is detected to achieve relay attack defense on the end side. More importantly, in order to solve the poor generalization ability of the RF signal fingerprint method in a single controlled data acquisition environment and the data collection and privacy issues in the scenario where NFC is widely used on the end side, federated learning is used to organize and arrange various NFC reader terminal devices for federated model training. Without directly accessing the original data, federated learning can benefit from diverse data from all parties and obtain a more robust classification and recognition model. Ultimately, a highly secure NFC terminal device and system that can be used for vehicle keyless entry systems, access control, etc. is realized.
[0089] The present invention designs an NFC relay attack detection method and system based on federated learning, which are used to detect and identify the occurrence of NFC relay attacks in real time, terminate illegal communications, and improve NFC security.
[0090] In practical applications, follow steps 1 to 6 below to implement NFC relay attack detection and identification based on federated learning.
[0091] Step 1: Select an NFC reader device, which in this example is a universal reader based on NXP's NFC chip. Select an NFC tag that has been authenticated as legitimate; design and implement a device that simulates an NFC relay attack (wired or wireless) as an illegal NFC tag; assign a classification label to each NFC tag; record the NFC reader instance ID; and then proceed to step 2.
[0092] In specific practical applications, authenticated legal tags refer to, for example, the car keys distributed by the original manufacturer in the vehicle PKES, the NFC access control cards distributed by the gate machine, etc. Under normal circumstances, the number of NFC tags authenticated as legal can be considered to be always limited. In this embodiment, the NFC protocol considered is NFC Type A that complies with the more common ISO / IEC 14443 protocol. In the embodiment, the legal NFC tags selected are 4 NXP MIFARE M1 type NFC tags.
[0093] In the specific implementation, it is impossible to obtain all illegal relay signal data from the attacker implementing the NFC relay attack. The purpose of designing a device to simulate the NFC relay attack is to provide illegal NFC signal samples in the initial data set for pre-training of the model.
[0094] Step 2: On each NFC reader side, record and collect the original signal data generated by the interaction between the NFC tag and the NFC reader. The data collection diagram is shown in the attached figure. Figure 1 After data collection, data frame analysis, data clipping, and data cleaning, only the NFC tag reply reader command (direction: NFC tag → NFC reader) ATQA command signal waveform is saved to generate the NFCATQA waveform data set. The data sample and decoding diagram are shown in the attached figure. Figure 2 . Then go to step 3.
[0095] Here, the specific implementation of step 2 is explained by taking the data collection and preprocessing in the pre-training stage as an example. In practical applications, the data preprocessing and data set generation on each NFC reader end are similar. The overall collection and processing flow of NFC-ATQA waveform data is shown in the attached figure. Figure 3 Specifically, the method comprises the following steps 2.1 to 2.3:
[0096] Step 2.1: Place the NFC tag within the working magnetic field of the NFC reader; start the recording and NFC decoding process; power on the NFC reader; and record the NFC signals of the interaction between the reader and the tag for a period of time.
[0097] In specific implementation, the NFC antenna captures the wireless signal transmitted between the NFC tag and the NFC reader; the signal acquisition is based on AirSpy's software defined radio (SDR) hardware platform and equipment, which has a receiving frequency range of 24-1700MHz. AirSpy is connected to a computer or other device with computing power, and uses a sampling rate of 10MSPS to collect the captured signals for further processing.
[0098] Step 2.2, based on the data frame analysis results and NFC protocol knowledge, the data processing and cropping program locates the sampling points of the start and end positions of the ATQA instructions in all recorded files for any data frame type and frame content before and after the data frame, accurately captures the ATQA segment waveform and writes it into the WAV file. The classification label of the data sample is the label of the NFC tag.
[0099] The input of the data decoding and cropping program is the original digital signal output by the AirSpy SDR hardware device. The signal is converted into a wav format file corresponding to all the original digital signals and a json file corresponding to its decoding and parsing results based on the signal cross-correlation and the knowledge of the ISO / IEC 14443 protocol specification that NFC Type A complies with by the data parsing program written in C++. The content includes all the signals sent by the NFC reader and NFC tag. The correlation value calculation method of the signal is:
[0100]
[0101] Among them, the correlation value C(x,y) in the interval [n1,n2] is a real number independent of n.
[0102] By calculating the correlation value between the original signal and the reference signal S0, S1 and their magnitude relationship, the corresponding symbol mode and logic '1' or logic '0' can be mapped. The correlation value calculation formula is (taking Manchester encoding in the direction of NFC tag → NFC reader as an example):
[0103]
[0104]
[0105] in
[0106]
[0107] x(t) is the original baseband signal.
[0108] After decoding, the final data frame JSON structure and some decoding result examples are shown in Table 1:
[0109] Table 1
[0110]
[0111] The data clipping program uses Python to first read the decoding result of the NFC data frame in json. Based on the numpy library, it intercepts and retains the waveform of the ATQA command signal determined by the start and end sampling points from the original wav according to the decoding result as the data sample.
[0112] Step 2.3, similar to the above steps 2.1 to 2.2, collect waveform samples under different channel conditions at multiple readers located in multiple scenes (indoors, outdoors, etc.); after verifying the correctness of the data samples, use them as a local data set unique to the NFC reader terminal at that location and form a one-to-one mapping from each reader ID to its private local data set.
[0113] In actual applications, the ids of all participating clients form a list client_ids, and the private datasets of each party are stored locally or in a remote storage. The mapping function is used to map the client id to the dataset instance at the corresponding location, which is used to realize the dynamic loading of the dataset during training.
[0114] Step 3: Use Tensorflow Keras to build a deep convolutional neural network (CNN) model for signal recognition and classification and distinguishing between legitimate and relayed NFC signals. This model serves as the network structure to be trained in the federated learning framework. Then build a federated learning training system and proceed to step 4.
[0115] In practical applications, the proposed convolutional neural network structure is a CNN with three convolutional layers. Each convolutional layer is followed by a GroupNormalization layer, using the ReLu activation function. The activation function of the third convolutional layer is followed by a Flatten layer and a Dense layer. The CNN network structure model implemented using Tensorflow Keras is shown in the figure below. Figure 4 shown.
[0116] Step 4: Use the client-server (CS) architecture to build a horizontal federated learning training system. Select several NFC reader terminals as the participating clients of federated learning; select a central server node to play the role of orchestration, which receives the model parameters sent by each participating client, performs central aggregation, and sends the parameters of the new round of aggregation model. Each node in the federated learning system realizes distributed point-to-point communication.
[0117] In practical applications, the client-server federated learning system framework designed and implemented is as follows Figure 5 As shown:
[0118] Under the orchestration of the central server node, federated learning enables multiple NFC readers to jointly conduct federated learning training as participants.
[0119] In step 5, the NFC waveform dataset generated and independently held by the participating client is used as input, and the category label to which the data sample is classified is output. Each NFC reader terminal, as a participating client, jointly trains a federated model for detecting and identifying NFC relay attacks in a federated learning manner under the orchestration of the central server node based on the adopted model structure and initial state, the data sample on the client side, the true value of the label, and the considered evaluation indicators.
[0120] In specific implementation, the goal of the federated optimization problem is to find the model parameter w that minimizes the loss function of the entire data set:
[0121]
[0122] Among them, the loss function is:
[0123]
[0124] For n data samples, each sample (x i ,y i ), for the model weight parameter w, the expectation of the loss obtained by running the model inference.
[0125] Now for each round of federated learning with K participants, D k represents the local data set held by the kth participant, the above formula can be written as:
[0126]
[0127] Among them, F k (w) is the average loss of all k samples on one participant's side.
[0128] In practical applications, the federated learning training system runs the federated average algorithm, and one complete iteration is called a round. A round of federated learning iteration includes the following steps 5.1 to 5.4:
[0129] Step 5.1: Federated learning initialization: the central server node first sends a shared initial model state w0 to each participating client. In specific implementation, w0 is the parameter of the imported pre-trained model.
[0130] Step 5.2: In any round t, select K participating NFC terminals participating in the current round of federated training based on their local data and the current round t starting model state w t Compute local gradients:
[0131]
[0132] In practical applications, whether a participant participates in the current round of federated training iteration depends on whether it is in a stable active state, such as when the vehicle is started in the vehicle PKES scenario (both the car key and the car computer are in operation).
[0133] Step 5.3, in the central aggregation phase, the central server calculates and aggregates the model parameters and performs model updates:
[0134]
[0135]
[0136] in The model sharing weight w issued by the central server in the round is used by the participant k in the tth round t The model weight parameters are updated after local iteration. The parameters are combined into a weighted average, where the weight is the ratio of the data samples at each participant's client to the total number of data samples of all global participants, so that clients with larger data volumes have greater influence in model iteration.
[0137] In particular, for data quantization, we consider a distributed average estimation problem, that is, the average of several vectors To estimate, Represents the maximum and minimum values of all coordinates of each d-dimensional vector. The random uniform quantization method they proposed assigns the quantized value of each coordinate as follows:
[0138]
[0139] The quantization level And it can be made. E(Y i (j)) = X i (j) thereby achieving The estimate and bring The mean square error of . It is worth noting that this method does not require additional assumptions about the probability distribution of the data and is data-oriented rather than model-oriented. Specifically, for all data whose number of elements exceeds the threshold of 20,000 during the aggregation process, they are first flattened into rank-1 tensors, and then 8-bit (256-level) quantized based on the maximum and minimum values, and the original data elements (such as tff.TensorType) represented by 32-bit single-precision floating-point data types (tf.float32) are converted to integer values under 8-bit quantization.
[0140] Step 5.4, the central server node sends w t+1 ;
[0141] Through the federated learning model training and federated averaging algorithm running in a cyclic manner, federated learning realizes model training and iteration without directly accessing the data and taking into account data security and privacy. In the solution verification stage, in order to show that the federated model can obtain a model with stronger generalization ability and higher accuracy, a baseline is considered, which is obtained by cross-dataset verification by multiple models centrally trained on different local data sets, and the average model performance is obtained; an ideal performance is considered, that is, the model classification performance obtained by centrally training all data at one time, but it is considered unachievable in practical applications. The federated algorithm used in the patent can achieve faster convergence and higher performance than the original FedAvg algorithm. The model accuracy performance is shown in the attached figure. Figure 6 shown.
[0142] Step 6. The client side of the participant saves two copies of model parameters: a model for continuous federated training and a model for inference. The client side uses the federated training model to participate in the continuous iteration of the federated model; until the next update of the inference model parameters, the client side uses the federated model that meets the iteration target as the inference model, that is, the model used to detect and identify NFC relay attacks;
[0143] Based on the above steps 1 to 6, a model for detecting and identifying NFC relay attacks can be obtained. In practical applications, NFC relay attacks can be resisted based on step A.
[0144] Step A: When an NFC interaction occurs, the end-side device relies on its own computing power to pre-process the transmitted NFC signal in real time and input it into the inference model. The inference output is the probability of each NFC tag in the multi-classification problem. Based on the preset judgment logic, the multi-classification results are converted into binary classification results: when the tag with the highest probability is a known illegal tag or the maximum probability of all tags is lower than the preset threshold, the model will identify it as a signal from an illegal device, terminate the communication to defend against NFC relay attacks, and alert the user.
[0145] Based on the above design, this patent invention aims to solve the security problem that NFC is vulnerable to relay attacks, and proposes a system for NFC relay attack detection and identification method based on federated learning, including a data generation and processing module, a horizontal federated learning module, a model inference module and a detection alarm module.
[0146] The NFC waveform data acquisition and processing module generates and persists a data set based on the aforementioned steps 1 to 2, and supports adding new data generated by the system during continuous operation to the global data to incrementally expand the data set. In actual application examples, the present invention sets common application scenarios including vehicle keyless entry and start (PKES) system and access control.
[0147] In the PKES implementation, the legitimate car key distributed by the manufacturer is tested and interacted before leaving the factory, and the generated NFC waveform data is used as a data set sample. In subsequent use, the legitimate car key held by the owner is placed near the car's center console while driving, and can continue to generate NFC interaction data to supplement the legitimate signal data.
[0148] The horizontal federated learning module is a federated learning system that uses a client-server (CS) architecture. With the help of the federated learning framework, the federated model training based on the convolutional neural network structure is carried out based on the local data set of the NFC reader terminal of each participant, the selected loss function and the iteration target. In practical applications, for the training of federated models, the more recommended method is to first conduct traditional centralized training based on the data generated before leaving the factory to obtain a pre-trained model parameter, and then continue to iterate on this basis to achieve faster convergence of the federated model.
[0149] In actual applications, NFC reader terminals generate frequent NFC interactions, and the resulting data is usually not effectively utilized or is inconvenient to collect centrally due to data silos. As the vehicle position changes, the new data generated and collected will be richer data containing more channel conditions. Federated learning effectively uses this data to train the federated model, which will make the final model more inclined to capture the RF fingerprint features of the NFC tag (i.e., the car key) to obtain better generalization capabilities for variable wireless channels, thereby improving the accuracy and robustness of the model.
[0150] During the federated learning deployment phase, car companies are responsible for building and managing distributed computing systems for federated learning. Onboard computers and other edge computing devices rely on their network communication capabilities to communicate and interact with central server nodes through RPC remote calls, run model training and model inference based on their own computing capabilities, enable PKES on the vehicle to participate in federated model training, and continuously iterate and deploy federated models for NFC relay attack detection.
[0151] The model inference module is used to apply the model obtained by federated training for detecting and identifying NFC relay attacks, run model inference and output the results of NFC relay attack detection and identification for the current communication in real time; in the verification phase, the model predicted the time for 54,000 data samples to be 8.603 seconds. If all samples are averaged, it is equivalent to a single inference running time of 0.159 milliseconds, which meets the NFC interaction latency requirements.
[0152] The detection and alarm module interacts with the user through the platform interface or mobile app interface based on the output of the model inference module during each NFC interaction. When an NFC relay attack is detected, the current communication is terminated and the alarm information is pushed to the user interface. The user interface can choose to provide feedback or take over the detection and identification system for manual authentication.
[0153] Data collection platform for collecting NFC-ATQA waveforms: This patent design implements a data collection process for parsing and cutting out ATQA data samples from wireless signals, which can extract the waveform of ATQA, a common instruction segment in RFID / NFC, from the original signal in real time as a data sample for extracting the NFC tag radio frequency fingerprint. The relevant field currently lacks a public data set for training, detecting and identifying NFC relay attack models. The data collection method proposed in this patent can be used to create corresponding data sets and to train models for detecting and identifying NFC relay attacks.
[0154] NFC relay attack identification method using RF fingerprint and deep learning: The solutions of current related research are mainly based on distance boundary protocol and environmental monitoring. Compared with the existing patents, the method using spatiotemporal characteristics has the limitation of high distance detection accuracy and Wifi or cellular network coverage in the application scenario. This method proposes to detect and identify NFC relay attacks from the perspective of specific transmitting source device identification based on the waveform of the physical layer transmission signal, using RF signal fingerprint and deep learning methods. It has a high accuracy rate, meets the NFC application interaction time requirements, and has no additional requirements for the scenario, which is easy to promote.
[0155] NFC relay attack identification method based on federated learning: The federated learning proposed in this patent utilizes more diverse signal data from each participant to jointly train a more robust federated model, thereby improving the accuracy and robustness of the NFC relay attack detection and identification model. Compared with previous studies and patents, it avoids the problem of model generalization caused by the single channel environment in which the data samples are located. At the same time, the system is more suitable for scenarios with massive distribution of NFC applications (multiple participants) and limited communication capabilities (this patent proposes to reduce the amount of uploaded data based on quantization).
[0156] NFC relay attack defense system based on federated learning: Compared with the methods proposed in existing patents, this patent's NFC relay attack detection and identification system based on federated learning includes a horizontal federated learning module, a model inference module, and a detection and alarm module. During NFC interaction, the system pre-processes signal data and performs model inference in real time, detects relay attacks in real time, and terminates communication and issues an alarm when an attack occurs.
[0157] Continuously iterative relay attack detection function: The federated learning method of this patent has been verified to be able to continue to iterate the federated model based on the newly arrived NFC waveform data on the basis of the existing federated learning model parameters. For fingerprint feature drift caused by channel changes or hardware device aging, the method of this patent can continuously iterate through the model to adapt to the changes in updated data features.
[0158] Those skilled in the art can understand that the above are only preferred examples of the invention and are not intended to limit the invention. Although the invention is described in detail with reference to the above examples, those skilled in the art can still modify the technical solutions recorded in the above examples or replace some of the technical features with equivalents. Any modification, equivalent replacement, etc. made within the spirit and principle of the invention should be included in the protection scope of the invention. All technical features in this embodiment can be freely combined according to actual needs.
[0159] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for detecting NFC relay attacks based on federated learning. Features: The specific steps include: Step 1, select the NFC reader device: a universal reader based on NXP's NFC chip; select the NFC tag that has been authenticated as legal; the device used to simulate the NFC relay attack as the illegal NFC tag; assign a classification label to each NFC tag; record the NFC reader instance ID; and proceed to step 2; Step 2: On each NFC reader side, the original NFC signal and the relayed NFC signal data generated by the interaction between the NFC tag and the NFC reader are recorded and collected. After data collection, data frame analysis, data clipping, and data cleaning, only the NFC tag's reply to the reader instruction is saved; Direction: NFC tag → NFC reader; ATQA command signal waveform, generate NFCATQA waveform data set, and then go to step 3; Step 3: Build a deep convolutional neural network model for signal recognition and classification and distinguishing between legitimate and relay NFC signals; use this model as the network structure to be trained in the federated learning framework; build a federated learning training system and proceed to step 4; Step 4: Use the client-server architecture to build a horizontal federated learning training system; select several NFC reader terminals as the participating clients of federated learning; select a central server node to play the role of orchestration, which receives the model parameters sent by each participating client, performs central aggregation, and sends the parameters of the new round of aggregation model; Each node in the federated learning system implements distributed point-to-point communication; Step 5: With the NFC waveform dataset generated and held by the client of the participant as input and the category label to which the data sample is classified as output, each client node of the participant jointly trains a federated model for detecting and identifying NFC relay attacks in a federated learning manner under the arrangement of the central server based on the adopted model structure and initial state, the data sample on the client side, the true value of the label, and the considered evaluation index; and runs the federated learning training until the iteration target is reached; Step 6: The client side of the participant saves two copies of model parameters: a model for continuous federated training and a model for inference. The end side uses the federated training model to participate in the continuous iteration of the federated model. Until the next update of the inference model parameters, the end side uses the federated model that meets the iteration target as the inference model, that is, the model used to detect and identify NFC relay attacks. Step 7: When an NFC interaction occurs, the terminal device relies on its own computing power to pre-process the transmitted NFC signal in real time, and inputs the inference model to obtain the classification and identification result of the signal, and then detects and identifies the NFC relay attack based on the preset judgment logic; when it is identified as an NFC relay attack, the NFC reader terminal terminates the NFC communication to defend against the NFC relay attack.
2. According to the method for detecting NFC relay attacks based on federated learning in claim 1, Features: In step 2, specifically, the NFC signal data is saved in a WAV file format; NFC data frame analysis is based on the data frame representation specified by the ISO-14443A protocol. Real-time analysis of NFC data frames is performed in both the NFC tag-NFC reader and NFC tag-NFC reader directions. However, the waveform of the signal replied by the NFC tag in the NFC tag-NFC reader direction is retained as the data sample.
3. According to the NFC relay attack detection method based on federated learning according to claim 1, Features: NFC Type A data frame parsing performs symbol matching based on signal cross-correlation values to complete real-time data frame parsing.
4. According to the method for detecting NFC relay attacks based on federated learning in claim 1, Features: Assign the label of the data sample to the label of the corresponding NFC card; save the data sample separately according to the ID of each NFC reader and realize a one-to-one mapping from a certain reader ID to the data set generated at the corresponding reader.
5. According to the method for detecting NFC relay attacks based on federated learning in claim 1, Features: Described step 2 specifically comprises the following steps: Step 2.1, place the NFC tag within the working magnetic field of the NFC reader; start the recording and NFC decoding program; power on the NFC reader; record the NFC signal of the interaction between the reader and the tag for a period of time; Step 2.2, based on the data frame analysis results and NFC protocol knowledge, the data processing and cropping program locates the sampling points of the start and end positions of the ATQA instructions in all recorded files for the data frame types and frame contents before and after any data frame, accurately captures the ATQA segment waveform and writes it into a WAV file; the classification label of the data sample is the label of the NFC tag; The input of the data decoding and cropping program is the original digital signal output by the AirSpy SDR hardware device. The signal is converted into a wav format file corresponding to all the original digital signals and a json file corresponding to its decoding and parsing results based on signal cross-correlation and knowledge of the ISO / IEC 14443 protocol specification that NFC Type A complies with by the data parsing program written in C++. The content includes all the signals sent by the NFC reader and NFC tag. The correlation value calculation method of the signal is: Among them, the interval [n 1 ,n 2 ]The internal correlation value C(x,y) is a real number independent of n; By calculating the original signal and the reference signal S 0 , S 1 The calculated correlation values and their magnitude relationships can be mapped to corresponding symbol patterns and logic 1 or logic 0. The correlation value calculation formula is: in x(t) is the original baseband signal; The data clipping program uses Python to first read the decoding result of the NFC data frame in json, and based on the numpy library, intercepts and retains the waveform of the ATQA command signal determined by the start and end sampling points from the original wav according to the decoding result as the data sample; Step 2.3, similar to steps 2.1 to 2.2, collect waveform samples under different channel conditions at multiple readers located in multiple scenes; after verifying the correctness of the data samples, use them as a local data set unique to the NFC reader terminal at that location and form a one-to-one mapping from each reader ID to its private local data set.
6. According to the method for detecting NFC relay attacks based on federated learning in claim 1, Features: In step 3, the proposed convolutional neural network structure, specifically, is a CNN containing 3 convolutional layers, each convolutional layer is followed by a ReLu activation function, and the activation function of the third convolutional layer is followed by a Flatten layer and a Dense layer.
7. According to the method for detecting NFC relay attacks based on federated learning in claim 1, Features: The relevant model evaluation indicators are accuracy, precision, recall rate and F1 score. In the evaluation of the federated model, the average accuracy of the model accuracy of the last 5 rounds of training for a certain number of rounds is used as the main evaluation indicator; wherein, the certain number of rounds is 250 rounds.
8. According to the method for detecting NFC relay attacks based on federated learning in claim 1, Features: In step 5, lossy compression-based quantization is introduced during federated learning training to quantize the original data represented by the 32-bit single-precision floating-point data type tf.float32 into an 8-bit integer value, reducing the amount of data uploaded by the client to the server.
9. According to the method for detecting NFC relay attacks based on federated learning in claim 1, Features: In step 5, the goal of the federated optimization problem is to find the model parameter w that minimizes the loss function of the entire dataset: Among them, the loss function is: For n data samples, each sample (x i ,y i ), for the model weight parameter w, the expected loss from running the model inference; For each round of federated learning with K participants, D k represents the local data set held by the kth participant, the above formula can be written as: Among them, F k (w) is the average loss of all k samples on one participant’s side; The federated learning training system runs the federated average algorithm, and one complete iteration is called a round. A round of federated learning iteration includes the following steps 5.1 to 5.4: Step 5.1: Federated learning initialization: the central server node first sends a shared initial model state w to each participating client. 0 ; In specific implementation, w 0 The parameters of the imported pre-trained model; Step 5.2: In any round t, select K participating NFC terminals participating in the current round of federated training based on their local data and the current round t starting model state w t Compute local gradients: In practical applications, whether a participant participates in the current round of federated training iteration depends on whether it is in a stable activity state; Step 5.3, in the central aggregation phase, the central server calculates and aggregates the model parameters and performs model updates: in, The model sharing weight w issued by the central server in the round is used by the participant k in the tth round t The model weight parameters are updated after local iteration; the parameters are combined into a weighted average, where the weight is the ratio of the data samples at each participant's client to the total number of data samples of all global participants, so that clients with larger data volumes have greater influence in model iteration; For data quantization, consider a distributed average estimation problem, that is, the average of several vectors To estimate, Represents the maximum and minimum values of all coordinates of each d-dimensional vector. The proposed random uniform quantization method assigns the quantized value of each coordinate as follows: Among them, the quantization level And we can make; E(Y i (j)) = X i (j) thereby achieving The estimate and bring The mean square error of Step 5.4, the central server node sends w t+1 ; Through the federated learning model training running in a cyclic manner and the federated averaging algorithm, federated learning achieves model training and iteration without directly accessing the data and taking into account data security and privacy.
10. A system based on the NFC relay attack detection and identification method based on federated learning according to any one of claims 1 to 9, Features: It includes NFC waveform data acquisition and processing module, horizontal federated learning module, model inference module and NFC relay attack detection and alarm module; The data generation and processing module is used to generate and persist data sets, and supports adding new data generated by the system during continuous operation to the global data to incrementally expand the data set; The horizontal federated learning module is used in the federated learning system with client-server architecture. With the help of the federated learning framework, the federated model training based on the deep convolutional neural network structure is carried out based on the local data set of the NFC reader terminal of each participant, the selected loss function and the iteration target; The model inference module is used to run the model inference under the parameter state based on the model parameters persisted on the terminal side, and output the results of NFC relay attack detection and identification for the current communication in real time; The detection and alarm module is used to interact with the user through the platform interface or mobile phone App interface based on the output of the model inference module during each NFC interaction; when an NFC relay attack is detected, the current communication is terminated and the alarm information is pushed to the user interface; the user interface can choose to provide feedback, or choose to take over the detection and identification system for manual authentication.
