MPC-Patch-Bench: Security-Aware LLM Code Patch for Multi-Party Computation

Yukuan Zhang, Mengxin Zheng, Qian LouarXiv 2026

TL;DR

General-purpose code repair benchmarks fail to accurately evaluate AI on specialized, security-critical software. To bridge this gap, MPC-Patch-Bench introduces a repository-level benchmark specifically for Secure Multi-Party Computation (MPC) that combines domain-specific data curation with strict cryptographic and numerical verification. The findings reveal a stark reality: functional correctness heavily overestimates LLM reliability, as up to 40% of functionally successful patches actually violate critical security or mathematical invariants.

What Problem Does This Paper Address?

Secure Multi-Party Computation (MPC) allows multiple organizations to jointly compute a function over private inputs without revealing the raw data to one another. It is a cornerstone of privacy-preserving machine learning and secure analytics. However, writing and repairing MPC code is exceptionally difficult because it operates over secret shares, interactive protocols, and fixed-point encodings rather than standard plaintext.

When developers try to use general-purpose code repair benchmarks like SWE-bench to evaluate Large Language Models (LLMs) on MPC repositories, they run into three major structural roadblocks:

  1. Infrastructure Noise: MPC repositories are dominated by generic Python infrastructure (like CI/CD pipelines or API wrappers) rather than core cryptographic logic.
  2. Missing Tests: High-value cryptographic fixes in open-source projects frequently ship without the standardized tests that automated benchmark extraction pipelines require.
  3. The Secrecy Contract: Standard "fail-to-pass" testing only checks if code runs and produces an expected output. It completely misses MPC-specific vulnerabilities like secret data leaks, data-oblivious control flow violations, or subtle numerical precision drift.

This paper introduces a benchmark designed to evaluate whether an LLM's code patch is not just functionally correct, but cryptographically safe.

Methods

The authors developed MPC-Patch-Bench, a framework split into two main pipelines:

  1. The Data Curation Framework: To isolate genuine cryptographic tasks, an AI agent filters raw pull requests (PRs) through three layers: a Primitive Check (direct manipulation of secret shares/oblivious transfer), Protocol Logic (interactive multi-party state machines), and Domain Specificity (constraints like data-obliviousness). A human-AI collaborative engine then synthesizes missing problem statements and test harnesses for incomplete PRs, rescuing high-value bugs that would otherwise be discarded.
  2. The MPC Verifier Framework: Once an LLM generates a patch, it must pass a dual-stream verification process:
  3. Dynamic Testing: Runs the secure protocol against a plaintext oracle to catch numerical-fidelity drift (precision loss from fixed-point truncations) and validates strict algebraic edge cases.
  4. Domain-Specific SAST (Static Application Security Testing): Scans the source code using custom rules (e.g., Semgrep) to flag cryptographic anti-patterns, such as unsafe reveals inside loops, insecure randomness, or illegal public/private type casts.
Figure 1: Overview of MPC-Patch-Bench: the Data Curation Framework produces the verified instance pool, which is then evaluated by the MPC Verifier.

Datasets

The benchmark introduces a new dataset consisting of 205 fully verified, executable task instances across five foundational open-source MPC libraries:

  • CrypTen & tf-encrypted (Tensor-based, ML-oriented frameworks)
  • MP-SPDZ (Protocol-level multi-party arithmetic)
  • SecretFlow (Federated and hybrid MPC computation)
  • PySyft (Privacy-preserving deep learning infrastructure)

These 205 instances were distilled from a massive initial pool of 7,305 raw GitHub pull requests. For context, applying strict, traditional SWE-bench filtering to this same pool would have yielded a mere 42 instances, proving the necessity of the authors' curation approach.

Figure 5: Cumulative distribution functions (CDFs) of MPC-Patch-Bench tasks: (left) gold patch size, (centre) Fail-to-Pass test count per instance, and (right) problem statement word count. See main text for analysis.

Key Insights and Ideas

  • Functional Correctness $\neq$ Cryptographic Safety: The most critical takeaway is that standard software engineering metrics are an unsafe proxy for cryptographic code reliability. An LLM can easily write a patch that passes all functional unit tests while silently leaking private data or introducing mathematical errors.
  • Leaderboard Inversion: Introducing security and precision checks doesn't just lower LLM scores; it completely reorders the model leaderboard. Models that excel at aggressive functional guessing often introduce the most security vulnerabilities.
  • The "Sweet Spot" of Complexity: Difficulty analysis showed that mid-complexity fixes (51–200 lines of code) had the highest resolution rates. Extremely short patches (1–10 lines) often required highly precise, expert-level cryptographic intuition that LLMs struggled to replicate.

Key Results

  • Low Overall Success: Even the strongest evaluated model functionally resolved only 22.9% of the 205 tasks. Protocol-level frameworks like MP-SPDZ remained almost entirely unsolved by all models.
  • High Attrition Under Verification: When evaluated by the MPC Verifier, the top model's verified resolution rate plummeted to 17.1%.
  • Up to 40% of functionally passing patches were rejected because they introduced cryptographic vulnerabilities or numerical-fidelity violations.
  • Leaderboard Shift: Under functional testing, Anthropic's Claude 3.5 Sonnet led the ranking. However, under strict security verification, it suffered a 29% attrition rate (losing 14 resolutions to security/precision flags), allowing Claude 3 Opus to overtake it as the safest model.

Limitations and Future Work

The current implementation of MPC-Patch-Bench is limited to five specific Python and C++-based MPC frameworks. The authors note that as the privacy-preserving ecosystem evolves, future work must extend this security-aware benchmarking methodology to other emerging cryptographic stacks, such as Fully Homomorphic Encryption (FHE) hybrids and Zero-Knowledge Proof (ZKP) programming environments.

Summary updated

BibTeX
@misc{zhang2026mpc,
  author = {Yukuan Zhang and Mengxin Zheng and Qian Lou},
  title = {{MPC-Patch-Bench: Security-Aware LLM Code Patch for Multi-Party Computation}},
  year = {2026},
  eprint = {2606.11416},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.11416},
}
Figure