A Context-Aware Neural Embedding for Function-Level Vulnerability Detection
Hongwei Wei, Guanjun Lin, Lin Li et al. · Algorithms · 2021
Exploitable vulnerabilities in software systems are major security concerns. To date, machine learning (ML) based solutions have been proposed to automate and accelerate the detection of vulnerabilities. Most ML techniques aim to isolate a unit of source code, be it a line or a function, as being vulnerable. We argue that a code segment is vulnerable if it exists in certain semantic contexts, such as the control flow and data flow; therefore, it is important for the detection to be context aware. In this paper, we evaluate the performance of mainstream word embedding techniques in the scenario of software vulnerability detection. Based on the evaluation, we propose a supervised framework leveraging pre-trained context-aware embeddings from language models (ELMo) to capture deep contextual representations, further summarized by a bidirectional long short-term memory (Bi-LSTM) layer for learning long-range code dependency. The framework takes directly a source code function as an input and produces corresponding function embeddings, which can be treated as feature sets for conventional ML classifiers. Experimental results showed that the proposed framework yielded the best performance in its downstream detection tasks. Using the feature representations generated by our framework, random forest and support vector machine outperformed four baseline systems on our data sets, demonstrating that the framework incorporated with ELMo can effectively capture the vulnerable data flow patterns and facilitate the vulnerability detection task.
Cited by 15 works. doi:10.3390/a14110335 Open-access PDF
Authors
References
- Scikit-learn: Machine Learning in Python
- Glove: Global Vectors for Word Representation
- Distributed Representations of Words and Phrases and their Compositionality
- Deep Contextualized Word Representations
- Enriching Word Vectors with Subword Information
- context2vec: Learning Generic Context Embedding with Bidirectional LSTM
- Software Framework for Topic Modelling with Large Corpora
- CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- AllenNLP: A Deep Semantic Natural Language Processing Platform
- One billion word benchmark for measuring progress in statistical language modeling