Author Login Chief Editor Login Reviewer Login Editor Login Remote Office

Computer Engineering

   

mportance-Aware Local Adversarial Contrastive Learning for Malware Detection

  

  • Published:2026-11-09

基于重要性感知的局部对抗对比学习恶意软件检测

Abstract: To address the limited classification performance and generalization capability of existing malware detection methods based on application programming interface (API) call sequences, this study proposes Mamba2+LAT-CL, a malware detection model that integrates importance-aware local adversarial training with contrastive learning. First, API call sequences are mapped into a continuous embedding space. A Mamba2 encoder models long-range dependencies, and masked mean pooling aggregates information from valid call positions to extract sample-level malware behavioral features. Second, adversarial training is introduced in the embedding space to improve detection performance. The gradient norm of the original-view classification loss with respect to the input embeddings is used to dynamically assess the importance of each API call position to the current classification decision. Highly influential positions are selected for local perturbation to construct locally perturbed views, making adversarial regularization more targeted. Next, the original and locally perturbed views of the same sample form a positive pair. An encoder and a projection head, with parameters shared across the two views, produce contrastive representations. The normalized temperature-scaled cross-entropy (NT-Xent) loss is introduced to encourage consistency between the two representations in the projection space. Finally, the original-view classification loss, locally perturbed-view classification loss, and contrastive loss are jointly optimized to enhance class discrimination and feature representation stability. During inference, only the embedding layer, encoder, feature aggregation module, and classification head are retained; perturbation generation and the contrastive learning branch are not required. Experimental results show that the proposed model achieves accuracies of 98.06% and 68.07% and F1 scores of 98.49% and 68.69% on the public Aliyun and Mal-API-2019 datasets, respectively, outperforming the comparison methods on both metrics. Its F1 scores exceed those of the best-performing comparison method on each dataset by 0.91 and 1.78 percentage points, respectively. Under embedding-space projected gradient descent attacks on Aliyun, the model maintains an F1 score of 91.01% at a sample-level Frobenius-norm perturbation budget of 5, substantially higher than the baseline Mamba2 score of 31.88%. In cross-dataset testing from Aliyun to MalBehavD-V1, the model achieves an accuracy of 76.50% and an F1 score of 71.49%, outperforming all comparison methods on both metrics. These results demonstrate the effectiveness of the proposed method for malware detection.

摘要: 针对现有基于应用程序接口(API)调用序列的恶意软件检测方法分类性能和泛化能力有限的问题,提出一种融合重要性感知局部对抗训练与对比学习的恶意软件检测模型Mamba2+LAT-CL。首先,将API调用序列映射至连续嵌入空间,引入Mamba2编码器建模长距离依赖关系,并通过掩码均值池化聚合有效调用位置的信息,提取样本级恶意软件行为特征;其次,为提升模型的检测性能,引入嵌入空间对抗训练,利用原始视图分类损失关于输入嵌入的梯度范数,动态评估不同API调用位置对当前分类决策的重要程度,筛选高重要性位置施加局部扰动,构造局部扰动视图,增强对抗正则化的针对性;随后,将同一样本的原始视图与局部扰动视图构造成正样本对,通过参数共享的编码器和投影头获得对比表示,引入归一化温度缩放交叉熵(NT-Xent)对比损失约束两种视图在投影空间中的表示一致性;最后,联合优化原始视图分类损失、局部扰动视图分类损失和对比损失,以增强模型的类别判别能力和特征表示稳定性。推理阶段仅保留嵌入层、编码器、特征聚合模块和分类头,无需执行扰动生成和对比学习分支。实验结果表明,该模型在Aliyun和Mal-API-2019两个公开数据集上的Accuracy分别达到98.06%和68.07%,F1-score分别达到98.49%和68.69%,均优于对比方法,相较各数据集上F1-score最高的对比方法,分别提高0.91和1.78个百分点。在Aliyun嵌入空间投影梯度下降攻击评估中,当样本级Frobenius范数扰动预算为5时,模型的F1-score仍达到91.01%,明显高于基础Mamba2的31.88%。在Aliyun到MalBehavD-V1的跨数据集测试中,模型的Accuracy和F1-score分别达到76.50%和71.49%,均优于所比较方法。上述实验结果验证了所提方法在恶意软件检测任务中的有效性。