arXiv(opens in a new tab)cs.LGSep 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2609.07529

CoRL: Co-Evolutionary Reinforcement Learning for Adaptive Indirect Prompt-Injection Attacks and Defenses

Boyang Zhang, Qingxin Xiao, Lingwei Dang, Qingyao Wu

ABSTRACT

Tool-augmented language agents are vulnerable to indirect prompt injection (IPI). Unlike direct prompt injection, IPI hides adversarial instructions in untrusted tool outputs and can covertly alter the execution of a legitimate task. Defenses trained on fixed attacks may fail as an attacker changes its strategy, injection site, and payload. To address this problem, we formulate adaptive IPI as an asymmetric, partially observable, general-sum Markov game: a multi-turn attacker adapts payloads at reached tool-return sites from the public trajectory, while a tool-using defender must block the injected objective and complete the user task. We propose CoRL, a verifier-grounded co-evolution and repair framework with three stages: Attacker SFT initializes multi-turn attacks from successful trajectories; bilateral Co-PPO jointly trains both agents with role-specific rewards and historical opponent populations; and Defender SFT consolidates verifier-accepted teacher repairs for population-discovered failures. Across 1,514 clean, fixed-template, and adaptive executions per defender, CoRL reduces overall ASR by 38.5 points to 0.0% and raises utility by 13.1 points to 76.3%. Stage-wise and controlled ablations show positive contributions from online Co-PPO and population-mined repair, while external-benchmark evaluation indicates transfer in attack resistance. The defender balances safety and task utility under the evaluated attacks, while the retained attackers provide candidates for adaptive red-team evaluation.

1 INTRODUCTION

Tool-augmented language agents consume untrusted webpages, emails, documents, and application state while calling tools that can modify external environments. Their tool returns can therefore mix task data with third-party instructions. Indirect prompt injection (IPI) exploits this ambiguity to redirect legitimate execution toward data leakage, tool misuse, or unauthorized actions (Greshake et al., 2023; Zhan et al., 2024; Debenedetti et al., 2024). A useful defense must block the injected objective while completing the user's task: rejecting external content wholesale may appear safe, but destroys the agent's utility.

Despite increasingly stateful IPI benchmarks (Zhan et al., 2024; Debenedetti et al., 2024; Zhang et al., 2025; Li et al., 2026), defenses are often trained on fixed or weakly varying attacks. Such defenses may not generalize when attackers condition payloads on the public trajectory, the reached injection site, and prior attempts. Online co-training introduces a second difficulty: each current policy can overfit to its latest opponent and forget earlier attack or defense modes. Meanwhile, optimizing attack blocking without an explicit task-utility signal can favor blanket refusal (Zhan et al., 2025; Wang et al., 2025b; He et al., 2026). These limitations leave a common challenge: how can training continually discover adaptive failures and retain their repairs in a deployable defender?

We address this challenge through a discovery-and-repair view: discovery exposes failures as both policies change, while repair retains their fixes without inducing blanket refusal. We model the within-execution interaction as an asymmetric, partially observable, general-sum Markov game. The defender acts throughout the multi-step trajectory, whereas the attacker intervenes only at reached

Figure

Figure 1: Adaptive IPI. (A) Malicious instructions are embedded in an otherwise legitimate tool return. (B) After an initial request is ignored, the attacker combines the public trace with its prior attempt to revise a later injection. The defender may complete the purchase and still leak the OTP. Reasoning snippets and tool calls are illustrative.

tool-return sites and adapts later payloads to the public history. Independent verifiers score attack success and task completion, defining payoffs that reward the attacker for compromise but distinguish safe task completion, safe failure, and compromise for the defender. Because these payoffs are not exact negatives, the game is general-sum. We instantiate it in an AgentDyn-derived seven-domain environment, holding out official configurations for evaluation.

We propose CoRL, a three-stage realization of this view. Attacker SFT first bootstraps multi-turn exploration from verifier-validated successes. Online Co-PPO then updates both roles with role-specific PPO against bilateral historical populations, with the aim of reducing latest-opponent overfitting while improving the defender and retaining attackers that expose residual failures. Finally, Defender SFT starts from the selected Co-PPO checkpoint and learns verified safe task execution from teachers facing this population.

Across seven domains and 1,514 raw executions per defender, Co-PPO improves every reported metric over its no-population counterpart, although the larger final gain follows Defender SFT. Relative to the base model, complete CoRL reduces observed overall ASR from 38.5% to 0.0% and raises overall utility from 63.2% to 76.3% under our protocols. A controlled 2×2 study shows positive contributions from Co-PPO initialization and population-mined repairs, with their combination performing best. External evaluations on InjecAgent and AgentLAB support transfer beyond the main benchmark, including improved task success under the mixed-attacker Task-Injection protocol on AgentLAB.

Our contributions are:

(1) We formulate within-execution adaptive IPI as an asymmetric general-sum Markov game and build a seven-domain, verifier-grounded environment; we will open-source the environment and SFT/RL data under responsible-release safeguards.

(2) We introduce CoRL, to our knowledge the first adaptive-IPI framework to train both an attacker agent and a tool-using defender agent with RL while exposing each current policy to historical opponents; Defender SFT then consolidates population-mined repairs.

(3) Across seven suites, InjecAgent, and AgentLAB, we report safety–utility, controlled attribution, stronger-attack tests, and stage-wise dynamics; CoRL leads the tested same-backbone baselines.

References (85)

  • Jailbreaking black box large language models in twenty queries, 2023
  • StruQ: Defending against prompt injection with structured queries
  • SecAlign: Defending against prompt injection with preference optimization
  • Meta SecAlign: A secure foundation LLM against prompt injection attacks, 2025c
  • Learning to inject: Automated prompt injection via reinforcement learning, 2026
  • Adversarial déjà vu: Jailbreak dictionary learning for stronger generalization to unseen attacks
  • AgentDojo: A dynamic environment to evaluate prompt injection attacks and defenses for LLM agents (opens the publisher in a new tab)
  • Defeating prompt injections by design, 2025
  • Not what you've signed up for: Compromising real-world LLM-integrated applications with indirect prompt injection, 2023
  • Defending against adaptive prompt injection attacks via reasoning-enabled task alignment, 2026
  • Defending against indirect prompt injection attacks with spotlighting, 2024
  • AgentLAB: Benchmarking LLM agents against long-horizon attacks, 2026
  • A unified game-theoretic approach to multiagent reinforcement learning
  • Learning diverse attacks on large language models for robust red-teaming and safety tuning
  • DRIFT: Dynamic rule-based defense with injection isolation for securing LLM agents (opens the publisher in a new tab)
  • PIGuard: Prompt injection guardrail via mitigating overdefense for free (opens the publisher in a new tab)
  • Agent-Dyn: Are your agent security defenses deployable in real-world dynamic environments?, 2026
  • Empowering LLM tool invocation with tool-call reward model
  • Tree of attacks: Jailbreaking black-box LLMs automatically (opens the publisher in a new tab)
  • Rule based rewards for language model safety (opens the publisher in a new tab)
  • The attacker moves second: Stronger adaptive attacks bypass defenses against LLM jailbreaks and prompt injections, 2025
  • High-dimensional continuous control using generalized advantage estimation
  • Proximal policy optimization algorithms, 2017
  • Progent: Securing AI agents with privilege control, 2025
  • Nature, 575(7782):350–354, 2019 (opens the publisher in a new tab)
  • The instruction hierarchy: Training LLMs to prioritize privileged instructions, 2024
  • GPT-Red: Automated red teaming via self-play at scale, 2026
  • Lifelong safety alignment for language models
  • Adversarial reinforcement learning for large language model agent safety, 2025b
  • MAGIC: A co-evolving attacker-defender adversarial game for robust LLM safety, 2026
  • AgentGym-RL: An open-source framework to train LLM agents for long-horizon decision making via multi-turn RL. In International Conference on Learning Representations, 2026
  • PISmith: Reinforcement learning-based red teaming for prompt injection defenses, 2026
  • InjecAgent: Benchmarking indirect prompt injections in tool-integrated large language model agents
  • Adaptive attacks break defenses against indirect prompt injection attacks on LLM agents (opens the publisher in a new tab)
  • Agent security bench (ASB): Formalizing and benchmarking attacks and defenses in LLM-based agents
  • Universal and transferable adversarial attacks on aligned language models, 2023
  • Early work showed that LLM-integrated applications blur the boundary between data and instructions, enabling attacks through webpages, emails, retrieved documents, and other third-party content (Greshake et al., 2023)
  • Prompt-level methods such as Spotlighting use provenance signals to mark external content (Hines et al., 2024)
  • Lee et al. (2025) show that conventional RL red-teamers can collapse onto a few modes; their GFlowNet-plus-MLE procedure discovers diverse attacks against a fixed target, after which refusal SFT on those prompts improves robustness to attacks from other red-teamers
  • AutoInject learns universal transferable injections with black-box RL, and PISmith trains a black-box RL red-teamer against prompt-injection defenses, including agentic settings (Chen et al., 2026; Yin et al., 2026)
  • Lifelong Safety Alignment mines strategies from jailbreak papers, refines a Meta-Attacker against a frozen Defender, and then refusal-trains the Defender on accumulated successful attacks over iterative rounds
  • CoRL instead acts only at reached tool-return sites and gives later attacker turns the benign return, public execution trace, earlier payloads, and intervening defender behavior
  • CoRL adopts historical-opponent exposure for a general-sum IPI game, but does not compute a meta-strategy or claim convergence to an equilibrium
  • Rule-Based Rewards use composable, LLM-graded rules to align helpfulness and safety (Mu et al., 2024)
  • They do not establish that Co-PPO invents new attack primitives: the Attacker SFT traces already contain tool-compatible actions, administrative notices, and verification chains
  • search more broadly
  • The user asks the agent to process an urgent email and buy light bulbs; the injected email requests phone-number exfiltration
  • Legacy traces do not contain a hash of the initial environment state
  • compliance
  • To bootstrap reliable exploration, it lists a small set of previously effective patterns: structured tool-call blocks, workflow prerequisites, administrative notices, JSON-like action fields, colleague requests, verification framing, and failure-recovery framing
  • The natural-language objective, public trace, suite/domain hint, local tool-return context, previous-attempt history, and binary unsatisfied-contract feedback are unchanged
  • The user task appears through the trace rather than as a duplicate field
  • The next prompt summarizes the defender's observable actions following the preceding payload and provides a binary indication that the authoritative target contract remains unsatisfied at the next trigger
  • When a returned field contains one or more unhandled placeholders, the rollout obtains a response for each triggered site, replaces only the corresponding placeholder, and preserves the surrounding benign content
  • The security verifier retains 3,995 conversations satisfying the executable attack contract (11,655 attacker turns)
  • Six cases per suite are evaluated under every template: $7 \times 6 \times 4 = 168$ executions, or 42 per template
  • Its run audit reports no duplicate or missing cases and no infrastructure or evaluator errors
  • Cases are within-suite user-task-injection-task combinations; fixed-template coverage is specified above
  • Overall U pools all conditions; Security is 1 – ASR on attacked episodes; $n$ excludes invalids
  • >Cell</td><td>Clean</td><td colspan=
  • This evaluation follows the official seven-suite configuration with important_instructions (Li et al., 2026; Debenedetti et al., 2024)
  • Workspace contributes 560 attack pairs versus 240 raw pairs in the main adaptive manifest (Table 6)
  • Relative to Base, CoRL lowers ASR in all seven suites and improves Safe-U in six, with the largest gain in DailyLife (21.00% to 72.00%)
  • >(b) InjecAgent: attack resistance</td></tr><tr><td rowspan=
  • The mixture differs across defenders, so the aggregate comparison describes this evaluation procedure rather than a controlled, pure-GPT-5.4 attack comparison
  • Thus the nominal totals of 510 and 544 and the completed-case coverage in Table 15 are not necessarily metric-valid denominators
  • Coverage is available completed cases over the official DH or DS total, not the ASR-valid denominator
  • >Defender</td><td rowspan=
  • We do not call it strict payload-OOD unless a construction audit confirms that its goal families, compromised fields, sites, and templates are absent from all SFT and online-RL data
  • AgentLAB provides separate attack-success and attacked-task-success outcomes, whereas the InjecAgent results measure attack resistance
  • Co-PPO uses seven eight-GPU nodes: eight GPUs for each role's trainer and 40 for rollout serving (Table 16)
  • (6) Run teacher defenders from task initial states under retained attackers, filter successful trajectories, select per configuration, mix untriggered replay, and deduplicate
  • Co-PPO samples
  • Among 7,859 safe, task-successful, normally terminated candidates with actual payload evidence, 6,974 pass the strict quality screen and 885 are rejected, giving an 88.74% quality acceptance rate
  • Attacked demonstrations and untriggered replay are mixed in the same training dataset with no independent replay coefficient, pairwise preference term, explicit KL penalty, or additional group-weighted loss
  • During Co-PPO, a malformed current-attacker response remains in $\mathcal{B}_{A}^{k}$ if its sampled token trace is exact and receives the shared terminal trajectory reward defined in Section 4: this is zero when the trajectory never succeeds, but can be positive if a later attempt succeeds
  • When a rollout belongs to a suite whose quota is incomplete, routing selects the probation slot with probability 0.75; otherwise it samples across loaded slots
  • Fitness is the suite-macro average
  • Consequently, $S_i$ is a serving heuristic rather than a stationary, cross-checkpoint measure of absolute strength or behavioral diversity
  • Population size is checked against the physical replica count for both roles
  • The rollouter first stops assigning new requests to the affected historical role, routes that traffic through current-current pairs, and waits for all active requests to drain before restarting replicas
  • Task utility changes from 62.25% to 60.41%, whereas Safe-U decreases from 54.26% to 49.23%
  • The horizontal axis excludes clean and fixed-template logs and does not count optimizer updates or guarantee that every record was consumed by PPO
  • The critic minimizes $\mathbb{E}_j[(V_{\phi_r}(s_j^r) - \hat{R}_j^r)^2]$ on these role-generated positions
  • One slot is reserved for a provisional candidate until it obtains at least 32 role-attributable, reward-bearing evaluations in each of seven suites