A Cryptographic Perspective on Mitigation vs. Detection in Machine Learning

Greg Gluch, Shafi GoldwasserarXiv 2025 · OpenReview

Abstract

In this paper, we initiate a cryptographically inspired theoretical study of detection versus mitigation of adversarial inputs produced by attackers on Machine Learning algorithms during inference time. We formally define defense by detection (DbD) and defense by mitigation (DbM). Our definitions come in the form of a 3-round protocol between two resource-bounded parties: a trainer/defender and an attacker. The attacker aims to produce inference-time inputs that fool the training algorithm. We define correctness, completeness, and soundness properties to capture successful defense at inference time while not degrading (too much) the performance of the algorithm on inputs from the training distribution. We first show that achieving DbD and achieving DbM are equivalent for ML classification tasks. Surprisingly, this is not the case for ML generative learning tasks, where there are many possible correct outputs for each input. We show a separation between DbD and DbM by exhibiting two generative learning tasks for which it is possible to defend by mitigation but it is provably impossible to defend by detection. The mitigation phase uses significantly less computational resources than the initial training algorithm. In the first learning task we consider sample complexity as the resource and in the second the time complexity. The first result holds under the assumption that the Identity-Based Fully Homomorphic Encryption (IB-FHE), publicly-verifiable zero-knowledge Succinct Non-Interactive Arguments of Knowledge (zk-SNARK), and Strongly Unforgeable Signatures exist. The second result assumes the existence of Non-Parallelizing Languages with Average-Case Hardness (NPL) and Incrementally-Verifiable Computation (IVC) and IB-FHE.

Introduction

In the evolving landscape of machine learning security, defensive strategies typically fall into two categories: Detection (identifying a "jailbreak" or adversarial prompt and refusing to answer) and Mitigation (ensuring the model produces a safe or correct answer despite the adversarial attempt). While a vast literature exists on adversarial examples, most of it remains empirical. This paper provides a formal cryptographic framework to answer a fundamental question in AI safety: Is it easier to "fix" (mitigate) the effects of an adversarial attack than it is to "spot" (detect) the attack in the first place?

This question is especially pressing for Generative AI, where "correctness" is fluid—there are many ways to answer a prompt correctly, making it harder to define what constitutes a "malicious" input versus a difficult but benign one. By using the rigorous tools of cryptography, we formalize these concepts to determine if one approach offers a fundamental advantage over the other.

Methods: Formal Framework and Definitions

The interaction between a Trainer/Defender and an Attacker is modeled as a formal 3-round protocol. We define two primary types of defenses:

  1. Defense by Detection (DbD): The defender must either provide a correct answer or flag the input as suspicious. The Defense by Detection (DbD) protocol. Source, p. 4
The Defense by Detection (DbD) protocol.
  1. Defense by Mitigation (DbM): The defender must provide a correct answer, potentially utilizing a small amount of extra resources (such as fresh data or extra computation time) at inference. The Defense by Mitigation (DbM) protocol. Source, p. 4
The Defense by Mitigation (DbM) protocol.

To prove these results, we employ "heavy-duty" cryptographic primitives to construct "hard" learning tasks, including Identity-Based Fully Homomorphic Encryption (IB-FHE), zk-SNARKs, Incrementally-Verifiable Computation (IVC), and Non-Parallelizing Languages (NPL).

Datasets: Theoretical Learning Tasks

As a theoretical study, this work introduces two novel, mathematically defined "learning tasks" used for formal proofs:

  • $\mathbb{L}^{data}$: A task designed to test sample complexity. It partitions inputs into "levels of difficulty" where more samples are required to solve higher levels.
  • $\mathbb{L}^{time}$: A task designed to test time complexity, where solving the task requires a specific amount of sequential wall-clock time that an attacker cannot bypass.

Key Insights and Results

The core contribution of this work is the discovery of a fundamental separation between detection and mitigation in generative contexts.

The Classification Equivalence

For classification tasks, where there is only one right answer, detection and mitigation are essentially equivalent. If a defender cannot detect a bad input, they cannot mitigate it, because any "fix" would effectively reveal that the input was recognized as problematic.

The Generative Separation

In generative tasks, mitigation is strictly more powerful. Because there are many valid outputs, a defender can use a small amount of "fresh" resources at inference time to produce a valid result, even if they cannot distinguish the attacker's clever "jailbreak" from a normal, difficult prompt.

  • Theorem 1 (Sample Complexity): There exists a generative task where a defender can mitigate an attack using only $O(\sqrt{K})$ fresh samples, even though detecting the attack is impossible for any algorithm using $poly(K)$ resources.
  • Theorem 2 (Time Complexity): Similarly, there is a task where mitigation is possible with $O(\sqrt{T})$ extra time, but detection remains impossible even with $poly(T)$ time.

These results highlight a shift in AI industry trends—moving resources from the training phase to the inference phase (e.g., "test-time compute") to improve safety and alignment. Furthermore, the construction challenges the common conjecture of attack transferability, showing that a small increase in resources at inference can break this transferability.

Limitations and Future Work

While this paper provides the first formal proof that safety (mitigation) can be guaranteed without needing to solve the potentially impossible problem of perfect adversarial detection, several limitations remain:

  • Cryptographic Assumptions: The results rely on the existence of complex cryptographic primitives like IB-FHE and zk-SNARKs. While widely believed to exist, these are strong theoretical assumptions.
  • Honest Trainer Assumption: The current model assumes the trainer is honest and trying to defend the model, rather than a malicious actor planting backdoors.
  • Computational Overhead: While the scaling of the mitigation is efficient, the actual constants involved in cryptographic proofs are currently too high for practical LLM deployment.

Future work will explore whether these mitigation techniques can be generalized to broader, more natural learning tasks beyond these specific cryptographic constructions.

Summary updated

BibTeX
@misc{gluch2025cryptographic,
  author = {Greg Gluch and Shafi Goldwasser},
  title = {{A Cryptographic Perspective on Mitigation vs. Detection in Machine Learning}},
  year = {2025},
  eprint = {2504.20310},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.20310},
}
Figure