Automating Patching of Vulnerable Open-Source Software Versions in Application Binaries

Ruian Duan, Ashish Bijlani, Yang Ji, Omar Alrawi, Yiyuan Xiong, Moses Ike, Brendan Saltaformaggio, Wenke Lee

Abstract

Security vulnerabilities in open-source software (OSS) libraries pose a significant risk to mobile applications, as developers often fail to update libraries promptly. This paper presents OSSPATCHER, a system that automatically backports source-code fixes into compiled application binaries. By leveraging variability-aware analysis and configuration inference, OSSPATCHER identifies vulnerable functions in stripped binaries and applies in-memory patches with high precision and negligible overhead. Evaluation on 1,140 real-world patches and 1,000 Android applications demonstrates its effectiveness in mitigating "n-day" exploits like Heartbleed and Stagefright.

Introduction

Modern mobile applications extensively utilize C/C++ OSS libraries for critical functionality. However, a "security gap" persists between the release of a library patch and its adoption by app developers. This delay leaves users vulnerable to known exploits. Patching these binaries is challenging due to build-time variability (e.g., #ifdef macros), static linking, and the absence of debug symbols in production binaries. OSSPATCHER addresses these challenges by transforming source-code patches into binary fixes that can be injected at runtime.

System Architecture

OSSPATCHER employs a multi-stage pipeline to automate the patching process, consisting of a Collector, Analyzer, Matcher, and Patcher.

OSSPATCHER System Architecture
  • Analyzer: Conducts feasibility analysis to ensure patches are localized within function boundaries. It utilizes tools like TypeChef to generate a Variability-aware Abstract Syntax Tree (VAST), mapping code blocks to specific compile-time configurations.
  • Matcher: Locates vulnerable functions within the target binary. It treats configuration inference as a constraint-solving problem, using symbolic execution and SMT solvers to match the binary's characteristics against the source-level variability.
  • Patcher: Implements a detour-based "hot-patching" mechanism. A background daemon injects a patch library into the application's memory space and redirects calls from the vulnerable function to the patched version using a trampoline.

Configuration Inference and Matching

A key innovation in OSSPATCHER is the treatment of build configurations as logical puzzles. Since binaries are often stripped of symbols, the system relies on observable artifacts like unique strings or constants to infer which macros were defined during compilation.

Configuration Inference as a Logic Puzzle

By mapping these artifacts to the VAST, OSSPATCHER can determine the exact variant of a library present in a binary, achieving 95% precision in matching. This allows the system to generate "stub" libraries that correctly link to internal, non-exported functions within the original binary without needing to relocate the entire program.

Evaluation and Results

The system was evaluated against 39 major OSS libraries (e.g., OpenSSL, FFmpeg) and 1,140 patches from the National Vulnerability Database.

  • Feasibility: 675 out of 1,140 patches were found suitable for automated application, including 29 out of 31 vulnerable OpenSSL versions.
  • Performance: The patching process adds less than 350ms to application startup and requires minimal memory (<80KB), making it imperceptible to users.
  • Security Impact: OSSPATCHER successfully blocked exploits for Heartbleed and Stagefright in popular apps like Chrome and Hangouts.

Conclusion and Future Work

OSSPATCHER provides a scalable solution for closing the security gap in mobile applications. While currently focused on C code and requiring root access for memory injection, the system demonstrates that automated binary patching is a viable and efficient defense against library-level vulnerabilities. Future work aims to extend support to C++ and explore non-root deployment methods.

Summary updated

BibTeX
@inproceedings{duan2019automating,
  author = {Ruian Duan and Ashish Bijlani and Yang Ji and Omar Alrawi and Yiyuan Xiong and Moses Ike and Brendan Saltaformaggio and Wenke Lee},
  title = {{Automating Patching of Vulnerable Open-Source Software Versions in Application Binaries}},
  booktitle = {NDSS},
  year = {2019},
}
Figure