SecCodePLT:一個統一平台,用於評估代碼生成AI的安全性。
SecCodePLT: A Unified Platform for Evaluating the Security of Code GenAI
October 14, 2024
作者: Yu Yang, Yuzhou Nie, Zhun Wang, Yuheng Tang, Wenbo Guo, Bo Li, Dawn Song
cs.AI
摘要
現有研究已建立多個基準,以突顯與代碼生成人工智慧(Code GenAI)相關的安全風險。這些風險主要體現在兩個方面:模型生成不安全代碼的潛力(不安全編碼)及其在網絡攻擊中的實用性(網絡攻擊幫助)。儘管這些基準已取得重大進展,但仍存在進一步改進的機會。例如,許多當前的基準往往更注重模型提供攻擊建議的能力,而非其生成可執行攻擊的能力。此外,大多數基準傾向於嚴重依賴靜態評估指標,這可能不如動態指標(如通過測試案例)那樣精確。相反,經專家驗證的基準雖然提供高質量數據,但往往規模較小。為彌補這些差距,我們開發了SecCodePLT,這是一個統一而全面的評估平台,用於評估代碼生成人工智慧的風險。對於不安全代碼,我們引入了一種結合專家與自動生成的數據創建新方法論。我們的方法確保了數據質量,同時實現了大規模生成。我們還將樣本與測試案例相關聯,以進行與代碼相關的動態評估。對於網絡攻擊幫助,我們建立了一個真實環境並構建樣本,以促使模型生成實際攻擊,並在我們的環境中使用動態指標。我們進行了廣泛的實驗,並展示了SecCodePLT在安全相關性方面優於最先進的基準CyberSecEval。此外,它更好地識別了最先進模型在不安全編碼和網絡攻擊幫助方面的安全風險。最後,我們將SecCodePLT應用於最先進的代碼代理Cursor,並首次識別了這個先進代碼代理中的非微不足道的安全風險。
English
Existing works have established multiple benchmarks to highlight the security
risks associated with Code GenAI. These risks are primarily reflected in two
areas: a model potential to generate insecure code (insecure coding) and its
utility in cyberattacks (cyberattack helpfulness). While these benchmarks have
made significant strides, there remain opportunities for further improvement.
For instance, many current benchmarks tend to focus more on a model ability to
provide attack suggestions rather than its capacity to generate executable
attacks. Additionally, most benchmarks rely heavily on static evaluation
metrics, which may not be as precise as dynamic metrics such as passing test
cases. Conversely, expert-verified benchmarks, while offering high-quality
data, often operate at a smaller scale. To address these gaps, we develop
SecCodePLT, a unified and comprehensive evaluation platform for code GenAIs'
risks. For insecure code, we introduce a new methodology for data creation that
combines experts with automatic generation. Our methodology ensures the data
quality while enabling large-scale generation. We also associate samples with
test cases to conduct code-related dynamic evaluation. For cyberattack
helpfulness, we set up a real environment and construct samples to prompt a
model to generate actual attacks, along with dynamic metrics in our
environment. We conduct extensive experiments and show that SecCodePLT
outperforms the state-of-the-art (SOTA) benchmark CyberSecEval in security
relevance. Furthermore, it better identifies the security risks of SOTA models
in insecure coding and cyberattack helpfulness. Finally, we apply SecCodePLT to
the SOTA code agent, Cursor, and, for the first time, identify non-trivial
security risks in this advanced coding agent.Summary
AI-Generated Summary