SPARK: Security Knowledge Priming and Representation-Guided Knowledge Activation for LLM-based Secure Code Generation

22d ago · Global · primary source: export.arxiv.org

A new inference-time method called SPARK aims to reduce security flaws in code generated by large language models without requiring retraining, according to a paper posted to arXiv on June 15 [1][2]. The approach activates what the researchers describe as latent security knowledge already present in pretraining corpora [2]. Large language models routinely produce code with exploitable security vulnerabilities, a problem prior work has addressed through computationally expensive fine-tuning or external knowledge retrieval [2]. The authors of the SPARK paper argue that the core issue is not a lack of security expertise in the models but a failure to activate it. “Without an explicit and brief cue, statistical pressure toward common training-distribution patterns suppresses the model’s safety-relevant representations,” they write [2]. SPARK consists of two components. The first retrieves relevant Common Weakness Enumeration (CWE) entries for a given coding task and appends a short structured cue to the prompt [2]. The second adds a precomputed token bias to the logits at every decoding step, derived by projecting a safe-direction vector through the language model head [2]. The bias is computed once offline and costs a single vector addition per generated token [2]. The researchers evaluated SPARK on 9 open-source models across C++, Java, and Python, comparing it with 7 baselines that span fine-tuning and retrieval-augmented methods [2]. SPARK matched or improved on the best baseline in every setting while preserving performance on the HumanEval benchmark [2]. In a black-box setting, Component I was tested on 7 of the strongest current models, including Claude, DeepSeek, and GPT, demonstrating the bottleneck of insecure code generation and the improvements enabled by the method [2]. The paper was submitted to the Cryptography and Security section of arXiv, an open-access repository that hosts electronic preprints across mathematics, physics, computer science, and other fields [6]. As of November 2024, arXiv receives roughly 24,000 new articles per month [6].

controversymodel-releaseresearch-paperbenchmarkinfrastructureapplicationtool-release

Background sources we checked (7)
  • arxiv.org ↗ Large language models routinely generate code with exploitable security flaws. Prior literature attributes this limitation to a lack of security expertise, steering current defense mechanisms toward heavy fine-tuning or external knowledge retrieval, which introduces significant c…
  • info.arxiv.org ↗ arXiv Labs - arXiv info | arXiv e-print repository Skip to content # arXiv Labs Attention arXiv Users: arXiv Labs is pausing new proposals ## What are arXiv Labs? arXiv Labs are a way for the community to contribute new, useful features to arXiv. These integrations are avail…
  • blog.arxiv.org ↗ arXivLabs: a space for community innovation – arXiv blog arXiv has launched a new, formalized framework enabling innovative collaborations with individuals and organizations. “Members of our community want to contribute tools that enhance the arXiv experience, and we val…
  • info.arxiv.org ↗ arXivLabs: Showcase - arXiv info | arXiv e-print repository ... # arXivLabs: Showcase ... arXiv is surrounded by a community of researchers and developers working at the cutting edge of information science and technology. ... While the arXiv team is focused on our core mission—pr…
  • en.wikipedia.org ↗ arXiv (pronounced as "archive"—the X represents the Greek letter chi ⟨χ⟩) is an open-access repository of electronic preprints and postprints (known as e-prints) approved for posting after moderation, but not peer reviewed. It consists of scientific papers in the fields of mathem…
  • en.wikipedia.org ↗ 14 (fourteen) is the natural number following 13 and preceding 15.…
  • en.wikipedia.org ↗ A large language model (LLM) is a type of machine learning model designed for natural language processing tasks such as language generation. LLMs are language models with many parameters, and are trained with self-supervised learning on a vast amount of text.…

Sources

Spot something wrong? Report an issue