Abstract
The identification of malicious actions using traffic analysis is one of the key challenges in current cybersecurity practices. There are two existing approaches for solving this problem; the first utilizes machine learning algorithms on unprocessed data, while the second focuses on the reconstruction of traffic using autoencoders, which ignore subtle cues. In this research work, we present an algorithm where informative representations of network traffic are learned automatically. The main component of our algorithm is a Siamese Bidirectional LSTM network with an attention mechanism. While most solutions learn from raw tabular data, our model learns from sequence data, encoding network traffic in sequences of feature tokens. Therefore, it is possible to discover bidirectional sequential dependencies in structured data. The network learns using a metric learning loss function, where normal traffic samples are tightly packed together, while malicious samples are pushed further away. Anomalies are detected based on their distance to the normal traffic sample cluster using the Mahalanobis distance. We experiment with the NSL-KDD dataset, where our model attains an F1-score of 0.9007 and ROC-AUC of 0.9550, outperforming not only the Mahalanobis distance baseline but also an autoencoder-based anomaly detector. Moreover, compared to existing solutions, the proposed approach provides higher accuracy, improved interpretability, and high applicability in practice.