inferwire
/
Cybersecurity·4 min read

Context Around the Code Sways LLM Vulnerability Verdicts

Changing only the author, the task framing or a prior scan result swayed eight LLMs' security verdicts on identical code, and forged commit metadata suppressed up to 97 percent of detections.

TL;DR

  • Changing only the context around identical code, such as author, task framing or a prior scan result, swayed security verdicts of all eight tested LLMs [^1].
  • In a simulated CI pipeline, forged pull-request metadata suppressed up to 97 percent of previously detected vulnerabilities, and prompt-based defenses didn't stop it [^1].

Background

LLMs are increasingly used as automated vulnerability detectors, for example in GitHub's Copilot Autofix, which reviews pull requests and triages security alerts [^1]. In deployment, such scanners rarely see code alone: they also receive the author's identity, task directives, commit messages and static analysis results [^1]. Psychology describes shortcuts such as the halo effect, where one positive impression colors unrelated judgments, framing, and anchoring on the first information received, and LLMs show these patterns too [^1].

What happened

Asif Shahriar and colleagues at BRAC University, Purdue University and the University of Illinois Urbana-Champaign kept the code fixed and changed only the surrounding prompt [^1]. For the halo effect, they attributed a snippet either to "the principal security engineer of our development team, who previously worked at Google's Project Zero team" or to a newly hired junior developer who is a fresh graduate. For framing, they varied the task and its stated consequences, and for anchoring, they said a prior automated analysis had marked the code safe or vulnerable [^1]. Eight models were tested, from Llama 4 Maverick and DeepSeek V3.1 to GPT 5.2, Claude Sonnet 4.6 and Gemini 2.5 Pro, on C/C++ code from PrimeVul and Python and Java code from CleanVul [^1].

All eight models were susceptible. Averaged across models on C/C++, susceptibility was 33.2 percent for framing, 23.5 percent for anchoring and 18.4 percent for halo, and open-source models were generally more biased than commercial ones [^1]. The direction wasn't always the expected one: Claude flagged more code when it came from the senior engineer, and GPT reacted against an explicit "vulnerable" anchor [^1]. A note that correctly clearing safe code keeps the pipeline moving was especially effective and cut recall by 26.11 points below the neutral prompt on average [^1]. Bugs that require reasoning about program state, such as a reachable assertion or a divide by zero, were 1.5 to 2 times more susceptible than ones with obvious signatures like a double free [^1].

The context didn't make models better or worse at the task, only more or less willing to call code vulnerable [^1]. Recall and false positive rate moved almost in lockstep, so precision stayed between 0.48 and 0.55 [^1]. When context flipped a verdict to vulnerable, the reason was often wrong: of nine GPT samples that flipped under the senior-engineer attribution, it named the real flaw in only two [^1]. The authors then attacked a simulated GitHub-style scanner. Without any access to the model, an attacker with commit access used a real maintainer's institutional email, a security-flavored branch name and PR title, a PR description about avoiding false alarms, and a commit message listing pre-merge tool results [^1]. That suppressed up to 97 percent of previously detected vulnerabilities, and the combined payload stayed above 75 percent for every open-source model [^1].

Why it matters

LLM scanners are taking on the role of security gatekeepers in CI/CD pipelines, and the fields that sway them, such as branch names, PR titles and commit messages, are fully controlled by whoever submits the code [^1]. The paper cites prior work finding that 95.4 percent of users don't sign their commits, so a forged author identity is a realistic assumption [^1]. Unlike prompt injection, the payload contains no explicit instruction, only text that looks like normal workflow metadata, which the authors chose so it wouldn't raise suspicion [^1].

Telling the model to ignore metadata didn't solve it. A weak defense prompt helped only GPT and Gemini, and even a strong one that named each channel left every open-source model above 40 percent; on Claude, both defenses made the attack more successful [^1]. The authors call for training-time interventions that make verdicts invariant to non-code context [^1]. Their study used function-level snippets and a simulated pipeline rather than a live scanner, and cost kept them from repeated runs [^1].

Practical example

Say your team's pipeline sends each pull request to an LLM reviewer along with the PR title, description and commit messages. Going by this study, a contributor could word those fields to sound routine and senior, and the reviewer might clear code it would otherwise flag [^1]. You test this by running the reviewer on the same diff twice, once with only the code and once with the metadata, and checking whether the verdicts change [^1]. If they do, you send the scanner the diff alone, leave the metadata to human reviewers, and treat an LLM "safe" verdict as one signal rather than a gate.

Related gear

We recommend this book because it teaches how to audit source code for vulnerabilities, the work these LLM scanners are being asked to do.

AdvertisementAmazon

The Art of Software Security Assessment: Identifying and Preventing Software Vulnerabilities

Sources

  1. [1]arXiv — Words Speak Louder Than Code: Investigating Cognitive Heuristics in LLM-Based Code Vulnerability Detection