Md Abdul Hannan (Colorado State University), Ronghao Ni (Carnegie Mellon University), Chi Zhang (Carnegie Mellon University), Limin Jia (Carnegie Mellon University), Ravi Mangal (Colorado State University), Corina S. Pasareanu (Carnegie Mellon University)

Large language models (LLMs) have demonstrated impressive capabilities across a wide range of coding tasks, including summarization, translation, completion, and code generation. Despite these advances, detecting code vulnerabilities remains a challenging problem for LLMs. In-context learning (ICL) has emerged as an effective mechanism for improving model performance by providing a small number of labeled examples within the prompt. Prior work has shown, however, that the effectiveness of ICL depends critically on how these few-shot examples are selected. In this paper, we study two intuitive criteria for selecting few-shot examples for ICL in the context of code vulnerability detection. The first criterion leverages model behavior by prioritizing samples on which the LLM consistently makes mistakes, motivated by the intuition that such samples can expose and correct systematic model weaknesses. The second criterion selects examples based on semantic similarity to the query program, using k-nearest-neighbor retrieval to identify relevant contexts.

We conduct extensive evaluations using open-source LLMs and datasets spanning multiple programming languages. Our results show that for Python and JavaScript, careful selection of few-shot examples can lead to measurable performance improvements in vulnerability detection. In contrast, for C and C++ programs, few-shot example selection has limited impact, suggesting that more powerful but also more expensive approaches, such as retraining or fine-tuning, may be required to substantially improve model performance.

View More Papers

Ipotane: Balancing the Good and Bad Cases of Asynchronous...

Xiaohai Dai (Huazhong University of Science and Technology), Chaozheng Ding (Huazhong University of Science and Technology), Hai Jin (Huazhong University of Science and Technology), Julian Loss (CISPA Helmholtz Center for Information Security), Ling Ren (University of Illinois at Urbana-Champaign)

Read More

Pando: Extremely Scalable BFT Based on Committee Sampling

Xin Wang (Tsinghua University and State Key Laboratory of Cryptography and Digital Economy Security), Haochen Wang (Tsinghua University), Haibin Zhang (Yangtze Delta Region Institute of Tsinghua University, Zhejiang), Sisi Duan (Tsinghua University, Zhongguancun Laboratory, Shandong Institute of Blockchains and State Key Laboratory of Cryptography and Digital Economy Security)

Read More

LatticeBox: A Hardware-Software Co-Designed Framework for Scalable and Low-Latency...

ZhanPeng Liu (Peking University), Chenyang Li (Peking University), Wende Tan (Imperial College London), Yuan Li (Zhongguancun Laboratory), Xinhui Han (Peking University), Xi Cao (Science City (Guangzhou) Digital Technology Group Co., Ltd.), Yong Xie (Qinghai University), Chao Zhang (Tsinghua University)

Read More