[Paper Review] Towards security defect prediction with AI
This paper introduces s-bAbI, a synthetic dataset of syntactically valid C code with non-trivial control flow and line-level labels for buffer overflow defects. It evaluates a memory network AI model and static analysis tools on this dataset, finding that while the AI model achieves performance comparable to static analyzers, it requires an exhaustive amount of training data, highlighting the need for better code representations and arithmetic-aware deep learning architectures to improve security defect prediction.
In this study, we investigate the limits of the current state of the art AI system for detecting buffer overflows and compare it with current static analysis tools. To do so, we developed a code generator, s-bAbI, capable of producing an arbitrarily large number of code samples of controlled complexity. We found that the static analysis engines we examined have good precision, but poor recall on this dataset, except for a sound static analyzer that has good precision and recall. We found that the state of the art AI system, a memory network modeled after Choi et al. [1], can achieve similar performance to the static analysis engines, but requires an exhaustive amount of training data in order to do so. Our work points towards future approaches that may solve these problems; namely, using representations of code that can capture appropriate scope information and using deep learning methods that are able to perform arithmetic operations.
Motivation & Objective
- To investigate the limits of state-of-the-art AI systems in detecting buffer overflows in source code.
- To develop a synthetic code generator (s-bAbI) capable of producing large-scale, syntactically valid C programs with non-trivial control flow and labeled security defects.
- To compare the performance of AI models and static analysis tools on this new dataset in terms of precision and recall.
- To identify key deficiencies in current AI and static analysis approaches for security defect prediction.
- To guide future research by identifying necessary improvements in code representation and model architecture for robust defect detection.
Proposed method
- The authors created s-bAbI, a code generator that produces syntactically valid C programs with controlled complexity, including conditionals and loops.
- The dataset includes line-level labels for safe and unsafe buffer writes, enabling fine-grained defect detection evaluation.
- A memory network model, inspired by Choi et al. [1], was trained on the s-bAbI dataset to classify buffer write operations as safe or unsafe.
- The performance of the AI model was compared against multiple static analysis tools using standard metrics: precision and recall.
- The study used a minimal, controlled code complexity to isolate the impact of control flow and arithmetic reasoning on model performance.
- The authors evaluated model generalization by analyzing the data requirements for the AI system to achieve acceptable performance.
Experimental results
Research questions
- RQ1Can a state-of-the-art AI model, specifically a memory network, detect buffer overflows in synthetic C code with non-trivial control flow?
- RQ2How does the performance of the AI model compare to existing static analysis tools in terms of precision and recall on the s-bAbI dataset?
- RQ3What is the minimum amount of training data required for the AI model to achieve performance comparable to static analyzers?
- RQ4Can the AI model generalize across variations in control flow and arithmetic expressions, or does it rely on memorization of training examples?
- RQ5What architectural improvements are needed for AI models to effectively reason about scope and arithmetic in code for security defect detection?
Key findings
- The static analysis tools evaluated exhibited high precision but poor recall on the s-bAbI dataset, except for one sound analyzer that achieved both high precision and high recall.
- The state-of-the-art memory network AI model achieved performance comparable to static analysis tools but required an exhaustive amount of training data to do so.
- The AI model's performance suggests it may be relying on memorization of training examples rather than learning generalizable patterns for buffer overflow detection.
- The study indicates that current AI models struggle with reasoning about scope and arithmetic in code, which are essential for robust security defect detection.
- The results suggest that future AI models must incorporate better code representations—such as AST path encodings—and support for arithmetic operations to improve generalization.
- The s-bAbI dataset successfully exposes limitations in current AI and static analysis approaches, establishing a minimal benchmark for future research.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.