paper-with-me

Papers

DeepGuard: Secure Code Generation via Multi-Layer Semantic Aggregation

2026-04-10 · Li Huang, Zhongxin Liu, Yifan Wu, Tao Yin, Dong Li, Jichao Bi, Nankun Mu, Hongyu Zhang, Meng Yan arxiv

Large Language Models (LLMs) for code generation can replicate insecure patterns from their training data. To mitigate this, a common strategy for security hardening is to fine-tune models using supervision derived from the final transformer layer. However, this design may suffer from a final-layer bottleneck: vulnerability-discriminative cues can be distributed across layers and become less detectable near the output representations optimized for next-token prediction. To diagnose this issue, we perform layer-wise linear probing. We observe that vulnerability-related signals are most detectable in a band of intermediate-to-upper layers yet attenuate toward the final layers. Motivated by this observation, we introduce DeepGuard, a framework that leverages distributed security-relevant cues by aggregating representations from multiple upper layers via an attention-based module. The aggregated signal powers a dedicated security analyzer within a multi-objective training objective that balances security enhancement and functional correctness, and further supports a lightweight inference-time steering strategy. Extensive experiments across five code LLMs demonstrate that DeepGuard improves the secure-and-correct generation rate by an average of 11.9% over strong baselines such as SVEN. It also preserves functional correctness while exhibiting generalization to held-out vulnerability types. Our code is public at https://github.com/unknownhl/DeepGuard.

📄 PDF Abstract BibTeX arXiv:2604.09089

Code (0)

등록된 구현이 없습니다.

Tasks

Code Generation

Similar Papers 제목 키워드 기반

DeepGuard: A Framework for Safeguarding Autonomous Driving Systems from Inconsistent Behavior

2021-11-18 · Manzoor Hussain, Nazakat Ali, Jang-Eui Hong

The deep neural networks (DNNs)based autonomous driving systems (ADSs) are expected to reduce road accidents and improve safety in the transportation domain as it removes the factor of human error from driving tasks. The…

Anomaly DetectionAutonomous DrivingAutonomous VehiclesTime Series+1

Surgical Repair of Insecure Code Generation in LLMs

2026-04-17 · Gustavo Sandoval, Brendan Dolan-Gavitt, Siddharth Garg arxiv

Large language models write production code, and yet they routinely introduce well-known vulnerabilities. We show that this is not a knowledge deficit: the same models that generate insecure code, correctly identify and …

Code Generation

SecRepoBench: Benchmarking LLMs for Secure Code Generation in Real-World Repositories

2025-04-29 · Connor Dilgren, Purva Chiniya, Luke Griffith, Yu Ding 외

This paper introduces SecRepoBench, a benchmark to evaluate LLMs on secure code generation in real-world repositories. SecRepoBench has 318 code generation tasks in 27 C/C++ repositories, covering 15 CWEs. We evaluate 19…

BenchmarkingCode GenerationPrompt Engineering

SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forward

2026-06-23 · Rupam Patir, Keyan Guo, Haipeng Cai, Hongxin Hu arxiv

The increasing use of AI systems for code generation raises a central security question: what can today's models and coding agents actually do to produce secure code, where do they still fail, and what would move the fie…

Reinforcement LearningCode Generation

RESCUE: Retrieval Augmented Secure Code Generation

2025-10-21 · Jiahao Shi, Tianyi Zhang arxiv

Despite recent advances, Large Language Models (LLMs) still generate vulnerable code. Retrieval-Augmented Generation (RAG) has the potential to enhance LLMs for secure code generation by incorporating external security k…

Code Generation