← Lab /AI/ML

Mathematical encoding lets attacks bypass LLM safety at up to 56% success

Encoding harmful prompts as coherent mathematical problems bypasses LLM safety filters with 46%-56% success

AI/ML arXiv 5 May 2026 Attack Simulation evidence

Published as “Exposing LLM Safety Gaps Through Mathematical Encoding:New Attacks and Systematic Analysis”

Why it matters

The results show that safety filters relying on natural-language pattern matching can be bypassed by deep mathematical reformulation, indicating a need for defenses that understand abstract mathematical structure.

Summary

LLM-based mathematical encodings achieve 46-56% attack success across eight target models, far outpacing rule-based encodings (≈11%) and unencoded baselines (≈10%). The effect holds across two independent benchmarks (HarmBench and JailbreakBench) and is driven by deep reformulation of harmful content, not by mathematical notation itself. Evidence is strong: consistent ASR patterns across 8 models, 2 benchmarks, and robustness tests show little degradation with prompt repetition.

What they found 3

  1. LLM-based encodings achieve high attack success, averaging 46.3% ASR on HarmBench across eight models.

    “averaging 46.3% ASR on HarmBench across eight target models compared to 11.0% for rule-based encodings and 10.0% for the unencoded baseline.”

  2. Formal Logic encoding performs on par with Set Theory overall.

    “Formal Logic achieves ASR comparable to Set Theory overall (avg. 50.1% vs. 50.7% on HarmBench)”

  3. Attack success is robust to prompt repetition, with 85.7% of repeats changing ASR by ≤5 percentage points.

    “85.7% of repeat experiments yielding |∆ASR| ≤5 percentage points”

Caveats 1

  • GPT-5 achieves only 2.5% baseline ASR and 13-32% under LLM-based encodings

What’s new here 4

  • Introduces a Formal Logic encoding that matches or exceeds Set Theory attacks.
  • Systematic comparison of LLM-based versus rule-based mathematical encodings across eight models.
  • Evaluates robustness via repeat post-processing, showing attacks are stable to surface-level changes.
  • Provides public code and scripts for all six encoding strategies on two benchmarks.