A new ACL 2026 Findings paper combines an offline-tuned defensive suffix with online stochastic ICL demonstration search, wrapped in a structured template prompt. The result: GCG and AutoDAN attack success rates fall to nearly 0% with no model fine-tuning, no measurable utility loss, and negligible computational overhead.

The paper is "Defending LLMs against Jailbreak Attacks via Template-Based ICL with a Defensive Suffix" by Ruiyang Ni, Changlong Li, Shuaibiao Han, Zhiyu Yi, Perley Xu, and Wenjie Ruan (ACL 2026 Findings, pages 42778-42797). Code is at github.com/Trusted-LLM/DSICL.

TLDR

DSICL defends LLMs using two components stitched into a single prompt template. First, an offline-tuned defensive suffix is computed once using an iterative algorithm. Second, at inference time, an online stochastic random search selects the most effective ICL demonstrations from a pre-built pool. The user instruction, selected demonstrations, and defensive suffix are assembled into a structured prompt fed to the LLM. No weights change. No fine-tuning required. GCG and AutoDAN attack success rates drop to nearly 0% with no utility loss.

Key Findings

The paper reports several results that distinguish DSICL from the crowded jailbreak defense space:

Attack success rate reduction to near 0%. Against GCG, the most studied white-box adversarial suffix attack, DSICL reduces attack success to approximately 0%. Against AutoDAN, a black-box attack that uses genetic algorithms to generate jailbreak prompts, DSICL achieves the same near-0% result. The defense works across both attack types without requiring attack-specific configuration.

No model utility loss. Many jailbreak defenses degrade model performance on benign tasks. Output filters truncate responses. Fine-tuning approaches can make models overly cautious. DSICL preserves model utility on standard benchmarks because it operates at the prompt level without modifying model parameters or constraining output generation.

Negligible computational overhead. The offline suffix optimization runs once and produces a fixed string. The online ICL search adds a stochastic sampling step at inference time, but the paper reports this overhead as negligible. The defense does not require a separate model, a classifier, or multi-step generation pipelines.

No fine-tuning required. DSICL works with any LLM that supports in-context learning. The defensive suffix and ICL demonstrations are injected through the prompt itself. This means the defense can be deployed on closed-source models accessed via API, not just open-weight models you control locally.

Technical Details

DSICL has three components that work together inside a structured template prompt.

1. Offline Defensive Suffix Optimization

The defensive suffix is a fixed string of tokens appended to the user instruction. The paper tunes this suffix using an iterative algorithm that searches for token sequences that maximize the model's refusal behavior on harmful inputs while minimizing interference with benign inputs. The optimization runs offline, once, and produces a portable suffix that can be reused across sessions and models. This builds on the same token-level search logic that powers GCG attacks. The difference: instead of finding suffixes that break alignment, DSICL finds suffixes that reinforce it.

The key design choice is that the suffix is attack-agnostic. It is not tuned against a specific attack. It reinforces the model's general safety alignment, which is why it transfers across both GCG and AutoDAN without attack-specific configuration.

2. Online Stochastic ICL Demonstration Search

The second component uses in-context learning demonstrations. DSICL maintains a pool of pre-constructed demonstration examples that show the model refusing harmful requests and answering benign ones. At inference time, a stochastic random search selects the most effective subset of demonstrations from this pool for the specific input.

The search is stochastic, not deterministic, which prevents an adversary from predicting which demonstrations will be selected. This adds randomness that makes the defense harder to attack. An attacker who knows the demonstration pool cannot guarantee which demonstrations will appear in any given prompt.

The demonstrations serve as behavioral anchors. By showing the model examples of safe behavior immediately before processing the user instruction, DSICL primes the model to maintain its alignment even when the instruction contains adversarial content.

3. Structured Template Assembly

The third component is the template itself. DSICL assembles three elements into a structured prompt:

  1. The original user instruction
  2. The selected ICL demonstrations
  3. The defensive suffix

The template enforces a specific ordering and formatting that maximizes the defensive effect. The demonstrations appear before the user instruction, establishing the behavioral context. The defensive suffix appears after the user instruction, providing a final alignment reinforcement. This structure matters. The paper tests alternative orderings and finds that the chosen template produces the best defense.

How the Components Interact

The offline suffix provides a constant defense layer. The online ICL search provides an adaptive layer that changes with each input. The suffix alone can be attacked by someone who knows the string. The ICL demonstrations alone lack the consistency of a fixed suffix. Together, the adaptive randomness of ICL selection and the fixed reinforcement of the suffix create a defense harder to bypass than either component alone.

Implications

For LLM Application Developers

DSICL works at the prompt level. You need three things: the tuned suffix string, a pool of ICL demonstrations, and a template to assemble them with user input. This makes DSICL deployable on any LLM API that accepts custom prompts. The low overhead matters for production where many defenses add latency. DSICL adds a search step over a demonstration pool, which the paper reports as negligible.

For Security Teams

The near-0% ASR is the headline. But the more important property is the defense's structure. The JBShield experience, where a 0% ASR defense was broken to 46.2% by an adaptive attack, shows single-layer defenses are fragile. DSICL's two-layer design with a stochastic component makes it structurally harder to attack than a deterministic defense.

For the Research Community

DSICL contributes to training-free jailbreak defenses alongside Defensive Prompt Patch (DPP, ACL 2025) and SelfDefend (USENIX Security 2025). DSICL adds a hybrid approach: a tuned suffix combined with ICL demonstrations in a structured template. The ACL 2026 Findings acceptance suggests the community sees value in this design.

Limitations and Open Questions

The paper does not report results against multi-turn jailbreak attacks. Multi-turn attacks build rapport across several turns before attempting the jailbreak, and it is unclear whether single-turn prompt defenses like DSICL handle this pattern.

The GitHub repository is empty as of July 8, 2026. The code is referenced in the paper but has not been published yet, limiting independent verification.

The stochastic ICL search introduces non-determinism. The same input could receive different defensive configurations across runs. This is a feature for security but a potential issue for applications requiring deterministic behavior.

The evaluation focuses on GCG and AutoDAN. Other attack methods including PAIR, prompt injection via tool outputs, and multi-turn social engineering attacks are not covered.

Comparison to Other Defenses

DSICL sits in a specific niche: training-free, prompt-level, inference-time defenses. Compared to fine-tuning approaches like adversarial training, DSICL is cheaper to deploy but may be less resilient to novel attack types. Compared to classifier-based defenses like JBShield or runtime filters, DSICL does not require a separate model or access to model internals. Compared to Defensive Prompt Patch (DPP), DSICL adds the ICL demonstration component, which adds adaptive randomness that a static patch cannot offer.

The key differentiator is the two-layer design. Most prompt-level defenses use a single mechanism: a suffix, a prefix, or a set of demonstrations. DSICL combines a fixed suffix with adaptive ICL selection, which creates a defense surface harder to attack than either mechanism alone.

Sources

  • Ni, R., Li, C., Han, S., Yi, Z., Xu, P., & Ruan, W. (2026). "Defending LLMs against Jailbreak Attacks via Template-Based ICL with a Defensive Suffix." Findings of ACL 2026, pages 42778-42797. https://aclanthology.org/2026.findings-acl.2123/
  • Code repository: https://github.com/Trusted-LLM/DSICL (empty as of July 8, 2026)
  • Xiong, C. et al. (2025). "Defensive Prompt Patch: A Strong and Generalizable Defense of Large Language Models against Jailbreak Attacks." Findings of ACL 2025, pages 409-437.
  • Wang, X. et al. (2025). "SelfDefend: LLMs Can Defend Themselves against Jailbreaking in a Practical Manner." USENIX Security 2025.
  • Derya, K. & Sunar, B. (2026). "Revisiting JBShield: Breaking and Rebuilding Representation-Level Jailbreak Defenses." arXiv:2605.03095.