Multi-agent LLM framework that automatically repairs C/C++ vulnerabilities: localizes faults, generates patches, and validates them against sanitizer PoCs, tests, and security checks.
DeepAVR is a multi-agent framework for end-to-end automated vulnerability repair (AVR) of C/C++ programs. Starting from a sanitizer report and the project's source code, six LLM agents (fault localization, patch generation, compile validation, security validation, functionality validation and patch review) exchange structured feedback until a patch passes every check. When an intermediate patch changes the sanitizer bug type, DeepAVR keeps it and re-localizes on the patched program (patch-conditioned re-localization).
This repository contains the code for the paper DeepAVR: Deep Analysis via Multi-Agent Collaboration for Automated Vulnerability Repair.
| Benchmark | Targets | Backend used in the paper | Section |
|---|---|---|---|
| VulnLoc | 39 | gpt-4.1 | RQ1 |
| SAN2VULN (zero-day) | 25 | gpt-4.1 | RQ2 |
| SEC-bench | 200 | gpt-5-mini, DeepSeek-V4.1-Flash | RQ3 |
| CyberGym | C/C++ tasks | any | — |
docker without sudo)git clone https://github.com/rimwoohan/DeepAVR.git
cd DeepAVR
python3.10 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu126
Put your API keys in src/.env (loaded automatically) or export them in the shell:
# src/.env
OPENAI_API_KEY=sk-... # --llm-provider openai (gpt-4.1, gpt-5-mini)
DEEPSEEK_API_KEY=sk-... # --llm-provider deepseek (deepseek-flash)
All commands below are run from src/:
cd src
| Option | Default | Meaning |
|---|---|---|
--llm-provider {openai,deepseek,openrouter,ollama} | openai | LLM backend |
--llm-model NAME | gpt-4.1 for openai | model name, e.g. gpt-5-mini, deepseek-flash |
--loop-max N | 15 | iteration limit of the repair loop |
--index I / --start I --end J | all targets | which targets of the metadata file to run |
--model-config PATH | model_config.yaml | per-agent reasoning effort and prompt style |
src/model_config.yaml sets the per-agent reasoning
effort used for reasoning models (gpt-5-mini, deepseek-flash). It has no
effect on gpt-4.1. Models whose name contains mini or nano use the shorter
prompts in prompts_mini.py.
src/logs/<model>/: the full agent conversation for each target<container>_write: the Docker container that holds the final patched program,
left running after the target finishes--result-json FILE: writes a machine-readable result for each targetsrc/meta_s2p.yaml lists the 39 VulnLoc
vulnerabilities (entries 0–38) in the order of Table 2 of the paper. The benchmark images
(rimwoohan/san2patch-benchmark:v2, acorn421/san2patch-benchmark:latest) are
pulled automatically on first use. You can also pull them in advance:
docker pull rimwoohan/san2patch-benchmark:v2
docker pull acorn421/san2patch-benchmark:latest
# one vulnerability (CVE-2017-14745)
python main.py meta_s2p.yaml --index 0
# all 39 VulnLoc vulnerabilities, as in the paper
python main.py meta_s2p.yaml --start 0 --end 39 --llm-model gpt-4.1
For each target, DeepAVR runs the PoC under the sanitizer, then the functionality test suite when one is available.
src/meta_san2vuln.yaml lists the 27 SAN2VULN
vulnerabilities (entries 0–26), which use the same image as VulnLoc. The
paper evaluates 25 of them: entries 12 and 13 (liblouis CVE-2022-26981 and
CVE-2022-31783) are excluded because their fixes predate June 2024.
python main.py meta_san2vuln.yaml --start 0 --end 12 --llm-model gpt-4.1
python main.py meta_san2vuln.yaml --start 14 --end 27 --llm-model gpt-4.1
src/meta_secbench_cve200.yaml lists the
200-CVE evaluation split of SEC-bench.
Each target uses its SEC-bench image hwiwonlee/secb.eval.x86_64.<project>.<cve>:patch,
which is pulled automatically.
Scoring needs a SEC-bench checkout. Clone it next to src/ and install its
requirements into a separate environment:
cd .. # repository root
git clone https://github.com/SEC-bench/SEC-bench.git
python3.10 -m venv .venv-secb
.venv-secb/bin/pip install -r SEC-bench/requirements.txt -e SEC-bench
cd src
Run one target directly:
python main.py meta_secbench_cve200.yaml --index 0 \
--llm-provider deepseek --llm-model deepseek-flash
Run and score the whole split. run_secbench_batch.sh splits the targets
across parallel workers, exports each patch in SEC-bench's format and finally
scores everything with the SEC-bench evaluator:
# DeepSeek-V4.1-Flash
PROVIDER=deepseek MODEL=deepseek-flash WORKERS=8 \
SECB_PYTHON=../.venv-secb/bin/python ./run_secbench_batch.sh
# GPT-5-mini
PROVIDER=openai MODEL=gpt-5-mini WORKERS=8 \
SECB_PYTHON=../.venv-secb/bin/python ./run_secbench_batch.sh
| Variable | Default | Meaning |
|---|---|---|
WORKERS | 16 | parallel main.py processes |
TIMEOUT | 90m | wall-clock cap per target |
GPUS | 0 | comma-separated GPUs to spread workers over |
START, END | whole file | range of targets |
DRY=1 | off | print the plan without running anything |
SKIP_EVAL=1 | off | skip scoring at the end |
Results go to runs/<model>/<timestamp>/. To re-score a finished run:
SECB_PYTHON=../.venv-secb/bin/python ./run_secbench_eval.sh runs/deepseek-flash/<timestamp>
The paper reports the medium criterion (eval_output/report_medium.jsonl):
the patched program must run the PoC without a sanitizer error and exit with
code 0 or with the same code as the reference-patched program.
adapter/ runs DeepAVR as a patch-only agent on
CyberGym-E2E and scores its
patches with CyberGym's own validation. Only C/C++ tasks are supported.
Set up CyberGym-E2E next to this repository. The dataset is gated on
Hugging Face: request access to
sunblaze-ucb/cybergym-e2e
first, then:
git clone https://github.com/sunblaze-ucb/cybergym-e2e.git
cd cybergym-e2e
git apply ../DeepAVR/adapter/patches/cybergym-e2e.patch # opt-in APT mirror, see adapter/docs
python3.10 -m venv .venv
.venv/bin/pip install tomli tomli_w anthropic openai boto3 httpx huggingface_hub docker
export HF_TOKEN=...
.venv/bin/hf download sunblaze-ucb/cybergym-e2e --repo-type dataset \
--revision 29a59f0876f5c3612e44f380aa297ab4faf4b847 --local-dir data/
.venv/bin/python scripts/pull_images.py
sudo sysctl -w vm.mmap_rnd_bits=28 # required by the sanitizers
To try a single task, download only its data, e.g. --include 'projects/md4c/arvo_31332/*'.
Run DeepAVR from the CyberGym-E2E checkout, with CyberGym's interpreter:
export CYBERGYM_ROOT="$PWD" DEEPAVR_ROOT=/path/to/DeepAVR
export PYTHONPATH="$DEEPAVR_ROOT/adapter"
# one task
.venv/bin/python -m deepavr_cybergym run md4c/arvo_31332 --llm-provider openai --llm-model gpt-4.1
# many tasks
.venv/bin/python -m deepavr_cybergym batch --language c --parallel 8