LLMs frequently overconfident about insecure code, with worse functional than security calibration
The evaluated LLMs exhibit prevalent overconfidence in generated code, especially for functional correctness
Software arXiv 30 Jun 2026 Measurement Simulation evidence
Published as “An Empirical Study of Security Calibration in Large Language Models for Code”
Why it matters
Execution gating can markedly lower overconfidence, offering a practical way to reduce the risk of deploying vulnerable AI-generated code, albeit at the cost of discarding many samples.
Summary
The study finds that current code-generation LLMs are dramatically overconfident about the security of their outputs, with False Trust rates up to 83% in realistic repository settings. Even the best-performing model (Gemini-2.0-Flash) still has an Expected Calibration Error around 0.25, far above well-calibrated thresholds. Mitigation via execution gating cuts ECE by roughly a third but discards 45-86% of samples, while calibration-guided repair offers little security gain and often breaks functionality. The paper provides the first large-scale measurement of security calibration across 36 000 snippets, three models, and multiple temperatures, but no abstract was supplied to summarize the work.
What they found 3
- Verbalized confidence is severely miscalibrated for GPT-4o-mini and Qwen3-Coder-Next, and only modestly better for Gemini-2.0-Flash.
“Using verbalized confidence, GPT-4o-mini and Qwen3-Coder-Next exhibit severe miscalibration (ECE ∈[0.456, 0.481] and [0.408, 0.421], respectively), while Gemini-2.0-Flash shows comparatively better calibration (ECE ∈[0.247, 0.263]), though still far above typical well-calibrated thresholds (ECE ≤0.01) [28].”
- Calibration degrades sharply when moving from isolated functions to repository-level generation.
“For GPT-4o-mini, average ECE rises from 0.411 on SALLM to 0.697 on repository tasks (∆ECE = +0.286), while False Trust increases from 16.9% to 83.2% (∆FT = +66.3%).”
- Execution gating consistently reduces calibration error across all models.
“All LLMs show ECE reduction through functional gating, confirming that the execution brittleness mechanism is universal.”
Caveats 2
- Calibration-guided repair does not reliably improve security. Repair success remains low (0.00%-2.39%), and functional breakage often exceeds 60%.
- However, absolute values such as specific False Trust rates, per-language degradation magnitudes, and ECE scores are model- and version-specific and may shift with future releases.
What’s new here 4
- First systematic measurement of how well LLMs self-assess the security of generated code (security calibration).
- Comparison of calibration between self-contained functions and multi-file repository contexts, revealing severe degradation.
- Evaluation of mitigation techniques (execution gating, authorized-breaking repair, few-shot prompting) on security calibration.
- Analysis of calibration-guided repair pipelines, showing low repair success despite confidence signals.