Do Language Models Learn Semantics of Code? A Case Study in Vulnerability Detection
Benjamin Steenhoek, Md Mahbubur Rahman, Shaila Sharmin, and Wei Le

TL;DR
This study investigates whether pretrained language models for vulnerability detection understand code semantics related to bugs, revealing their limitations and proposing annotation methods that improve model performance and semantic alignment.
Contribution
The paper introduces annotation techniques that highlight bug semantics in code inputs, enhancing model performance and semantic understanding in vulnerability detection tasks.
Findings
Better-performing models align more with potentially vulnerable statements
Models generally fail to align with buggy paths
Annotations improve model performance and semantic alignment significantly
Abstract
Recently, pretrained language models have shown state-of-the-art performance on the vulnerability detection task. These models are pretrained on a large corpus of source code, then fine-tuned on a smaller supervised vulnerability dataset. Due to the different training objectives and the performance of the models, it is interesting to consider whether the models have learned the semantics of code relevant to vulnerability detection, namely bug semantics, and if so, how the alignment to bug semantics relates to model performance. In this paper, we analyze the models using three distinct methods: interpretability tools, attention analysis, and interaction matrix analysis. We compare the models' influential feature sets with the bug semantic features which define the causes of bugs, including buggy paths and Potentially Vulnerable Statements (PVS). We find that (1) better-performing models…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Engineering Research · Web Application Security Vulnerabilities · Software Reliability and Analysis Research
MethodsALIGN
