Home / Projects / PatchAnalyzer

PatchAnalyzer

Symbolic Min-Max Analysis for Assessing Patch Correctness

Manuscript complete, targeting ACM TOSEMDissertation work

Generating a plausible patch is no longer the hard part. Deciding whether it is correct is. PatchAnalyzer answers two questions with evidence. Does any input still trigger the vulnerability, and does behavior change on inputs that were safe before?

280
developer and LLM-generated patches assessed, for 70 vulnerabilities in 30 projects
5
developer patches flagged unsafe, each fixed again upstream later
3 / 73
of 195 valid-looking LLM patches are unsafe / safe but change behavior
55
small input domains where exhaustive enumeration matched every count

The idea

A correct security patch must remove the reported vulnerability across the whole input domain and preserve intended behavior. Replaying the crash, running tests, or fuzzing the patched program cannot show either. PatchAnalyzer splits the input domain into a vulnerability space, the inputs where the vulnerable program violates the safety property, and a functionality space, all the other inputs. It then counts, using symbolic execution and model counting, how many inputs in each space a patch gets wrong.

The assessment is min-max. Minimize the inputs that still violate the property, and among patches that violate nothing, maximize the inputs whose behavior stays the same.

Two spaces of the input domain and six illustrative patches ranked by min-max assessment
The two spaces of the input domain and six illustrative patches, ranked by the min-max assessment.

How it works

Three phases. Contract synthesis defines both spaces. An LLM agent builds the execution harness, and PatchAnalyzer requires the reported violation to reproduce concretely before accepting it. Differential analysis symbolically executes the vulnerable and patched functions from the same state, and classifies every path by whether the patch removes, keeps, or introduces a violation and whether the output changes. Patch impact analysis uses model counting to quantify the inputs in each set, and returns a verdict with a witness input for every violation and behavior change.

Overview of PatchAnalyzer with its three phases
The three phases of PatchAnalyzer, from contract synthesis to patch impact analysis.

An example from the evaluation

Four patches for a heap out-of-bounds read in Ghostscript (arvo:42327). All four block the proof-of-concept input, and the three LLM patches pass CyberGym's validity checks. Their semantics still diverge. The developer patch compares with >, so it misses the case where the index equals the size, and 256 violating inputs remain. The patches from Claude and Gemini remove all 256 and keep every safe input equivalent. GPT's patch removes them as well, but changes the output on 1,632 safe inputs. PatchAnalyzer ranks Claude and Gemini first, GPT second, and the developer patch last.

Four candidate patches for arvo:42327
Four patches for the out-of-bounds read in arvo:42327.

What the guarantee covers

Every result is labeled exhaustive or partial. An exhaustive result means symbolic exploration completed and every path was counted exactly, so each count equals the size of its set. Under that label, the counts are guarantees for the declared inputs and safety property, not samples. A partial result gives witnesses only.

The assumptions are explicit. The harness must reproduce the reported violation concretely before it is accepted, the checker and domain width come from the report, and any constraint that narrows the domain is listed along with the inputs it excludes. Behavior is compared on return values, and only on paths that complete within the bound.

What it found

On 280 patches for 70 vulnerabilities in 30 CyberGym projects, PatchAnalyzer flags five developer patches as unsafe, and each was fixed again upstream in the same function. One of them introduced an overflow that OSS-Fuzz detected ten weeks later. Among the 195 LLM patches that meet CyberGym's valid-patch criteria, it flags 3 as unsafe and 73 as safe but functionally different. Exhaustive enumeration of the 55 domains of at most three bytes agrees with every count.

This work is not yet published. The numbers above are from the current draft and may change before submission.

Cite

Md Shafiuzzaman, Tevfik Bultan. PatchAnalyzer: Symbolic Min-Max Analysis for Assessing Patch Correctness. Manuscript complete; submission to ACM Transactions on Software Engineering and Methodology (TOSEM) planned October 2026.

← Back to home