Penn State researchers Chenlong Yin, Runpeng Geng, Yanting Wang, and Jinyuan Jia built PISmith, a reinforcement learning framework that trains an attack LLM to break prompt injection defenses. The results are brutal. Every major defense tested falls apart under adaptive attack, and the best defenses that retain utility above 70% still let through 82% or more of crafted injections.

The Core Problem

Prompt injection attacks embed malicious instructions into data that LLMs process, like web pages or documents. Defenses exist in two categories. Prevention-based defenses try to make the LLM ignore injected instructions. Filter-based defenses try to detect and block malicious content before it reaches the LLM.

The problem: most defenses are evaluated against static, template-based attacks. When you throw adaptive attacks at them, their reported near-zero attack success rates collapse. PISmith automates this adaptive testing using RL.

How PISmith Works

PISmith trains an attack LLM as a policy that generates injected prompts. It operates in a black-box setting. The attacker can only query the defended LLM and observe its outputs. No access to model internals, no gradient access.

The training uses GRPO (Group Relative Policy Optimization) as a base, but vanilla GRPO fails hard against strong defenses. The reason is reward sparsity. When a defense blocks most attempts, the attack LLM generates rollout after rollout that fails. Two failure modes emerge:

  1. Entropy collapse. The policy overfits to the rare successful prompt and stops exploring new strategies. Training stagnates near zero reward.
  1. Gradient dilution. Even when exploration continues, the few successes get drowned out by the overwhelming majority of failures in the gradient signal. Learning from rare events is inefficient.

PISmith introduces two fixes:

  • Adaptive entropy regularization. Dynamically adjusts the entropy coefficient based on the current training reward. When rewards are near zero (early training against strong defenses), the regularization coefficient increases to force exploration. As the attack finds successful strategies, the coefficient decreases. This prevents entropy collapse without manual tuning.
  • Dynamic advantage weighting. Amplifies the gradient contribution of successful rollouts in proportion to their rarity. When success rate is 1 out of 64 rollouts, that single success gets weighted far more heavily than when 32 out of 64 succeed. This directly counters gradient dilution.

Benchmark Results

The team evaluated PISmith across 13 benchmarks covering question answering, retrieval-augmented generation, and long-context tasks. They tested 8 defenses against 7 baselines.

PISmith vs Baselines (ASR across 13 benchmarks)

Method Category Avg ASR@10 Avg ASR@1
Direct Static — 0.04
Combined Static — 0.07
TAP Search-based — 0.11
PAIR Search-based — 0.16
Strategy Search-based — 0.21
Vanilla GRPO RL-based 0.13 0.05
RL-Hammer RL-based 0.70 0.48
PISmith RL-based 1.00 0.87

PISmith hits 87% ASR@1 averaged across 13 benchmarks. The next best attacker, RL-Hammer, reaches 48%. Vanilla GRPO manages 5%. Static attacks barely register at 4-7%.

Defense Breakdown (PISmith ASR@1)

Defense Type Utility PISmith ASR@1
No Defense — 0.74 0.92
Sandwich Prevention 0.74 0.91
Instructional Prevention 0.73 0.92
PromptArmor Prevention 0.74 0.92
PIGuard Filter 0.72 0.82
PromptGuard Filter 0.66 0.89
DataFilter Prevention 0.63 0.49
DataSentinel Filter 0.55 0.52

Prevention-based defenses like Sandwich, Instructional, and PromptArmor maintain utility at 0.73-0.74 but offer zero meaningful protection. PISmith achieves 91-92% ASR against them, nearly identical to the undefended baseline of 92%. These defenses do nothing against adaptive attacks.

Filter-based defenses fare slightly better but at a steep cost. DataSentinel cuts ASR to 52% but tanks utility to 0.55. DataFilter gets ASR to 49% with utility at 0.63. No defense achieves both utility above 0.70 and ASR below 0.60. The authors call this the "fundamental utility-robustness trade-off."

Agentic Settings

PISmith was also tested in agentic settings against both open-source and closed-source models:

Target Model Direct ASR@1 PISmith ASR@10/1
Meta-SecAlign-8B 0.00 1.00 / 0.99
GPT-4o-mini 0.02 1.00 / 0.99
GPT-4.1-nano 0.01 1.00 / 1.00
GPT-5-nano 0.00 1.00 / 0.95

Meta-SecAlign, the defense that reports 0% ASR under direct attack, falls to 99% under PISmith. Every closed-source model tested is similarly vulnerable. GPT-5-nano with AgentDojo shows 0% direct ASR but 95% ASR@10 and 24% ASR@1 under PISmith in the harder agentic evaluation.

Why This Matters

Three takeaways:

Current defenses provide false security. Defenses that report near-zero ASR against static attacks are nearly useless against adaptive attacks. If you are deploying prompt injection defenses in production, you need to red-team with RL-based methods like PISmith. Static evaluations are not sufficient.

The utility-robustness trade-off is real. The only defenses that meaningfully reduce ASR (DataFilter, DataSentinel) also degrade benign task performance below acceptable thresholds. No existing defense is both useful and robust.

RL-based red teaming is now practical. PISmith demonstrates that automated RL training can find attacks that hand-crafted methods miss. The adaptive entropy regularization and dynamic advantage weighting make RL training viable even against strong defenses that cause extreme reward sparsity. This is a tool for defenders, not just attackers. Use it to test your own systems before someone else does.

The code is available at github.com/albert-y1n/PISmith. The paper is at arxiv.org/abs/2603.13026.