Abstract
The proliferation of Machine Learning as a Service (MLaaS) has enabled widespread deployment of large language models (LLMs) via cloud APIs, but also raises critical concerns about model integrity and security. Existing black-box tamper detection methods, such as watermarking and fingerprinting, rely on the stability of model outputs—a property that does not hold for inherently stochastic LLMs. We address this challenge by formulating black-box tamper detection for LLMs as a hypothesis-testing problem. To enable efficient and sensitive fingerprinting, we derive a first-order surrogate for KL divergence—the entropy-gradient norm—to identify prompts most responsive to parameter perturbations. Building on this, we propose Regularized Entropy-Sensitive Fingerprinting (RESF), which enhances sensitivity while regularizing entropy to improve output stability and control false positives. To further distinguish tampering from benign randomness, such as temperature shifts, RESF employs a lightweight two-tier sequential test combining support-based and distributional checks with rigorous false-alarm control. Comprehensive analysis and experiments across multiple LLMs show that RESF achieves up to 98.80% detection accuracy under challenging conditions, such as minimal LoRA fine-tuning with five optimized fingerprints. RESF consistently demonstrates strong sensitivity and robustness, providing an effective and scalable solution for black-box tamper detection in cloud-deployed LLMs.
Introduction
As organizations increasingly rely on cloud-hosted Large Language Models (LLMs) like GPT-4 or Llama 3, a significant "trust gap" has emerged between model owners and cloud service providers. Users and owners need a way to verify that the model they are interacting with is indeed the original, untampered version. Potential threats include providers swapping high-performance models for cheaper, compressed versions to save costs, or malicious actors injecting backdoors via fine-tuning.
Traditional integrity verification methods often fail in the context of LLMs. Watermarking requires modifying model weights, which may not be feasible for third-party owners, while standard fingerprinting assumes stable input-output mappings. Because LLMs are inherently stochastic, their outputs fluctuate based on sampling temperature and randomness, making it difficult to distinguish between benign variance and actual tampering.
The RESF Framework
To bridge this gap, we propose Regularized Entropy-Sensitive Fingerprinting (RESF). This method identifies specific "canary" prompts that are hyper-sensitive to changes in the model's internal parameters while remaining stable under normal operating conditions.
Methodology
The RESF approach relies on three core innovations:
- Entropy-Gradient Norm Optimization: We derive a first-order surrogate for KL divergence to identify inputs where the model's probability landscape is steepest. These prompts act as "cliffs"; even a minor shift in model parameters (tampering) causes the output distribution to shift dramatically.
- Entropy Regularization: Sensitivity alone is insufficient if the prompt produces noisy, high-entropy outputs. RESF optimizes prompts to maximize sensitivity while simultaneously minimizing the original model's entropy, ensuring predictable responses from a "clean" model.
- Two-Tier Sequential Testing: To handle stochasticity, we implement a two-rule detection system. Rule E (Support Check) identifies tokens that were statistically impossible for the original model. Rule P (Shape Check) uses a sequential Chi-squared test to detect shifts in the probability distribution shape, even when the token set remains the same.
Experimental Evaluation
We evaluated RESF across a diverse set of open-source LLMs, including Qwen2.5 (0.5B and 7B), LLaMA3.2-1B, LLaMA3-8B, and Mistral-v3-7B. The system was tested against various tampering scenarios: supervised fine-tuning (SFT), freeze-layer fine-tuning, Low-Rank Adaptation (LoRA), and quantization (4-bit and 8-bit compression).
Key Results
RESF demonstrates exceptional performance across all tested models and tampering types. Notably, with just five optimized fingerprints, the system achieves near-perfect detection rates for most tampering methods.
- High Sensitivity: Even subtle modifications like LoRA fine-tuning, which changes only a tiny fraction of parameters, were detected with up to 99.9% accuracy.
- Robustness: The system maintained a low false-positive rate (typically <1%), effectively distinguishing between model tampering and benign environmental changes like temperature shifts.
- Efficiency: The sequential testing framework allows for "early exit" detection, often identifying tampered models within the first few queries.
Conclusion and Future Work
RESF provides a robust, black-box solution for maintaining model integrity in the MLaaS ecosystem. By focusing on entropy-sensitive prompts, it overcomes the challenges posed by LLM stochasticity.
Future research will focus on reducing the computational cost of generating fingerprints, which currently requires significant time for larger models. Additionally, we aim to improve the "naturalness" of fingerprint prompts to prevent adversaries from identifying and filtering them out, ensuring the long-term viability of fingerprinting in an adversarial landscape.
Summary updated