用结构化提示提升代码漏洞检测,发现越复杂越容易失效
Routing Ceilings Are Domain-Independent: Structural Prior Injection in Code Security Vulnerability Detection
- 用结构提示增强模型识别漏洞能力,尤其对语义类漏洞效果显著
- 提示在真实漏洞数据上性能暴跌,最差下降51.1个百分点
- 迭代优化提示反而更差,说明需训练而非只调提示
大型语言模型虽具备解决代码安全漏洞检测的能力,但难以稳定激活。本文在代码安全领域复现了形式数学推理中的结构提示(cheatsheet)实验,评估了GPT-OSS-120B、Llama-3.3-70B和Gemma-4-31B三个模型在三类漏洞(CWE-798、CWE-284、非标准反模式)上的表现,并将提示迁移到真实CVE数据集VUDENC(CWE-89、CWE-22)。结果表明:(F1)结构提示使语义漏洞召回率从20.0%提升至100.0%;(F2)零样本性能随语义复杂度升高而下降;(F3)相同提示在真实数据上引发分布偏移崩溃(如CWE-89 F1从100%降至48.9%,-51.1pp);(F5)迭代重构提示得到的v2版本在真实数据上表现劣于v1,与先前研究一致。这些发现表明,跨域性能权衡现象在代码安全中成立,支持路由器假设的跨领域性。建议采用分布感知训练替代仅靠提示校准。
原文摘要 · Abstract (English)
Large language models (LLMs) exhibit a well-documented gap between latent capability and consistent activation: the router hypothesis posits that models possess the knowledge to solve a task but lack reliable internal routing to activate it. Prior work in formal mathematical reasoning (SAIR, Cázares 2026) reports that structural priors (cheatsheets) raise in-distribution performance dramatically, yet collapse below the zero-shot baseline out-of-distribution (OOD) -- and that iterative recalibration amplifies rather than corrects the collapse. We test whether this phenomenon is cross-domain by reproducing the SAIR design in source-code security vulnerability detection, evaluating three LLMs (GPT-OSS-120B, Llama-3.3-70B, Gemma-4-31B) across three vulnerability categories (CWE-798, CWE-284, and the non-CWE N+1 anti-pattern) spanning syntactic, contextual, and semantic complexity, then transferring cheatsheet-augmented prompts to real-world CVE data from VUDENC (CWE-89, CWE-22). Our findings replicate and extend SAIR: (F1) structural priors lift semantic-vulnerability recall from 20.0% to 100.0% across all models; (F2) zero-shot performance degrades along a semantic complexity gradient; (F3) the same cheatsheets that saturate synthetic performance amplify distribution-shift collapse on real CVE data (CWE-89: 100% synthetic F1 to 48.9% on VUDENC, -51.1pp); (F5) iterative recalibration produces a v2 cheatsheet that performs worse than v1 on real data, mirroring SAIR's AN45c-vs-AN38 finding. These results provide evidence that the cross-distribution trade-off surface documented in SAIR generalises to code security, and that the router hypothesis is cross-domain. We argue the structural nature of the collapse motivates distribution-aware training over prompt calibration. Code and evaluation scripts: https://github.com/bytepro-ai/bitcoder-v2-research
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。