Search papers, labs, and topics across Lattice.
This paper introduces a transferable adversarial attack targeting code language models (CLMs) that perturbs identifiers in code snippets without changing their functionality, thereby misleading code retrieval systems. The authors demonstrate that this attack can significantly degrade retrieval performance, reducing the Mean Reciprocal Rank (MRR) by up to 77% across various models, including both smaller and larger, closed-source embedding models. These findings reveal a critical vulnerability in current CLM-based search tools, emphasizing the need for more resilient approaches to code retrieval.
Adversarial attacks can manipulate code retrieval systems, reducing their effectiveness by up to 77% without altering code functionality.
Reliable code retrieval is crucial for developer productivity and effective code reuse. However, current neural code language models (CLMs) powering search tools are susceptible to adversarial attacks targeting non-functional textual elements. In this paper, we introduce a programming language-agnostic, transferable, adversarial attack that exploits this CLM vulnerability. Our approach perturbs identifiers within a code snippet without altering the snippet's functionality to artificially align the code with a target query. We demonstrate that our attack, even when computed using smaller code embedding models, such as CodeT5+, is highly effective and transferable to larger, closed-source embedding models, like Voyage-code-3, or LLMs like Gemini-3.1-Pro. Our attack can increase the similarity between the query and arbitrary, irrelevant code snippets, consequently degrading key retrieval metrics such as the Mean Reciprocal Rank (MRR) of state-of-the-art models by up to 77%. The experimental results highlight the fragility of current code search methods and underscore the need for more robust, semantic-aware approaches.