arXiv:2609.05903cs.CRSep 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2609.05903

EvoSafeHarness: Evolving Model- and Domain-Specific Harnesses for Securing Agents

Nanxi Li, Yingzi Ma, Yulong Cao, Edward Suh, Bo Li, Dawn Song, Chaowei Xiao

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Nanxi Li¹ Yingzi Ma² Yulong Cao³ Edward Suh³ Bo Li⁴ Dawn Song⁵ Chaowei Xiao¹,³

¹Johns Hopkins University ²University of Wisconsin–Madison ³NVIDIA

⁴University of Illinois Urbana–Champaign ⁵UC Berkeley

Figure

Figure 1. EvoSafeHarness dominates the utility–security trade-off on all four benchmarks. Each panel plots utility against safe rate (100 – ASR), so higher is better on both axes and the ideal defense sits in the top-right corner. Large markers show cross-model method averages and small dots show individual evaluation cells (model×domain cells on DecodingTrust-Agent, victim models elsewhere). The Agent-SafetyBench panel reports utility under attack; the AgentDojo panel reports held-out test results and the AgentDyn panel zero-shot transfer of the AgentDojo harness.

ABSTRACT

Large Language Model (LLM) Agents are turning language into real-world effects. They should remain safe against both indirect prompt injections and direct harmful requests. System-level safety harnesses provide an additional enforcement layer in addition to model-level solutions, but existing harness designs are typically built once by experts and applied across heterogeneous models and domains. The effective defense is inherently deployment-dependent: models differ in how much external enforcement they need before utility starts to drop, while domains differ in which effects, state, and action sequences must be governed. A harness strict enough for one model over-blocks another, and a policy general enough to transfer across domains can miss the safety relations of the application.

We present EvoSafeHarness, a safety-specific harness optimization framework that automatically synthesizes a deployable harness for a frozen model in a target domain. Unlike existing harness generation frameworks that target utility alone, it jointly searches a natural-language policy and executable code logic, guided by behavioral feedback from the target model and by a domain specification, and screens each candidate with a fresh-context adversarial review that rejects rules keyed to benchmark artifacts. Across four agent benchmark families, EvoSafeHarness establishes a stronger safety–utility frontier than fixed expert-designed defenses. On DecodingTrust-Agent, across fifteen independently searched model×domain deployments, it reduces average attack success rate (ASR) from 45.6% to 10.0% at a 3.3-point utility cost, the best score in 14 of 15 cells. On AgentDojo it reaches 82.8% utility at 0.0% ASR, twice the utility of CaMeL at the same zero-ASR operating point, and the same harness transfers unchanged to unseen AgentDyn suites. It also attains the best score on Agent-SafetyBench for every victim and keeps mean ASR below 20% under adaptive PAIR attacks with a refinement budget of 16. Analysis of the synthesized harnesses shows that domain semantics shape which safety relations and trajectory state are required, while model and runtime behavior shape how and where those relations are enforced, supporting harnesses optimized for the deployment at hand rather than a single universal design.

github.com/SaFo-Lab/EvoSafeHarness

andylinx.github.io/EvoSafeHarness

EvoSafeHarness

arXiv preprint • 1

1 Introduction

1 Introduction

Language-model agents are moving from demonstration to deployment. As they gain access to sensitive data, financial accounts, production systems, and external services, safety becomes an operational requirement. A chatbot failure may end in an undesirable response; an agent failure can result in a transferred payment, a leaked credential, deleted production data, or a persistent shell process. The unit of safety has expanded from a single utterance to an entire action trajectory, and the consequences of failure have expanded with it.

What makes agent safety qualitatively harder is that harmful instructions can enter through two channels that cross different security boundaries. In an indirect prompt injection attack [Greshake et al., 2023, Liu et al., 2024, Perez and Ribeiro, 2022], an adversary embeds instructions in external content—such as an email, a web page, or a document—that the agent must consume as data. If the agent treats this content as authoritative, it may execute actions that the user never requested. In a direct attack [Chen et al., 2026, Andriushchenko et al., 2025, Zhang et al., 2024], the harmful instruction instead arrives through the nominal user channel itself: a malicious user may ask the agent to transfer funds beyond an approved limit, delete production data, or disclose protected credentials.

To address these risks, model-level defenses have been proposed and remain essential [Wallace et al., 2024, Chen et al., 2025a,b]. These methods improve the model's ability to distinguish trusted instructions from untrusted content or to learn to refuse unsafe requests. However, model-level defenses can make policy-compliant behavior more likely, but they do not by themselves provide a system-level enforcement boundary that is independent of model behavior. This limitation has motivated system-level defenses implemented in the harness level. Existing approaches use mechanisms such as provenance marking, injection detection, trajectory validation, capability enforcement, and lifecycle-level execution control [Hines et al., 2024, Inan et al., 2023, Li et al., 2025, Debenedetti et al., 2025, Lin et al., 2026c], demonstrating that the harness is an effective locus of agent security. However, these methods generally instantiate a fixed, expert-designed defense whose policy and control flow are the same across heterogeneous models and domains (Figure 2A). This leaves an open question: can a universal harness provide the best safety–utility trade-off across deployments, or should the harness be adapted to the target model and domain?

Building a universal harness that remains both safe and useful across models and applications is challenging because these two sources of variation affect different aspects of harness design. Model variation changes the appropriate strength of enforcement. A strongly safety-trained model such as Claude Opus may already resist many of the attacks that an external harness is intended to block; as shown in Figure 1, imposing a strict capability-based defense such as CaMeL [Debenedetti et al., 2025] can preserve strong security while substantially reducing benign utility. The same restrictions may nevertheless be essential for a model that is more susceptible to adversarial instructions. The marginal security benefit and utility cost of a harness are model-dependent, so a configuration that achieves a favorable safety–utility trade-off for one model need not do so for another. Application domain variation goes beyond enforcement strength: it changes the safety relations and control flow that the harness must implement. This is particularly clear for direct attacks, where the request arrives through the user channel and its harmfulness must be determined from the semantics of the requested effect. A filesystem harness may need to inspect command effects, sensitive paths, secret movement, and subsequent data flow. A finance harness, by contrast, must distinguish trades from money egress, enforce destination constraints, and maintain transaction history because a sequence of individually permissible trades may collectively constitute wash trading. Command and path filters cannot capture these financial relations, while a transaction ledger provides no protection against filesystem threats such as persistence or secret exfiltration. Model variation changes how strongly a harness should intervene, whereas domain variation changes its predicates, state, routing logic, and enforcement points; a single fixed design is unlikely to provide the best safety–utility trade-off across both.

This heterogeneity makes automated harness engineering an appealing next step. Meta-Harness [Lee et al., 2026] demonstrates that an agentic proposer can iteratively search harness code using behavioral feedback from the target model while inspecting candidate source code, evaluation scores, and execution traces from previous iterations. The same behavioral signals can expose model-specific security failures, but applying the paradigm to security is not as simple as replacing an ordinary task reward with attack success. Doing so creates three dangerous shortcuts. First, a harness can appear safe by refusing everything, converting security into utility collapse. Second, it can overfit to superficial artifacts in the evaluation set, such as filenames, paths, or recurring

1 Introduction

Figure

Figure 2. From the limits of fixed defenses to our model- and domain-specific EvoSafeHarness. (A) Existing fixed harnesses fail across models and domains: utility collapses on one victim, risk persists on another, and no single policy fits every domain. (B) EvoSafeHarness instead automatically designs a distinct combination of natural-language policy and executable code logic for every model×domain deployment. (C) With the domain fixed, model behavior determines how the same security relation is enforced; each model's searched harness beats CaMeL on both utility and ASR. (D) With the model fixed, domain semantics determine which relations and state must be protected, and each domain's searched harness again dominates.

attack phrases, and thereby obtain improvements that disappear under trivial renaming or paraphrasing. Third, because synthesized harness code is itself part of the enforcement mechanism, an error that skips a check or fails open can create an untested path for unsafe tool execution. Beyond these three failure modes, a scalar reward provides poor diagnostic feedback: it does not reveal whether a failure arose from a direct harmful request or an indirect injection, nor what kind of control should be revised. Safety harness synthesis needs a search procedure designed to preserve utility, test generalization, respect an explicit trust boundary, and return attack-specific evidence rather than only a scalar reward.

To meet these requirements, we present EvoSafeHarness, a safety-specific meta-harness that optimizes a deployable harness HH around a frozen model MM in a target domain DD (Figure 3). Each search is conditioned on a domain specification that defines the deployment contract. Within this contract, four components form a closed optimization loop: a Designer proposes a natural-language policy together with executable code logic; a fresh-

1 Introduction

Figure

Figure 3. EvoSafeHarness searches a deployment-specific security harness. Given a frozen model MM, a target domain DD, and existing defenses as a warm start, the Designer drafts a candidate harness H=(P,C)H = (P, C), a natural-language policy PP paired with executable code logic CC, and iterates with a fresh-context Criticizer that stress-tests each proposal. Survivors enter the Cascade Test Environment, which runs cheap-to-expensive stages and separately measures benign utility and direct/indirect ASR. The Analyzer distills failed traces into experience that seeds the next iteration.

context Criticizer reviews the proposal; a Cascade Test Environment executes and scores surviving candidates; and an Analyzer returns decomposed scores and failure traces to the Designer for the next revision. These components are designed to address the preceding failure modes directly. Separate benign evaluation prevents a refuse-all candidate from presenting zero attack success as an unqualified improvement. The generalization requirements in the domain specification, together with independent Criticizer review, screen out rules keyed to benchmark-specific artifacts. Finally, the Cascade Test Environment and Analyzer preserve benign, direct-attack, and indirect-attack outcomes as separate feedback channels, allowing the Designer to revise the policy or executable code logic in response to the specific failure observed. EvoSafeHarness thereby turns a general reward-driven code search into a constrained, adversarially validated procedure for generating model- and domain-specific safety harnesses.

We evaluate EvoSafeHarness on four agent benchmark families spanning both attack channels, and it improves the safety–utility trade-off on all of them (Figure 1). On DecodingTrust-Agent, our primary benchmark, fifteen independently searched model×domain harnesses cut average ASR from 45.6% to 10.0% at a 3.3-point utility cost and obtain the best score in 14 of 15 cells, whereas the fixed defenses CaMeL, DRIFT, and Progent either leave ASR above 37% or sacrifice more than 20 utility points (Table 1). On Agent-SafetyBench, whose harms include unsafe user requests and misinformation that never surface as a tool call, the searched harness has the lowest unsafe-behaviour rate and the best score for every victim (Table 2). On AgentDojo it reaches 82.8% utility at 0.0% ASR, twice the utility of CaMeL at the same zero-ASR operating point, and the same harness transfers unchanged to unseen AgentDyn suites at 75.0% utility and 0.0% ASR (Table 2). Finally, a frozen harness keeps mean ASR below 20% against three adaptive PAIR attackers with a refinement budget of 16 (§6.3), and controlled ablations show that the security warm start, the fresh-context Criticizer, and the nested cascade each contribute measurably (§7.5).

The returned harnesses clarify why deployment-specific design produces these gains. Figure 2C holds the request, attack, and os-filesystem domain fixed and varies only the victim model. Sonnet 4.6 reaches zero held-out ASR with a lightweight policy and two semantic checks, whereas GLM-5 benefits from deterministic gates, provenance state, and verdict caching. A weaker model does not just need more rules. Model and runtime behavior determine whether the same safety relation should be enforced semantically or deterministically, with or without state, and at which point in execution. Figure 2D instead holds GLM-5 fixed and varies the domain. Filesystem safety depends on command effects, sensitive paths, and data flow, whereas finance must distinguish trades from money egress and retain transaction history because individually permissible actions can form a harmful sequence. Domain adaptation decides which safety relations and state must be protected, while model adaptation determines how to enforce them without unnecessary utility loss.

3 Problem Formulation