Static Analysis-Guided Patch Synthesis for Correcting LLM-Generated Insecure Code

preprint OA: closed
Full text JSON View at publisher
Full text 9,731 characters · extracted from preprint-html · click to expand
Static Analysis-Guided Patch Synthesis for Correcting LLM-Generated Insecure Code | 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 Static Analysis-Guided Patch Synthesis for Correcting LLM-Generated Insecure Code Miriam Koch, Daniel Weber, Lukas Schneider This is a preprint; it has not been peer reviewed by a journal. https://doi.org/ 10.21203/rs.3.rs-8992030/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 LLMs often miss subtle security conditions such as boundary checks and authentication flows. We introduce a static-analysis-driven patch synthesizer that transforms insecure LLM output into correct and safe code. The pipeline uses abstract interpretation to detect violations, followed by SMT-guided repair rules. On 3,200 vulnerable code snippets across five vulnerability categories, our system achieves 74% full automatic repair and 92% partial repair, outperforming Codex and GPT-4 post-processing by a large margin. Developer usability evaluation shows 58% reduction in manual fix time. The method highlights how program analysis can systematically strengthen LLM-based secure coding. Computer Architecture and Engineering Theoretical Computer Science Software Engineering static analysis patch synthesis vulnerability repair SMT solving secure code generation Full Text Additional Declarations The authors declare no competing interests. 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-8992030","acceptedTermsAndConditions":true,"allowDirectSubmit":true,"archivedVersions":[],"articleType":"Research Article","associatedPublications":[],"authors":[{"id":598394249,"identity":"075917a8-9a23-42fb-9a7d-156a8e8e5a9b","order_by":0,"name":"Miriam Koch","email":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAAyAQMAAABI0h/eAAAABlBMVEX///8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAABF0lEQVRIiWNgGAWjYDACZiD+AMQG7M0HYGJsQGyBWwt7AwPjDJAWnmMJIAqmRQK3Fp4DDMwcILUSOQbEaTG4kbz5M0OFXb65RM7XDT93/JEz5z/87MGHCgkGg/MHcGhJKzAuOJNsubPn7babvWcMjC1npJkbzjgD1HIjAYeWHIPkmW0HDAyO5267wdtmkLjhBg+bNG8bSAsuh+UYHOb9B9RyIOfZzb8gLefPQLXgctiZM4bNvA1ALSdy2G6DbTmQA9VyALvDJI+3FTPOOJZsYHDmmNlt2TZjY6DvzCSBfuGRxOEXvsPMmz98qLED+qX52c23bXJyBucPP5P4UGEjx4fDYQzQqMAEPLjU49YyCkbBKBgFowAGACkbZjPovc7gAAAAAElFTkSuQmCC","orcid":"","institution":"Department of Computer Science, Technical University of Munich, Munich 80333, Germany","correspondingAuthor":true,"prefix":"","firstName":"Miriam","middleName":"","lastName":"Koch","suffix":""},{"id":598394250,"identity":"c3cf05a7-ebe9-488b-b4b0-b1c1ea532c56","order_by":1,"name":"Daniel Weber","email":"","orcid":"","institution":"","correspondingAuthor":false,"prefix":"","firstName":"Daniel","middleName":"","lastName":"Weber","suffix":""},{"id":598394251,"identity":"4eb1b44b-45c2-4425-94f2-752bdec7dec9","order_by":2,"name":"Lukas Schneider","email":"","orcid":"","institution":"","correspondingAuthor":false,"prefix":"","firstName":"Lukas","middleName":"","lastName":"Schneider","suffix":""}],"badges":[],"createdAt":"2026-02-28 02:18:16","currentVersionCode":1,"declarations":{"humanSubjects":false,"vertebrateSubjects":false,"conflictsOfInterestStatement":false,"humanSubjectEthicalGuidelines":false,"humanSubjectConsent":false,"humanSubjectClinicalTrial":false,"humanSubjectCaseReport":false,"vertebrateSubjectEthicalGuidelines":false},"doi":"10.21203/rs.3.rs-8992030/v1","doiUrl":"https://doi.org/10.21203/rs.3.rs-8992030/v1","draftVersion":[],"editorialEvents":[],"editorialNote":"","failedWorkflow":false,"files":[{"id":104401403,"identity":"6416d531-fadd-45bd-8618-63bade697a82","added_by":"auto","created_at":"2026-03-11 12:12:37","extension":"pdf","order_by":1,"title":"","display":"","copyAsset":false,"role":"manuscript-pdf","size":382271,"visible":true,"origin":"","legend":"","description":"","filename":"12.8weihengbai15StaticAnalysisGuidedPatchSynthesisforCorrectingLLMGeneratedInsecureCode.pdf","url":"https://assets-eu.researchsquare.com/files/rs-8992030/v1_covered_f1575140-1c70-42fd-b3fc-4e0f7f0f15c9.pdf"}],"financialInterests":"The authors declare no competing interests.","formattedTitle":"\u003cp\u003e\u003cstrong\u003eStatic Analysis-Guided Patch Synthesis for Correcting LLM-Generated Insecure Code\u003c/strong\u003e\u003c/p\u003e","fulltext":[],"fulltextSource":"","fullText":"","funders":[],"hasAdminPriorityOnWorkflow":false,"hasManuscriptDocX":false,"hasOptedInToPreprint":true,"hasPassedJournalQc":"","hasAnyPriority":true,"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":"static analysis, patch synthesis, vulnerability repair, SMT solving, secure code generation","lastPublishedDoi":"10.21203/rs.3.rs-8992030/v1","lastPublishedDoiUrl":"https://doi.org/10.21203/rs.3.rs-8992030/v1","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"},"manuscriptAbstract":"\u003cp\u003eLLMs often miss subtle security conditions such as boundary checks and authentication flows. We introduce a static-analysis-driven patch synthesizer that transforms insecure LLM output into correct and safe code. The pipeline uses abstract interpretation to detect violations, followed by SMT-guided repair rules. On 3,200 vulnerable code snippets\u0026nbsp;across five vulnerability categories, our system achieves 74% full automatic repair\u0026nbsp;and 92% partial repair, outperforming Codex and GPT-4 post-processing by a large margin. Developer usability evaluation shows 58% reduction in manual fix time. The method highlights how program analysis can systematically strengthen LLM-based secure coding.\u003c/p\u003e","manuscriptTitle":"Static Analysis-Guided Patch Synthesis for Correcting LLM-Generated Insecure Code","msid":"","msnumber":"","nonDraftVersions":[{"code":1,"date":"2026-03-03 18:05:36","doi":"10.21203/rs.3.rs-8992030/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":"97953c8f-7238-4c09-a38a-51404b48382e","owner":[],"postedDate":"March 3rd, 2026","published":true,"recentEditorialEvents":[],"rejectedJournal":[],"revision":"","amendment":"","status":"posted","subjectAreas":[{"id":63682709,"name":"Computer Architecture and Engineering"},{"id":63682710,"name":"Theoretical Computer Science"},{"id":63682711,"name":"Software Engineering"}],"tags":[],"updatedAt":"2026-03-03T18:05:36+00:00","versionOfRecord":[],"versionCreatedAt":"2026-03-03 18:05:36","video":"","vorDoi":"","vorDoiUrl":"","workflowStages":[]},"version":"v1","identity":"rs-8992030","journalConfig":"researchsquare"},"__N_SSP":true},"page":"/article/[identity]/[[...version]]","query":{"redirect":"/article/rs-8992030","identity":"rs-8992030","version":["v1"]},"buildId":"XKTyCvWXoU3ODBz1xrDgd","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 (2026) — 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