# Survey on 5G Physical Layer Security Threats and Countermeasures
## 6 Machine Learning for Enhancing PHY Layer Security
### Autoencoders  
From the point of view of deep-learning, tamper detection in LTE and 5G networks can be treated as an anomaly detection task. An anomaly detection task identifies unusual patterns or outliers in data that deviate from the norm. To our knowledge, only a limited number of recent papers have been published, so this section will review potential deep-learning architectures for anomaly detection and, if applicable, survey the recent works. The main goal of an autoencoder is to learn a latent space representation (encoding) for a data set. The general architecture is depicted in Figure 13. The input data, **X**, are passed to the _Encoder_ network that compresses the input into smaller and meaningful representations called the _latent space representation_, **Z**. The _Decoder_ network reconstructs the latent space representation to produce output **X** as similar as possible to the input [140]. Based on the specific application, the autoencoders can be built using the appropriate building blocks described in the previous chapter (i.e., CNNs, LSTM, Transformers,...).  
From the point of view of the anomaly detection task, in the learning stage, only the tamper-free data are passed to the input and output of the model to learn the high-level representation of the data. In the testing stage, both tamper and tamper-free data are passed to the model, while the reconstruction error \(\textbf{E}(\textbf{X},\textbf{\hat{X}})\) is measured. When the reconstruction error exceeds a certain defined threshold, the data are considered to be tampered with.  
A similar approach was used in [141], where the Deep-Convolutional Autoencoder (DCAE) was adopted for physical tamper attack detection and tested in indoor scenarios on custom OFDM signals. Starting from simple thresholding of the reconstruction error as the  
Figure 12: The vanilla Transformer architecture from [136]. The fundamental building blocks are the _Input Embeddings_, _Positional Encoding_, _Encoder_ (green block), and _Decoder_ (purple block). The orange blocks represent the Multi-head self attention (MSA) modules, the yellow blocks are the additions of residual connections and normalization layers, and the blue blocks are the feed forward neural networks.  
Figure 13: General autoencoder architecture.  
metric to judge the presence of anomalies, the method has been improved by considering the Probability Density Function (PDF) estimation of the reconstruction error. Its further extension towards multi-antenna configuration, in either a centralized or decentralized manner, has then been proposed in [142].  
Although, in the above, the applications of autoencoders focused on tamper attack detection have been discussed, the autoencoder approach can also be adopted for transmitter classification [143], profiting from denoising autoencoder properties to mitigate noise interference and then improve its robustness under low SNR conditions. Again, in this paper, as well as in its predecessor [144], the principle has been evaluated on WiFi or ZigBee devices. The application to 4G device classification, among the authorized and rogue ones, has been shown in [145] on the transient part of the LTE PRACH signal with a two-dimensional wavelet coefficients graph. The autoencoder, more specifically the autoencoder with Bahdanau attention [146], has been proposed in [147] to allow physical layer authentication in highly dynamic environments, i.e., in the presence of moving users or fast-changing nearby objects. The proposed method relies on a model-based approach to predict the CSI. The decision is then based on the Mean Square Error (MSE) between the measured and predicted CSI. The use of the deep autoencoder to secure 5G-IoT devices is then proposed in [148].