Inverting the Shield: POLARIS Systematically Generates Safety Tests from Policy SpecificationsInverting the Shield: Systematically Generating Safety Tests from Policy Specifications
The authors propose POLARIS, which compiles safety policies into first-order logic and builds a semantic graph to systematically generate safety test queries; the authors report a policy clause coverage of 100% and a higher number of successful attacks than the baselines.
The paper does not define a threat model from an attacker's perspective, but rather serves as a red-team test generation framework: starting from natural-language safety policies, it systematically generates harmful queries that violate the policies, to test target LLMs' policy compliance; the targets are 6 open-source chat models, single-turn interaction, and success is judged by 5 automated evaluators (including GPT-5-mini and DeepSeek-R1-0528).
- Existing LLM safety evaluations either rely on static benchmarks (costly, prone to contamination, easily outdated) or on heuristic red teaming (lacking systematicity); neither can trace specific policy clauses or guarantee coverage.
- POLARIS compiles natural-language safety policies into first-order logic axioms (AVTs), builds and densifies a semantic policy graph, samples violation paths via controlled random walks, and instantiates them into natural-language test queries by a generator LLM combined with context and intent masking.
- The authors report: policy clause coverage 100% (Table 7); the number of successful attacks is higher than the baselines on almost all target models, reaching 13722 on Mistral-7B as evaluated by GPT-5-mini; generating 28660 queries costs $70.52.
- The authors note: generation quality depends on the input policy (garbage-in, garbage-out); it is limited to static single-turn interaction, and multi-turn dialogue and autonomous agent risks are future directions. The experimental targets are 6 open-source models at the 7B level plus Qwen3-8B; no human evaluation is reported.
- Evaluated models
- Llama-2-7B-chatLlama-3.1-8B-InstructMistral-7B-Instruct-v0.2Qwen-7BGemma-7BVicuna-7B-v1.5Qwen3-8B
- Benchmarks
- SORRY-BenchSOS-BenchAirBench 2024AdvBenchJBB-BehaviorsHarmBenchDANLLM-FuzzMalicious-InstructMasterKey16 项企业使用政策与 4 项中国监管文件
- Metrics
- Coverage ScoreNovelty ScorePolicy Clause CoverageAttack Success CountPolicy-Compliance Rate
Researchers propose the POLARIS framework, which compiles unstructured natural language safety policies into first-order logic (FOL) representations, establishing traceable links between high-level rules and concrete test cases. The framework accordingly builds a Semantic Policy Graph, encoding complex policy violation scenarios as traversable paths, systematically explores the graph to discover compositional violation patterns, and then instantiates them as executable natural language test queries, achieving coverage-driven, reproducible safety testing. In the experiments reported by the authors, POLARIS achieves higher policy coverage and attack success counts than existing baselines. The authors state that the framework bridges formal methods and AI safety, providing an automated path with verifiable traceability for making LLMs follow safety-critical policies; code is released at https://github.com/huac-lxy/POLARIS。
Paper analysis
What problem does this paper attempt to solve?
Existing safety evaluations lack systematicity and traceability; the authors propose formalizing safety policies and then systematically generating tests.
Core problem: existing LLM safety evaluations cannot systematically verify a model's compliance with safety policies, nor can they clearly state which policy clauses have been tested.
- Problem setting: LLM alignment requirements are usually written in natural-language safety policies, and the authors argue that safety evaluation is essentially verifying compliance with these policies.
- Shortcomings of existing paradigms: The authors state that static benchmarks are costly, susceptible to data contamination, and outdated as soon as they are updated, testing memorization rather than generalization; automated red-teaming is heuristic, probing randomly without a map of the policy space; both lack traceability and coverage guarantees.
- Core observation: The authors' key insight is that safety policies, though designed as shields, also precisely delineate the boundaries that attacks must cross; once formalized as explicit constraints, they can be systematically "inverted" into adversarial tests targeting the compliance boundary.
- Paper's approach: It proposes POLARIS (POlicy-guided Logic-Assisted Red-teaming and Instantiation System), which compiles policies into first-order logic (FOL), builds a semantic policy graph and explores it systematically, then instantiates it into natural-language test queries, achieving coverage-driven, reproducible safety testing.
- Threat model (not defined from the attacker's perspective in the paper; understood according to the red-teaming framework):
- Goal: generate harmful queries that violate a given safety policy, to test the target LLM's policy compliance.
- Knowledge/capability: uses public corporate usage policies and government regulatory documents as input to automatically generate queries, without requiring internal knowledge of the target model.
- Victim system: 6 open-source chat models (Llama-2-7B-chat, etc.), single-turn interaction.
- Success criterion: an automatic evaluator (e.g., GPT-5-mini) judges whether the output violates the policy, counted by number of successful attacks.
What related research exists?
Related work falls into three groups: static safety benchmarks, automated red teaming and instruction generation, and specification-based testing in software engineering.
LLM safety evaluation benchmarks
- Static benchmarks such as AdvBench (Zou et al., 2023), SORRY-Bench (Xie et al., 2025), and SOS-Bench (Jiang et al., 2025) provide standardized evaluation; the authors state that they are costly, non-adaptive, and prone to contamination.
- Dynamic red teaming: curiosity-driven red teaming (Hong et al., 2025) uses an adversarial LLM to automatically generate harmful prompts, and expert seed generation (Yuan et al., 2025); the authors state that they are more flexible but still heuristic, lacking traceability to specific policies and systematic coverage guarantees.
Instruction and prompt generation
- Evol-Instruct / WizardLM (Xu et al., 2024a; Luo et al., 2024, 2023) and MAGPIE (Xu et al., 2024b) use LLMs to iteratively synthesize more complex instructions to improve model capabilities. The authors point out that POLARIS has a different goal: not to increase instruction complexity or merely pursue attack success rates, but to guarantee verifiable coverage of explicitly formalized policies.
Specification-based test generation in software engineering
- Model-Based Testing (Ussami et al., 2016; Lahami et al., 2015; Sartaj et al., 2019) and Property-Based Testing (Goldstein et al., 2024; Xiong et al., 2024; Bose, 2025) systematically generate test cases from formal specifications. The authors point out that these methods rely on machine-readable formal specifications, whereas safety policies are vague natural language—precisely the gap POLARIS aims to bridge.
Baselines and benchmarks
- Dynamic baseline: the curiosity-driven red teaming framework (Hong et al., 2025).
- Static benchmarks: SORRY-Bench, SOS-Bench, AirBench 2024, AdvBench, JBB-Behaviors, HarmBench (the coverage comparison in Table 1 additionally includes DAN, LLM-Fuzz, Malicious-Instruct, MasterKey).
The authors position this paper as: using policy specifications to drive systematic, verifiable, coverage-oriented test generation, combining the flexibility of dynamic methods with the rigor of formal specifications.
How does the paper address this problem?
POLARIS has three stages: compile policies into FOL → build and densify the semantic policy graph → sample by graph walk and instantiate queries.
Overall idea: compile natural-language safety policies into verifiable first-order logic axioms, organize them into a semantic policy graph, systematically explore combinatorial violation patterns, and then instantiate them into natural-language harmful queries by a generator LLM, with each test case traceable to a specific policy clause.
Policy-to-Logic Compilation
- Policy preprocessing: split compound policy clauses into atomic rules {r1, ..., rn}, each an irreducible prohibition (e.g., "prohibit distributing drugs or firearms" is split into two rules), to avoid semantic ambiguity in subsequent generation.
- Abstract Violation Template (AVT): each atomic rule is formalized as a logical implication ∀ x, y, ⋯ : Ppre(x, y, ...) ⇒ VIOLATION(Ri), where Ri is the policy reference and the premise consists of three types of components extracted by an LLM: entities (e.g., User, Explosive), actions (e.g., Manufacture, Distribute), and deontic modality (the logical operator defining the prohibition).
- The authors state that this transformation guarantees that every test case is grounded in a specific, machine-verifiable logical axiom, establishing traceability.
Semantic policy graph construction and densification
- Graph construction: map the entities and actions of all AVTs to nodes V and edges E; e.g., "prohibit instructing weapon manufacturing" is initialized as User, Instruction, Weapon nodes and semantic action edges.
- Embedding-based merging: project entity nodes into a high-dimensional semantic space; nodes with high cosine similarity (e.g., Client and User) become merge candidates, unifying the search space to generalize across synonymous concepts.
- LLM-driven link prediction: use the LLM's parametric knowledge to infer causal or associative links between unconnected concepts (e.g., "chemistry lab" contains "precursor chemicals"), turning a static rule set into a dynamic environment where multi-hop combinatorial violation scenarios can be discovered.
Graph-guided query instantiation
- Random graph traversal: perform controlled random walks on the densified graph to sample abstract violation scenario paths
\pi : v_1 \xrightarrow{e_1} v_2 \xrightarrow{e_2} \cdots \xrightarrow{e_n} v_k, where paths satisfy the topological constraints of the policy graph. - Context-aware instantiation: rather than instantiating directly, the generator LLM weaves a narrative around the abstract scenario, explicitly injecting two variables: Context (a seemingly benign situation, e.g., "educational research", used to reduce the target model's refusal probability) and Intent Masking (packaging harmful intent as hypothetical or investigative inquiries).
- Instantiation has two layers: first ground generalized nodes into concrete personas (User → Junior Analyst), then synthesize a scenario seed based on Context and Intent to generate the final query.
Key parameters and implementation
- Graph traversal configuration (Appendix A.2): random walk length 8, 2–4 action edges per path, 2 paths generated per node.
- Embedding model all-mpnet-base-v2, neighborhood size k = 15 for density-weighted computation, cosine distance threshold τ ∈ {0.4, 0.5, 0.6}.
- Hardware: Intel Xeon Platinum 8358 CPU + NVIDIA A100 80GB; Python 3.11, PyTorch 2.8.0, vLLM 0.10.2, Transformers 4.56.1.
- Appendices G and H provide the complete prompt templates for adding node relations and FOL translation.
What experiments did the paper conduct?
Four RQs: coverage and novelty, attack effectiveness, efficiency, and module validation, plus ablations and several extended experiments in the appendix.
Experimental setup
- Target models: Llama-2-7B-chat, Llama-3.1-8B-Instruct, Mistral-7B-Instruct-v0.2, Qwen-7B, Gemma-7B, Vicuna-7B-v1.5; the appendix extends to Qwen3-8B.
- Policy sources: the full text of 16 policies from 9 AI companies (Anthropic, Baidu, Cohere, DeepSeek, Google, Meta, Mistral, OpenAI, Stability), plus prohibited behaviors in 4 Chinese regulatory documents.
- Baselines: the dynamic baseline is curiosity-driven red teaming (Hong et al., 2025); static benchmarks are SORRY-Bench, SOS-Bench, AirBench 2024, AdvBench, JBB-Behaviors, HarmBench.
- Metrics: density-weighted Coverage/Novelty Score (cosine distance in embedding space, k=15, τ ∈ {0.4,0.5,0.6}), Policy Clause Coverage, number of successful attacks (the authors explicitly align with fuzzing principles by using absolute failure counts rather than success rates).
- Evaluation method: 5 automatic evaluators—Llama-Guard-3-8B, HarmBench-Llama-2-13b-cls, GPT-4.1, GPT-5-mini, DeepSeek-R1-0528; the main text reports GPT-5-mini and DeepSeek-R1-0528, with full results in Appendix B.2. The paper does not report human evaluation.
- Generator side: the main experiments use Llama-3-8B-Lexi-Uncensored to generate queries, and Appendix B.1.2 uses GPT-OSS-20B to verify generator independence; the query volume of the dynamic baseline is strictly matched.
Main results
According to Table 2 (number of successful attacks, evaluated by GPT-5-mini / DeepSeek-R1-0528):
Swipe horizontally to read the table
Dataset Gemma Llama-2 Llama-3 Mistral-7B Qwen-7B Vicuna AirBench 1192/1152 717/711 1391/1215 2850/2081 2100/2095 1945/1639 SOS 956/1015 1034/1043 1130/1006 1871/1368 1333/1315 1603/1578 Curiosity 32/32 20/25 224/56 84/35 2294/700 22/31 POLARIS 4344/5200 832/697 3716/4015 13722/11045 11150/10708 8045/8590 (The four rows AdvBench, HarmBench, JBB, SORRY have smaller values and are omitted; see Table 2 for the full results.)
- The authors state that POLARIS consistently uncovers more total violations than baselines on almost all target models, with a 4–6× improvement over the strongest baseline, AirBench 2024, on Mistral-7B and Qwen-7B.
- Exception: on Llama-2, SOS-Bench (1034/1043) is higher than POLARIS (832/697); the authors state that SOS-Bench is competitive on specific models, but POLARIS is more stable across the entire evaluation suite.
- Coverage and novelty (Table 1): at τ=0.6, the Coverage Score exceeds 90% against most baselines while maintaining novelty (e.g., 35.26% Novelty at 93.21% coverage against HarmBench); Policy Clause Coverage reaches 100% (Table 7, all 13 policy sources at 100%, whereas Malicious-Instruct reaches only 46.15% on the OpenAI policy).
RQ3: Efficiency
- Generating 28660 queries costs $70.52 in API cost and takes 17490.26 seconds (4.86 hours), averaging $2.47 per thousand queries (Table 3, API calls to GPT-4-Turbo).
- By stage: Policy-to-Logic $8.30, Semantic Policy Graph $35.11, Query Instantiation $27.11; the authors state that graph construction is a one-time cost, and the marginal cost of subsequent continuous generation via Instantiation is $0.94 per thousand queries.
RQ4: Intermediate module validation
- Logical formalization: across 16 policy sources (Table 4 lists 13), expert LLM review gives an average fine-grained score of 9.10/10 and a strict binary accuracy of 92.06% (Table 4).
- Entity extraction: on 50 randomly sampled policy clauses annotated by two domain experts, Exact Match is 84.7% and Semantic Match (verified by GPT-5) is 90.1%.
- The authors state that an additional automatic consistency filter validates axioms and checks satisfiability, discarding a small number of low-quality specifications.
Other ablations and analyses
- Logic-layer ablation (Table 6): the full framework has a policy compliance rate of 92.90%, versus 88.90% for w/o Logic (feeding raw policies directly to the LLM for generation).
- Graph ablation (Table 5): at τ=0.6, average Novelty rises from 24.80% for w/o Graph to 28.00%, and Coverage/Novelty are higher at all thresholds.
- K sensitivity (Appendix C.1, Figures 2, 3): as K varies from 1 to 30, the Coverage/Novelty fluctuation bands for most benchmarks are narrow; MasterKey's Coverage fluctuates relatively more, which the authors suggest may be due to its smaller sample size.
- Adaptability (Appendix C.2, Table 11): after adding instantiation constraints for the six scientific domains of SOS-Bench, Coverage improves by 8.21/14.70/2.91 percentage points at τ=0.4/0.5/0.6 respectively.
- Policy granularity (Appendix C.3, Table 12): under broad vs specific policies, average Coverage is 60.09% vs 60.42% and average Novelty is 5.47 vs 8.60; the authors state that performance is robust to granularity.
- Generator capacity (Appendix B.1.2, Table 8): after switching to GPT-OSS-20B, Coverage decreases and Novelty increases (often by more than 20 percentage points); the authors state that larger generators tend to avoid dense semantic regions.
- Query diversity (Appendix E, Table 13, N=100 samples per benchmark): POLARIS has K=43 scenario types (AdvBench has 11), syntactic diversity 1.00, and dependency tree depth 8.01 (SOSBench 9.04 and AirBench 9.75 are higher).
What are some points that can be further explored?
The authors note two limitations: dependence on input policy quality, and limitation to single-turn static interaction; the experiments cover 7 target models and automated judging.
Limitations and future directions noted by the authors
- Dependence on input policy quality (Limitations section): test generation quality fundamentally depends on the input policy, which the authors call a typical "garbage-in, garbage-out" situation.
- Limited to static single-turn interaction (Limitations section): the current implementation is limited to static, single-turn interaction; extending logical formalization to the emergent, stateful risks of multi-turn dialogue and autonomous AI agents is what the authors call a key and primary future direction.
Scope of experimental coverage
- The target models tested are Llama-2-7B-chat, Llama-3.1-8B-Instruct, Mistral-7B-Instruct-v0.2, Qwen-7B, Gemma-7B, and Vicuna-7B-v1.5, 6 in total, with Qwen3-8B added in the appendix (Table 10); all are open-source models, with no closed-source target models included.
- Attack success determination relies entirely on 5 automated evaluators (Llama-Guard-3-8B, HarmBench-Llama-2-13b-cls, GPT-4.1, GPT-5-mini, DeepSeek-R1-0528); the paper reports no human evaluation or agreement between judges and humans.
- Policy inputs are 16 policies from 9 companies and 4 Chinese regulatory documents; in intermediate module validation, the human-annotated sample for entity extraction is 50 policy clauses with two experts.
- The efficiency experiment reports the API cost and time for generating 28660 queries (Table 3), but does not report the total number of queries to target models or the query budget per target model.
- The diversity analysis (Appendix E) randomly samples N=100 per benchmark.
Summarize the main content of the paper
POLARIS formalizes safety policies into first-order logic and explores them as graphs, systematically generating traceable safety test queries.
A paper that introduces specification-based testing from software engineering into AI safety evaluation, proposing the red-team test generation framework POLARIS.
- Problem to solve: the authors argue that static benchmarks are costly and prone to contamination and obsolescence, while dynamic red teaming is heuristic; neither can trace specific policy clauses or guarantee coverage.
- Method highlights: policies are split into atomic rules and compiled into first-order logic AVTs; entities and actions form a semantic policy graph, densified through embedding merging and LLM link prediction; controlled random walks sample violation paths, and a generator LLM injects benign context and intent-masked instances to instantiate queries.
- Main results: policy clause coverage 100% (Table 7, 13 sources); the number of successful attacks is higher than the baselines on almost all target models, reaching 13722 on Mistral-7B as evaluated by GPT-5-mini, which the authors describe as a 4~6x improvement over the strongest baseline AirBench; the exception is Llama-2, where SOS-Bench is higher. Generating 28660 queries costs $70.52 (Table 3).
- Validation and ablation: strict binary accuracy of policy-to-logic compilation is 92.06% (Table 4); removing the logic layer lowers policy compliance from 92.90% to 88.90% (Table 6); removing graph traversal lowers average Novelty (Table 5).
- Authors' conclusion: the authors state that the rigor of formal methods can be successfully applied to AI safety, as a step toward building verifiable safe AI systems; they also note that the framework depends on input policy quality and is currently limited to single-turn static interaction, with multi-turn and agent scenarios as future directions.