There are More Fish in the Sea: Automated Vulnerability Repair via Binary Templates

Bo Lin, Shangwen Wang, Liqian Chen, Xiaoguang MaoarXiv 2024 · DOI

Abstract

Automated Vulnerability Repair (AVR) has traditionally focused on source code, a paradigm that faces significant hurdles when source code is unavailable or when the "compile-and-test" loop becomes a bottleneck. We present TemVUR, the first tool designed to repair Java vulnerabilities directly at the bytecode level. By utilizing a suite of 33 repair templates, TemVUR bypasses the need for source access and avoids time-consuming compilation. Our evaluation on the Vul4J benchmark and a newly curated dataset, ManyVuls4J, demonstrates that TemVUR not only fixes 57% more vulnerabilities than state-of-the-art source-level tools but also operates nearly ten times faster, averaging just 61.5 seconds per repair.

Introduction

The current landscape of Automated Program Repair (APR) is heavily skewed toward source-level modifications. While effective in open-source environments, this approach fails in scenarios where security analysts only have access to compiled binaries (e.g., proprietary or obfuscated software). Furthermore, source-level repair is notoriously inefficient; in large-scale systems, the compilation phase can account for over 90% of the total repair time.

To address these challenges, we propose a binary-level repair approach. By operating directly on Java .class files, we can eliminate the compilation overhead and provide a "shield" for vulnerabilities even when the original source code is out of reach.

The TemVUR Workflow

TemVUR implements a template-based repair strategy optimized for Java bytecode. The process is divided into four distinct stages:

  1. Fault Localization: Using spectrum-based localization (specifically the Ochiai metric), TemVUR identifies suspicious bytecode instructions by analyzing execution traces of passing and failing tests.
  2. Template Selection: We curated a library of 33 templates, including 13 vulnerability-specific fixes (e.g., adding null-pointer checks or replacing insecure object instantiations) and 20 general-purpose repair patterns.
  3. Patch Generation: Using the ASM bytecode manipulation framework, TemVUR applies selected templates to the "suspicious" locations in the binary to generate candidate patches.
  4. Patch Validation: Candidates are validated against the project's test suite. A patch is considered "plausible" if it passes all original tests plus the specific "Proof of Vulnerability" (PoV) test case.
The four-stage workflow of TemVUR for binary-level vulnerability repair.

Evaluation and Datasets

We evaluated TemVUR using two benchmarks: Vul4J, a standard set of 79 reproducible Java vulnerabilities, and ManyVuls4J, a new dataset we curated to include 23 additional vulnerabilities across 11 diverse projects. This expansion ensures a more rigorous test of the tool's generalizability across different software architectures and CWE types.

Results and Key Insights

TemVUR significantly outperforms existing source-level tools in both effectiveness and efficiency. On the Vul4J benchmark, TemVUR correctly fixed 11 vulnerabilities, representing a 57.1% improvement over the previous state-of-the-art.

The "Security-Fixing" Paradigm

A key contribution of this work is the distinction between a "Correct" patch and a "Security-Fixing" patch. While a correct patch is semantically identical to a human developer's fix, a security-fixing patch successfully neutralizes the vulnerability even if it differs architecturally. For security practitioners, a security-fixing patch provides an immediate, functional defense. TemVUR generated 15 such patches on Vul4J, a 66.7% improvement over prior methods.

Repair results across various projects, highlighting plausible, security-fixing, and correct patches.

Performance Gains

The most striking result is the speedup. By skipping the compilation phase, TemVUR reduces the average repair time from nearly 10 minutes (581.8 seconds for the tool TBar) to just over one minute (61.5 seconds). This order-of-magnitude improvement makes automated repair feasible for large-scale, rapid-response security scenarios.

Conclusion and Future Work

TemVUR demonstrates that binary-level repair is not only viable but superior to source-level repair in speed and accessibility. While current limitations include the difficulty of searching for "donor code" in binaries and the potential for "shallow" fixes that only address symptoms, the results are promising. Future research will explore ensemble methods that combine the speed of binary manipulation with the rich semantic context of source code where available.

Summary updated

BibTeX
@misc{lin2024there,
  author = {Bo Lin and Shangwen Wang and Liqian Chen and Xiaoguang Mao},
  title = {{There are More Fish in the Sea: Automated Vulnerability Repair via Binary Templates}},
  year = {2024},
  eprint = {2411.18088},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.18088},
}
Figure