The paper addresses security vulnerabilities in AI-generated code (vibe coding). It first finds that insecure code-generating agents are less than half as likely to conduct effective planning and testing for hidden security risks. To mitigate this, the authors develop SecureVibe, a training recipe that explicitly targets security planning and testing. SecureVibe uses supervised fine-tuning on a security suite of 4 tasks, plus post-training methods: reinforcement learning from verifiable execution feedback (SecureVibe_rl) and hint-based self-supervision (SecureVibe_hg).
SecureVibe outperforms baselines across two types of security coding tasks on four benchmarks. It improves security pass@1 by 6.9 points on BaxBench and 11.5 points on unseen CWE categories in SusVibes. Notably, it also improves functionality pass@1 by 13.6 points on SusVibes and 4.1 points on SWE-bench Verified, showing that security enhancements do not degrade functional correctness. The work offers practical insights: diversifying supervision across planning, coding, and testing is more effective than adding more coding trajectories alone, and hint-guided supervision helps when the agent's existing security capabilities are insufficient.