[Paper Review] Learning to Repair Software Vulnerabilities with Generative Adversarial Networks
This paper proposes a GAN-based approach for automated repair of software vulnerabilities without requiring paired training data, using a conditional NMT generator with novel loss functions to enforce accurate code repair. The method achieves performance close to supervised seq2seq models on code repair benchmarks, even with unpaired data, demonstrating strong generalization and applicability to other sequence correction tasks.
Motivated by the problem of automated repair of software vulnerabilities, we propose an adversarial learning approach that maps from one discrete source domain to another target domain without requiring paired labeled examples or source and target domains to be bijections. We demonstrate that the proposed adversarial learning approach is an effective technique for repairing software vulnerabilities, performing close to seq2seq approaches that require labeled pairs. The proposed Generative Adversarial Network approach is application-agnostic in that it can be applied to other problems similar to code repair, such as grammar correction or sentiment translation.
Motivation & Objective
- To address the challenge of automated software vulnerability repair in the absence of paired training data.
- To develop a method that maps vulnerable code to secure code without requiring one-to-one labeled examples.
- To enable application-agnostic sequence correction, such as grammar correction or sentiment translation, using adversarial learning.
- To overcome the non-differentiability of discrete outputs in GANs during training on code sequences.
- To ensure generated repairs are semantically and syntactically valid by enforcing conditioning on input code via novel loss functions.
Proposed method
- A conditional NMT generator is used as the generator in a GAN, trained with adversarial loss instead of standard negative likelihood.
- The discriminator is trained to distinguish between real repaired code and generated repairs, providing a proxy loss for distribution matching.
- A soft-label discriminator operates on expected (non-sampled) outputs to handle the non-differentiable nature of discrete code generation.
- Two novel generator loss functions, $\mathcal{L}_{\textit{AUTO}}$ and $\mathcal{L}_{\textit{FREQ}}$, are introduced to enforce fidelity to input code and improve repair quality.
- Curriculum learning is applied to gradually increase training difficulty, improving convergence and performance.
- The approach is evaluated on a code repair dataset with both paired and unpaired data, using BLEU-4, sequence accuracy, and correctness metrics.
Experimental results
Research questions
- RQ1Can a GAN-based approach effectively learn to repair software vulnerabilities without paired training examples?
- RQ2How well can adversarial training with a soft-label discriminator generalize to discrete code sequences despite non-differentiability?
- RQ3To what extent do the proposed generator loss functions improve repair accuracy and fidelity to input code?
- RQ4How does performance on unpaired data compare to supervised seq2seq baselines in code repair?
- RQ5Can the method be generalized to other sequence correction tasks beyond software repair?
Key findings
- The proposed GAN model with curriculum learning and $\mathcal{L}_{\text{FREQ}}$ regularization achieved a BLEU-4 score of 90.3 on the unpaired test set, approaching the seq2seq baseline of 91.3.
- The Base + Cur + Freq model achieved 98.2% sequence accuracy and 99.1% order accuracy, demonstrating high repair fidelity.
- Even with only half the training data and no paired examples, the unpaired GAN model achieved 81.3% BLEU-4 on the test set, showing strong generalization.
- The model successfully repaired real-world vulnerabilities, such as incorrect argument counts in function calls and double-free errors, as shown in Table 2.
- The method outperformed baseline GANs and achieved performance close to supervised seq2seq models, validating its effectiveness in low-data, unpaired settings.
- The approach is applicable beyond code repair, including grammatical error correction and sentiment translation, due to its application-agnostic design.
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.