用对抗测试发现编程竞赛代码中的隐蔽漏洞
CodeHacker: Automated Test Case Generation for Detecting Vulnerabilities in Competitive Programming Solutions
- 模仿编程竞赛黑客机制,多策略生成针对性测试用例
- 使现有数据集误判率下降,正确识别错误代码
- 适合评估大模型代码生成质量的研究者使用
大型语言模型(LLM)代码生成的评估严重依赖测试用例的质量与鲁棒性。然而,现有基准测试常缺乏对细微边界情况的覆盖,导致错误解法仍能通过。为此,我们提出CodeHacker——一个自动化代理框架,专用于生成针对特定程序提交的对抗性测试用例,以暴露其潜在漏洞。该框架模拟竞赛中的“黑客”机制,采用压力测试、反哈希攻击及逻辑针对性打击等多策略。为确保攻击有效性,引入校准阶段:代理通过自生成的对抗样本迭代优化自身的验证器与检查器。实验表明,CodeHacker显著提升了现有数据集的真实负例率(TNR),有效过滤此前被误接受的错误解法。此外,生成的对抗样本作为训练数据,可提升基于强化学习训练模型在LiveCodeBench等基准上的表现。
原文摘要 · Abstract (English)
The evaluation of Large Language Models (LLMs) for code generation relies heavily on the quality and robustness of test cases. However, existing benchmarks often lack coverage for subtle corner cases, allowing incorrect solutions to pass. To bridge this gap, we propose CodeHacker, an automated agent framework dedicated to generating targeted adversarial test cases that expose latent vulnerabilities in program submissions. Mimicking the hack mechanism in competitive programming, CodeHacker employs a multi-strategy approach, including stress testing, anti-hash attacks, and logic-specific targeting to break specific code submissions. To ensure the validity and reliability of these attacks, we introduce a Calibration Phase, where the agent iteratively refines its own Validator and Checker via self-generated adversarial probes before evaluating contestant code.Experiments demonstrate that CodeHacker significantly improves the True Negative Rate (TNR) of existing datasets, effectively filtering out incorrect solutions that were previously accepted. Furthermore, generated adversarial cases prove to be superior training data, boosting the performance of RL-trained models on benchmarks like LiveCodeBench.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。