What the model is shown decides what it copies

Before a coding assistant writes anything, something assembles the repository context it will read. A paper posted to arXiv on 4 November by Jiongchi Yu and seven co-authors argues that this assembly step, built almost entirely for functional correctness, is quietly deciding whether generated code is secure.

The argument rests on a new benchmark, CASE-Bench: 145 repository-level tasks drawn from real CVEs across 51 projects. Each task runs in Docker, has functional tests and a proof-of-concept exploit validated in both directions, and is annotated with the repository code that either enforces or undermines its security. That annotation is what makes the experiment possible — the authors can add or withhold a specific safeguard and watch what the model does.

A padlock on a metal gate
Withholding a safeguard cut the secure pass rate by up to 8.1 points. Illustration photo. David McElwee · pexels · Pexels License

Three findings

The team compared 13 context construction methods and six controls across six language models.

Functionality-oriented context raised the functional pass rate by up to 8.2 percentage points — and the secure pass rate by at most 3.7. Context engineering, in other words, buys roughly twice as much correctness as security.

Withholding a safeguard lowered the secure pass rate by up to 8.1 points. Inserting a single insecure exemplar raised correct-but-exploitable code by 6.3 points. One bad example in the context window costs more than most of the retrieval improvements gain.

The third result is the one that reframes the other two: across coding-agent trajectories, the agent actually observed the relevant safeguard in only 27% to 36% of runs. For roughly two thirds of the tasks, the authorisation check or validation routine that would have told the model what the project already does was never in front of it.

Why secure-code benchmarks have missed this

The paper’s methodological point is that existing secure-code benchmarks hold the context fixed and vary the model. That design measures a model’s security behaviour given perfect information, which is not the condition under which any real assistant operates.

By varying the context instead, CASE-Bench measures something closer to the deployed system: an agent that has to find the safeguard before it can imitate it, inside a repository large enough that finding it is not guaranteed.

A library of bound reference volumes on shelves
Agents found the relevant safeguard in roughly a third of their runs. Illustration photo. T6 Adventures · pexels · Pexels License

What it does not settle

The benchmark is built from known CVEs, which means every task has a documented flaw and a documented fix. That is what makes grading possible, and it also means the results say nothing about novel vulnerability classes a model might introduce where no prior fix exists.

The six models are not named in the abstract, and the figures are percentage-point movements on a benchmark the authors built, not absolute security guarantees.

What to watch

Whether retrieval systems start being scored on whether they surface safeguards. The paper’s practical implication is that a context builder tuned only for passing tests is leaving a measurable amount of security on the table, and that the fix is a retrieval question rather than a model question. The 27%-to-36% observation rate is the number to improve on.