A Stealthy Backdoor Attack for Code Models

preprint OA: closed
Full text JSON View at publisher

Abstract

Abstract Recent studies have shown that code models are susceptible to backdoor attacks. When injected with a backdoor, the victim code model can function normally on benign samples but may produce predetermined malicious outputs when triggers are activated. However, previous backdoor attacks on code models have used explicit triggers, and we aim to investigate the vulnerability of code models to stealthy backdoor attacks in this study. To this end, we propose a backdoor attack approach using Abstract Syntax Tree-based Triggers (ASTT) to obtain stealthiness. We evaluate ASTT on deep learning-based code models and three downstream tasks (i.e., code translation, code repair, and defect detection). With the clustering algorithm, we generated triggers based on abstract syntax trees. We find that the average attack success rate of our ASTT can reach 92.71%. Moreover, our ASTT is stealthy and can effectively bypass state-of-the-art defense approaches. Finally, we verify that the time overhead of our proposed ASTT is small and can meet the needs in real scenarios. Our finding demonstrates security weaknesses in code models under stealthy backdoor attacks.
Full text 11,139 characters · extracted from preprint-html · click to expand
A Stealthy Backdoor Attack for Code Models | Research Square window.SnipcartSettings = { analytics: { enabled: false } }; (function() { var accessVector = localStorage.getItem('access_vector') || ''; window.dataLayer = window.dataLayer || []; if (accessVector) { window.dataLayer.push({ user: { profile: { profileInfo: { snid: accessVector } } } }); } })(); (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-K279D39R'); Browse Preprints In Review Journals COVID-19 Preprints AJE Video Bytes Research Tools Research Promotion AJE Professional Editing AJE Rubriq About Preprint Platform In Review Editorial Policies Our Team Advisory Board Help Center Sign In Submit a Preprint Cite Share Download PDF Research Article A Stealthy Backdoor Attack for Code Models yubin qu, Song Huang, Xiang Chen, Xiaolin Ju, Long Li, Xingya Wang, and 2 more This is a preprint; it has not been peer reviewed by a journal. https://doi.org/ 10.21203/rs.3.rs-3969016/v1 This work is licensed under a CC BY 4.0 License Status: Posted Version 1 posted You are reading this latest preprint version Abstract Recent studies have shown that code models are susceptible to backdoor attacks. When injected with a backdoor, the victim code model can function normally on benign samples but may produce predetermined malicious outputs when triggers are activated. However, previous backdoor attacks on code models have used explicit triggers, and we aim to investigate the vulnerability of code models to stealthy backdoor attacks in this study. To this end, we propose a backdoor attack approach using Abstract Syntax Tree-based Triggers (ASTT) to obtain stealthiness. We evaluate ASTT on deep learning-based code models and three downstream tasks (i.e., code translation, code repair, and defect detection). With the clustering algorithm, we generated triggers based on abstract syntax trees. We find that the average attack success rate of our ASTT can reach 92.71%. Moreover, our ASTT is stealthy and can effectively bypass state-of-the-art defense approaches. Finally, we verify that the time overhead of our proposed ASTT is small and can meet the needs in real scenarios. Our finding demonstrates security weaknesses in code models under stealthy backdoor attacks. Code Translation Code Repair Defect detection Deep Neural Network Data Poisoning Attack Full Text Additional Declarations No competing interests reported. Cite Share Download PDF Status: Posted Version 1 posted You are reading this latest preprint version Research Square lets you share your work early, gain feedback from the community, and start making changes to your manuscript prior to peer review in a journal. As a division of Research Square Company, we’re committed to making research communication faster, fairer, and more useful. We do this by developing innovative software and high quality services for the global research community. Our growing team is made up of researchers and industry professionals working together to solve the most critical problems facing scientific publishing. Also discoverable on Platform About Our Team In Review Editorial Policies Advisory Board Help Center Resources Author Services Accessibility API Access RSS feed Manage Cookie Preferences © Research Square 2026 | ISSN 2693-5015 (online) Privacy Policy Terms of Service Do Not Sell My Personal Information {"props":{"pageProps":{"initialData":{"identity":"rs-3969016","acceptedTermsAndConditions":true,"allowDirectSubmit":true,"archivedVersions":[],"articleType":"Research Article","associatedPublications":[],"authors":[{"id":273861247,"identity":"99147a28-c830-4c14-9b13-49cf559e4ba2","order_by":0,"name":"yubin qu","email":"","orcid":"","institution":"PLA Army Engineering University","correspondingAuthor":false,"prefix":"","firstName":"yubin","middleName":"","lastName":"qu","suffix":""},{"id":273861248,"identity":"709812a7-3012-4954-b329-9e18b94b4b51","order_by":1,"name":"Song Huang","email":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAAyAQMAAABI0h/eAAAABlBMVEX///8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA40lEQVRIiWNgGAWjYBACAziLvQFMMTYQr4XnAMlaJBKI1GIukfzs4Zc/NnnykY8fPuZhsJHdcID52QN8WixnpJkby7alFRveTjM25mFIM95wgM3cAJ8WgxsJZtKSDYcTN84GMngYDiduOMDDJoFfS/o3aYk/QC0zj3//zcPwnxgtOWaSH9gOJ86X4DFj5mE4QISWM2/KpBnb0hI38OQUS84xSDaeeZjNDL+W4+nbJH/8sUmc335844c3FXayfcebn+HVAgJA9wD1HgCbAOISUg8EjD+AhHwDESpHwSgYBaNgZAIA8T9K/JM2WxwAAAAASUVORK5CYII=","orcid":"","institution":"PLA Army Engineering University","correspondingAuthor":true,"prefix":"","firstName":"Song","middleName":"","lastName":"Huang","suffix":""},{"id":273861249,"identity":"5d5840f5-502e-4517-8cf6-e726999ba06c","order_by":2,"name":"Xiang Chen","email":"","orcid":"","institution":"Nantong University","correspondingAuthor":false,"prefix":"","firstName":"Xiang","middleName":"","lastName":"Chen","suffix":""},{"id":273861250,"identity":"25dfd67e-6473-41ee-8c43-a001960db118","order_by":3,"name":"Xiaolin Ju","email":"","orcid":"","institution":"Nantong University","correspondingAuthor":false,"prefix":"","firstName":"Xiaolin","middleName":"","lastName":"Ju","suffix":""},{"id":273861251,"identity":"3eddc2e3-d7d8-4e6b-9f7e-70cd6f2e01f0","order_by":4,"name":"Long Li","email":"","orcid":"","institution":"Guilin University of Electronic Technology","correspondingAuthor":false,"prefix":"","firstName":"Long","middleName":"","lastName":"Li","suffix":""},{"id":273861252,"identity":"b4040692-8d50-49b7-a394-c520c56faec0","order_by":5,"name":"Xingya Wang","email":"","orcid":"","institution":"Nanjing Tech University","correspondingAuthor":false,"prefix":"","firstName":"Xingya","middleName":"","lastName":"Wang","suffix":""},{"id":273861253,"identity":"1e065327-ecc2-444e-a2b3-0db3548e9f91","order_by":6,"name":"Yongming Yao","email":"","orcid":"","institution":"PLA Army Engineering University","correspondingAuthor":false,"prefix":"","firstName":"Yongming","middleName":"","lastName":"Yao","suffix":""},{"id":273861254,"identity":"0aeb9608-9534-4d0a-93cd-37f13984a5f1","order_by":7,"name":"Ziqin Xiao","email":"","orcid":"","institution":"PLA Army Engineering University","correspondingAuthor":false,"prefix":"","firstName":"Ziqin","middleName":"","lastName":"Xiao","suffix":""}],"badges":[],"createdAt":"2024-02-19 05:34:14","currentVersionCode":1,"declarations":"","doi":"10.21203/rs.3.rs-3969016/v1","doiUrl":"https://doi.org/10.21203/rs.3.rs-3969016/v1","draftVersion":[],"editorialEvents":[],"editorialNote":"","failedWorkflow":false,"files":[{"id":78228894,"identity":"9908e578-6ed3-4e1a-a9cd-badd1d77eae8","added_by":"auto","created_at":"2025-03-11 07:17:08","extension":"pdf","order_by":1,"title":"","display":"","copyAsset":false,"role":"manuscript-pdf","size":1663670,"visible":true,"origin":"","legend":"","description":"","filename":"ASEAStealthyBackdoorAttackforCodeModels.pdf","url":"https://assets-eu.researchsquare.com/files/rs-3969016/v1_covered_cb78410d-29f7-4dcd-8976-ba92acb0e488.pdf"}],"financialInterests":"No competing interests reported.","formattedTitle":"A Stealthy Backdoor Attack for Code Models","fulltext":[],"fulltextSource":"","fullText":"","funders":[],"hasAdminPriorityOnWorkflow":false,"hasManuscriptDocX":false,"hasOptedInToPreprint":true,"hasPassedJournalQc":"","hasAnyPriority":false,"hideJournal":true,"highlight":"","institution":"","isAcceptedByJournal":false,"isAuthorSuppliedPdf":true,"isDeskRejected":"","isHiddenFromSearch":false,"isInQc":false,"isInWorkflow":false,"isPdf":true,"isPdfUpToDate":true,"isWithdrawnOrRetracted":false,"journal":{"display":true,"email":"[email protected]","identity":"researchsquare","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":true,"externalIdentity":"","sideBox":"","snPcode":"","submissionUrl":"/submission","title":"Research Square","twitterHandle":"researchsquare","acdcEnabled":true,"dfaEnabled":false,"editorialSystem":"","reportingPortfolio":"","inReviewEnabled":false,"inReviewRevisionsEnabled":true},"keywords":"Code Translation, Code Repair, Defect detection, Deep Neural Network, Data Poisoning Attack","lastPublishedDoi":"10.21203/rs.3.rs-3969016/v1","lastPublishedDoiUrl":"https://doi.org/10.21203/rs.3.rs-3969016/v1","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"},"manuscriptAbstract":"Recent studies have shown that code models are susceptible to backdoor attacks. When injected with a backdoor, the victim code model can function normally on benign samples but may produce predetermined malicious outputs when triggers are activated. However, previous backdoor attacks on code models have used explicit triggers, and we aim to investigate the vulnerability of code models to stealthy backdoor attacks in this study. To this end, we propose a backdoor attack approach using Abstract Syntax Tree-based Triggers (ASTT) to obtain stealthiness. We evaluate ASTT on deep learning-based code models and three downstream tasks (i.e., code translation, code repair, and defect detection). With the clustering algorithm, we generated triggers based on abstract syntax trees. We find that the average attack success rate of our ASTT can reach 92.71%. Moreover, our ASTT is stealthy and can effectively bypass state-of-the-art defense approaches. Finally, we verify that the time overhead of our proposed ASTT is small and can meet the needs in real scenarios. Our finding demonstrates security weaknesses in code models under stealthy backdoor attacks.","manuscriptTitle":"A Stealthy Backdoor Attack for Code Models","msid":"","msnumber":"","nonDraftVersions":[{"code":1,"date":"2024-02-22 05:04:35","doi":"10.21203/rs.3.rs-3969016/v1","editorialEvents":[{"type":"communityComments","content":0}],"status":"published","journal":{"display":true,"email":"[email protected]","identity":"researchsquare","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":true,"externalIdentity":"","sideBox":"","snPcode":"","submissionUrl":"/submission","title":"Research Square","twitterHandle":"researchsquare","acdcEnabled":true,"dfaEnabled":false,"editorialSystem":"","reportingPortfolio":"","inReviewEnabled":false,"inReviewRevisionsEnabled":true}}],"origin":"","ownerIdentity":"b1444eb6-a657-4d31-bfde-5c041d7381ce","owner":[],"postedDate":"February 22nd, 2024","published":true,"recentEditorialEvents":[],"rejectedJournal":[],"revision":"","amendment":"","status":"posted","subjectAreas":[],"tags":[],"updatedAt":"2025-03-11T07:09:01+00:00","versionOfRecord":[],"versionCreatedAt":"2024-02-22 05:04:35","video":"","vorDoi":"","vorDoiUrl":"","workflowStages":[]},"version":"v1","identity":"rs-3969016","journalConfig":"researchsquare"},"__N_SSP":true},"page":"/article/[identity]/[[...version]]","query":{"redirect":"/article/rs-3969016","identity":"rs-3969016","version":["v1"]},"buildId":"qtupq5eGEP_6zYnWcrvyt","isFallback":false,"isExperimentalCompile":false,"dynamicIds":[84888],"gssp":true,"scriptLoader":[]}

Text is read by the "Ask this paper" AI Q&A widget below. Extraction quality varies by source — PMC NXML preserves structure cleanly, OA-HTML may include some navigation residue, and OA-PDF can have broken hyphenation. The publisher copy (via DOI) is the canonical version.

My notes (saved in your browser only)

Ask this paper AI returns verbatim quotes from the full text · source: preprint-html

Answers must be backed by verbatim quotes from this paper's full text. Hallucinated quotes are dropped automatically; if no verbatim passage answers the question, we say so. How this works

Citation neighborhood (no data yet)

We don't have any in-corpus citations linked to this paper yet. This is a recent paper (2024) — citers typically take a year or two to land, and the OpenAlex reference graph may still be filling in.

Source provenance

europepmc
last seen: 2026-05-20T01:45:00.602351+00:00