Network-security situation prediction is a crucial aspect in the field of network security. It is primarily achieved through monitoring network behavior and identifying potential threats to prevent and respond to network attacks. In order to enhance the accuracy of situation prediction, this paper proposes a method that combines a convolutional neural network (CNN) and a gated recurrent unit (GRU), while also incorporating an attention mechanism. The model can simultaneously handle the spatial and temporal features of network behavior and optimize the weight allocation of features through the attention mechanism. Firstly, the CNN’s powerful feature extraction ability is utilized to extract the spatial features of the network behavior. Secondly, time-series features of network behavior are processed through the GRU layer. Finally, to enhance the model’s performance further, we introduce attention mechanisms, which can dynamically adjust the importance of different features based on the current context information; this enables the model to focus more on critical information for accurate predictions. The experimental results show that the network-security situation prediction method, which combines a CNN and a GRU and introduces an attention mechanism, performs well in terms of the fitting effect and can effectively enhance the accuracy of situation prediction.