Black-Box Guardrail Reverse-engineering Attack

Hongwei Yao, Yun Xia, Shuo Shao, Haoran Shi, Tong Qiao, Cong Wang · OpenReview

Abstract

Large language models (LLMs) increasingly employ guardrails to enforce ethical, legal, and application-specific constraints on their outputs. While effective at mitigating harmful responses, these guardrails introduce a new class of vulnerabilities by exposing observable decision patterns. In this work, we present the first study of black-box LLM guardrail reverse-engineering attacks. We propose Guardrail Reverse-engineering Attack (GRA), a reinforcement learning-based framework that leverages genetic algorithm-driven data augmentation to approximate the decision-making policy of victim guardrails. By iteratively collecting input-output pairs, prioritizing divergence cases, and applying targeted mutations and crossovers, our method incrementally converges toward a high-fidelity surrogate of the victim guardrail. We evaluate GRA on three widely deployed commercial systems, namely ChatGPT, DeepSeek, and Qwen3, and demonstrate that it achieves an rule matching rate exceeding 0.92 while requiring less than $85 in API costs. These findings underscore the practical feasibility of guardrail extraction and highlight significant security risks for current LLM safety mechanisms.

Introduction

As Large Language Models (LLMs) transition from research curiosities to production-grade tools, developers have implemented "guardrails"—external safety layers designed to filter or reject harmful content. These guardrails are typically treated as black boxes to protect proprietary safety logic and prevent adversaries from identifying specific bypasses. However, this study demonstrates that the observable binary decisions of a guardrail (allow vs. block) create a significant attack surface. By probing these boundaries, an adversary can systematically map and replicate the hidden safety policy, facilitating subsequent jailbreaking or prompt injection attacks.

The GRA Framework

The proposed Guardrail Reverse-engineering Attack (GRA) treats the victim guardrail as an environment to be explored and imitated. The framework operates through an iterative loop involving five key stages: sampling, forwarding, querying, reinforcement learning (RL) training, and genetic augmentation.

The GRA framework overview, illustrating the iterative loop between the adversary's surrogate model and the victim's black-box LLM system.

Reinforcement Learning for Policy Alignment

The core of GRA uses a surrogate model (e.g., Llama-3.1-8B) as an agent. The victim guardrail serves as a "reward model," providing feedback based on how closely the surrogate's predictions match the victim's actual behavior. Specifically, the framework employs Group Relative Policy Optimization (GRPO) to update the surrogate model's policy without requiring internal gradient access to the victim system.

Genetic Algorithm Data Augmentation

To maximize query efficiency, GRA focuses on "divergence cases"—prompts where the surrogate and victim disagree. It uses a Genetic Algorithm (GA) to generate new, high-value training data:

  • Crossover: Combines semantic elements from two high-divergence prompts to create complex new queries.
  • Mutation: Generates subtle, stealthy variations of single prompts to probe fine-grained decision boundaries.

Evaluation and Results

The attack was validated against three major commercial systems: ChatGPT, DeepSeek, and Qwen3, using two primary benchmarks: $D_{Jailbreak}$ (4,000 samples) and $D_{Injection}$ (5,000 samples).

Performance metrics of the GRA attack across three commercial LLM systems and two datasets, showing high fidelity in rule matching, recall, and F1-score.

The results demonstrate that GRA is highly effective and efficient:

  • High Fidelity: The attack achieved a rule matching rate (RuleMR) exceeding 0.92 across all tested systems.
  • Cost Efficiency: High-fidelity replicas were obtained for less than $85 in API costs, highlighting a massive asymmetry between defense and attack costs.
  • Superiority: GRA outperformed traditional model extraction baselines like DFME and Knockoff, particularly in identifying "indirect deflections" where models refuse prompts subtly.

Key Insights

A critical finding of this research is the transferability of safety logic. A surrogate trained on jailbreak attempts proved remarkably capable of predicting behavior on prompt injections. This suggests that commercial guardrails often rely on a unified underlying moral or legal framework, making them vulnerable to cross-domain extraction. Furthermore, the success of the genetic augmentation strategy confirms that the most effective way to "steal" a model is to aggressively probe the "gray areas" of its decision boundaries.

Conclusion and Defenses

The feasibility of low-cost guardrail extraction poses a severe threat to LLM safety. To mitigate these risks, the authors propose several defensive strategies:

  1. Input-Output Monitoring: Identifying the specific probing patterns characteristic of genetic algorithms.
  2. Adaptive Rejection: Introducing non-determinism or obfuscation in guardrail responses to reduce the signal available to attackers.
  3. Dynamic Policies: Frequently updating safety boundaries to ensure that reverse-engineered surrogates quickly become obsolete.

Summary updated

BibTeX
@misc{yao2025black,
  author = {Hongwei Yao and Yun Xia and Shuo Shao and Haoran Shi and Tong Qiao and Cong Wang},
  title = {{Black-Box Guardrail Reverse-engineering Attack}},
  year = {2025},
  eprint = {2511.04215},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.04215},
}
Figure