AIarXiv

Ranked by formulaVerdict: Notable

Secure and Functional Code Generation with Self-Evaluation

Large Language Models (LLMs) can generate functionally correct code that remains insecure.

By Al Mamun, Uddin

Score████░░░░░░3.6

Key numbers

  • 15.5% over RAG
  • 19.8% over the strongest prompt
  • 6% in FS

Caveats

  • Preprint; not yet peer reviewed.

VerdictWorth a reader's time today.

Read the originalPDF

Abstract

Large Language Models (LLMs) can generate functionally correct code that remains insecure. Security-focused fine-tuning can be expensive and is not always available, motivating inference-time approaches. Security-oriented prompting and retrieval can reduce vulnerabilities, but may also remove required behavior or apply defenses incompatible with the task. The challenge is to identify relevant security knowledge and use it to improve security without sacrificing functionality. We present SecGent, an inference-time framework that retrieves weakness context from the Common Weakness Enumeration (CWE) database and applies it to secure code generation. By connecting task specifications to relevant textual CWE records, SecGent provides task-specific security guidance without relying on retrieved vulnerable or patched code examples. Complementary functional and security tests check the resulting implementation, and their execution feedback guides repairs toward satisfying both objectives. We evaluate SecGent with four open-source LLMs and Claude Sonnet 5.5 across five programming languages on the CWEval benchmark. It achieves the highest joint functional--security success against four inference-time baselines for all five models. Across the open-weight models, mean functional-security@1 (FS@1) improves by 15.5% over RAG, with gains in both functionality and security, and by 19.8% over the strongest prompt optimizer compiled for each model. On Sonnet, FS@1 reaches 92.1%, outperforming the strongest baseline AutoGen by 4.8%. In a separate comparison, SecGent outperforms Claude Code with security-focused prompting by over 6% in FS@1. Feedback-guided repair further improves FS@1 by up to 6.7% over generation without feedback, primarily by recovering functionality while checking security.

Md Afif Al Mamun, Gias Uddin

The editor's rubric

Heuristic review

Leverage4 / 5
A general-purpose tool used across several fields (Adam, ResNet, LoRA, next-generation sequencing).
24% of this desk’s rubric
Magnitude3 / 5
Large gain: roughly 2x, or a clear new state of the art on a hard, unsaturated problem.
18% of this desk’s rubric
Evidence3 / 5
Solid: multiple benchmarks or cohorts, ablations, fair baselines, released code or data.
14% of this desk’s rubric
Novelty3 / 5
A genuinely new approach to an open problem.
16% of this desk’s rubric
Trajectory2 / 5
Some room to improve with obvious engineering.
18% of this desk’s rubric
Stakes2 / 5
Benefits a professional community (practitioners, clinicians, engineers).
10% of this desk’s rubric

Editor’s rationale

Heuristic triage from title and abstract text only, not a reading of the paper. Cues found: method (we propose); breadth (many tasks); gains (relative gain, outperforms); novelty (alternative to status quo); verification (multiple benchmarks, code released); stakes (general AI).

How the score was computed

rank-2026-10-18

Score████░░░░░░3.6

Score = 10 × (65% × adjusted merit / 10 + 25% × attention + 10% × freshness)

Desks place stronger verdicts first, then use this score to order work within the same verdict.

Merit
5.9 / 10
Weighted rubric, evidence-gated.
Adjusted merit
4.8 / 10
Shrunk toward the desk prior by editor confidence (44%).
Attention
0%
Citations, upvotes, points, mentions.
Freshness
45%
Half-life decay since publication.

No attention signals recorded yet.

The record

  • Reviewed by heuristic-v10 on Oct 27, 2026, 01:36 UTC. Paper type: method.
  • Categories: cs.CR, cs.MA, cs.SE
  • BRIEF, No.7 in the Artificial Intelligence edition of October 27, 2026.