Exposing Resource-Exhaustion DoS Vulnerabilities with LMPC
Abstract
LeakHunter This is the repository for the LeakHunter tool, a novel Java resource leak detector that leverages LLMs and LMPC algorithm. Abstract Resource leaks—failures to properly release scarce GC-unmanaged resources such as file descriptors, sockets, and database connections—are a pervasive root cause of resource-exhaustion DoS risks in Java programs. Prior approaches typically enumerate execution paths to identify resources that are not properly released. However, exceptions can trigger non-local control transfers that bypass resource releases, and exhaustive path enumeration may trigger path explosion, significantly reducing the practicality of existing methods. To adress this, we propose LeakHunter, a novel Java resource leak detector. Please read our paper for details. Repository Structure We have uploaded both the source code and dataset used in our experiments. The detailed information is listed below. LeakHunter/├── src/ # Source code directory│ ├── llm4leak.py # Main leak detection logic using LLM and MPC│ ├── mpc.py # Minimum Path Cover (MPC) algorithm implementation│ ├── cfg2.py # Control Flow Graph (CFG) construction│ ├── cfgGraph.py # CFG analysis and pruning│ ├── llms.py # LLM interface wrappers│ ├── prompts.py # Prompt templates for LLM queries│ ├── intention.py # Resource operation intention definitions│ ├── scan_jleaks_mpc.py # Scan JLeaks benchmark dataset│ ├── scan_droidleaks_mpc.py # Scan DroidLeaks benchmark dataset│ └── scan_apps.py # Scan real-world GitHub applications├── dataset/ # Datasets directory│ ├── JLeaks/ # JLeaks benchmark dataset│ │ └── JLeaksDataset/ # Bug and fix method pairs│ │ ├── JLeaks.xlsx # Dataset entries│ │ ├── bug_method_refinement/ # Buggy method files│ │ └── fix_method_refinement/ # Fixed method files│ ├── DroidLeaks/ # DroidLeaks benchmark dataset│ │ ├── DroidLeaks-refined.csv # Dataset entries│ │ └── files/ # Source code files├── requirements.txt # Python dependencies└── README.md # This file Primary Code Structure The main modules of LeakHunter are organized as follows: src/llm4leak.py: Core detection engine that orchestrates LLM-based analysis and MPC-based path enumeration src/mpc.py: Implements the Leak-oriented Minimum Path Cover (LMPC) algorithm for efficient path selection src/cfg2.py: Constructs iCFG from Java method code src/cfgGraph.py: Analyzes iCFG, handles exception flows, and performs graph pruning src/llms.py: Provides unified interface for different LLM providers (OpenAI, Anthropic, etc.) src/prompts.py: Contains prompt templates for LLM queries to extract resource operations src/intention.py: Defines resource operation types (acquire, release, validate, throw) For more details, please refer to the provided source code. Dataset The repository includes the following datasets used in our evaluation: JLeaks: Contains 1,089 bug-fix method pairs from real-world Java projects, covering various resource types (InputStream, OutputStream, Cursor, Socket, etc.) DroidLeaks: Contains Android-specific resource leak cases from DroidLeaks dataset Detailed Workflow Setup Environment: Install dependencies from requirements.txt. Configure LLM API keys in src/llms.py (OpenAI). Run Evaluation on Benchmarks: For JLeaks dataset: Run python src/scan_jleaks_mpc.py For DroidLeaks dataset: Run python src/scan_droidleaks_mpc.py For real-world applications: Run python src/scan_apps.py These scripts will: Load dataset entries For each method, use LLM to extract resource operations (acquire, release, validate, exceptions) Build CFG and perform graph analysis Apply MPC algorithm to generate minimal path cover Detect resource leaks along paths Output detection results and metrics View Results: Detection results are logged to timestamped log files in the src/ directory. CFG visualizations (if enabled) are saved to src/cfg_output/ directory.
Fields of Study & Subjects
Software Testing and Debugging Techniques
Software Engineering Research
Software System Performance and Reliability
Publication details
- Journal / source
- Zenodo (CERN European Organization for Nuclear Research)
- Publication date
- 30 January 2026