defense 2026

Gradient-Controlled Decoding: A Safety Guardrail for LLMs with Dual-Anchor Steering

Purva Chiniya , Kevin Scaria , Sagar Chaturvedi

0 citations

α

Published on arXiv

2604.05179

Prompt Injection

OWASP LLM Top 10 — LLM01

Key Finding

Reduces false positives by 52% vs GradSafe at comparable recall, lowers attack success rate by up to 20% vs strongest baseline, adds under 15-20ms latency

Gradient-Controlled Decoding (GCD)

Novel technique introduced


Large language models (LLMs) remain susceptible to jailbreak and direct prompt-injection attacks, yet the strongest defensive filters frequently over-refuse benign queries and degrade user experience. Previous work on jailbreak and prompt injection detection such as GradSafe, detects unsafe prompts with a single "accept all" anchor token, but its threshold is brittle and it offers no deterministic guarantee that harmful content will not be emitted once decoding begins. We introduce Gradient-Controlled Decoding (GCD), a training-free guardrail that combines an acceptance anchor token ("Sure") and refusal anchor token ("Sorry") tightening the decision boundary and significantly lowering false positives. In the mitigation stage, if a prompt is flagged, GCD preset-injects one or two refusal tokens ("Sorry, I can't...") before autoregressive decoding resumes, guaranteeing first-token safety regardless of sampling strategy. On ToxicChat, XSTest-v2, and AdvBench, GCD reduces false positives by 52% vs. GradSafe at comparable recall, lowers attack success rate by up to 10% vs. the strongest decoding-only baseline, adds under 15-20 ms latency on an average on V100 instances, transfers to LLaMA-2-7B, Mixtral-8x7B, and Qwen-2-7B, and requires only 20 demonstration templates.


Key Contributions

  • Dual-anchor gradient detection using both acceptance ('Sure') and refusal ('Sorry') tokens to sharpen decision boundaries
  • Deterministic mitigation via preset refusal token injection that guarantees first-token safety regardless of sampling strategy
  • Training-free approach requiring only 20 demonstration templates, achieving 52% reduction in false positives vs GradSafe

🛡️ Threat Analysis


Details

Domains
nlp
Model Types
llmtransformer
Threat Tags
inference_timeblack_box
Datasets
ToxicChatXSTest-v2AdvBench
Applications
llm safetyjailbreak preventionprompt injection defense