Black-Box Detection of Language Model Watermarks

Thibaud Gloaguen, Nikola Jovanović, Robin Staab, Martin Vechev

TL;DR

This paper demonstrates that current large language model (LLM) watermarking schemes—even those designed to be "undetectable" and distribution-preserving—can be reliably detected in a strict black-box setting. By querying models through standard text APIs without access to log-probabilities, the authors develop rigorous statistical tests that identify the presence and parameters of all three major watermarking families at a very low financial cost.

What Problem Does This Paper Address?

As LLMs become ubiquitous, watermarking has emerged as a crucial tool for regulators and providers to identify AI-generated text and prevent misuse. Early watermarking methods (like Red-Green schemes) alter the model's token probabilities, which can degrade text quality and make the watermark noticeable to downstream users. To solve this, researchers recently introduced "distribution-preserving" watermarks (such as Fixed-Sampling and Cache-Augmented schemes) that theoretically generate text indistinguishable from an unwatermarked model.

However, the authors of this paper ask a critical question: Are these watermarks truly undetectable in practical, real-world scenarios? Prior work assumed an adversary would need internal model access (white-box) or output log-probabilities to detect a watermark. This paper evaluates detectability under a realistic, strict black-box setting where the user only receives raw text responses from an API.

Figure 1: Overview of our key contribution. Given black-box textual access to a language model, a client can query the model and run statistical tests to rigorously test for presence of a watermark. In this example, both the test for Cache-Augmented watermarks (§4) and the test for Fixed-Sampling watermarks (§3) fail, while the test for Red-Green watermarks (§2) successfully detects the watermark.

Methods

The authors design distinct statistical tests tailored to the fundamental mechanics of the three prominent watermarking families:

  1. Red-Green Watermarks (Context-Dependent Logit Bias): These watermarks boost a pseudorandom set of tokens based on the immediate prefix context. The authors use a clever prompting strategy to force the LLM to choose from a restricted vocabulary (e.g., a list of fruits). By systematically varying the prefix and context tokens, they measure the resulting logit bias and apply a Monte Carlo permutation test to confirm if the variations are caused by a watermark.
  2. Fixed-Sampling Watermarks (Sublinear Response Diversity): These schemes use a pseudo-random key sequence of length $n_{key}$ to determine token selection. Because the key sequence eventually repeats or cycles, the total number of unique outputs for a given prompt is strictly bounded by $n_{key}$. The authors construct a "rarefaction curve" tracking unique outputs over multiple queries and use a Mann-Whitney U test to detect the sublinear diversity drop-off characteristic of these watermarks.
  3. Cache-Augmented Watermarks (Cache-Conditioned Choice Distribution): These watermarks use a cache of previously seen contexts to bypass watermarking and preserve the original distribution on repeated text. The authors exploit this by probing the model in two phases: one that forces a cache hit (revealing the unwatermarked distribution) and one that resets or avoids the cache. A Fisher's exact test is then used to detect discrepancies between the two distributions.

Datasets

Because this is an evaluation paper focusing on black-box detection rather than model training, the authors did not train on standard datasets. Instead, they evaluated their methods across:

  • Open-Source Models: Mistral-7B, Llama2 (7B, 13B, 70B), Llama3-8B, Yi1.5-9B, and Qwen2-7B.
  • Commercial APIs: GPT-4, Claude 3, and Gemini 1.0 Pro (used to validate false-positive rates in production environments).
  • Prompts: Custom-designed templates utilizing simple word lists (e.g., fruit names) and diversity-inducing prompts ("This is the story of...") to reliably measure model behavior.

Key Insights and Ideas

  • The Illusion of Undetectability: Theoretical guarantees of "undetectability" often break down due to implementation constraints. For instance, Fixed-Sampling watermarks inherently restrict the entropy of the generation space over many queries, leaving a clear statistical footprint.
  • Leveraging Cache Vulnerabilities: Cache-augmented watermarks inadvertently create a side-channel. By attempting to hide the watermark during repeated text generation, the cache explicitly leaks the unwatermarked distribution, allowing an attacker to compare it against the watermarked one.
  • Watermarks as Statistical Anomalies: Even without log-probabilities, repeating simple, constrained prompts allows an observer to reconstruct an approximation of the model's internal token preferences, turning black-box text into a viable statistical signal.

Key Results

The proposed statistical tests achieved near-perfect detection accuracy across all tested open-source models and watermarking variants:

  • High Statistical Confidence: When a watermark was present, the corresponding test rejected the null hypothesis with extremely low median p-values (frequently $0.000$ or $< 10^{-5}$), indicating clear detection.
  • Zero False Positives on Production APIs: When run against unwatermarked commercial deployments (GPT-4, Claude 3, Gemini), the tests correctly failed to reject the null hypothesis, demonstrating robustness against false positives.
Table 1: Main results of our watermark detection tests across different models and watermarking schemes. We report median p-values across 100 repetitions of the experiment, and for RED-GREEN schemes additionally over 5 watermarking keys. p-values below 0.05 (test passing) are highlighted in bold. δR and γR denote δ-REWEIGHT and γ-REWEIGHT schemes, respectively.
  • Low Cost: The tests are highly practical and inexpensive. Based on OpenAI's GPT-4o pricing, the authors estimate the cost of running a Red-Green test at $2.43**, a Fixed-Sampling test at **$0.28, and a Cache-Augmented test at just $0.10.
  • Real-World Generalization: The authors successfully extended their Red-Green test to detect Google's production-grade SynthID-Text watermark on a Gemma-7B model with a median p-value of $0.000$ over 100 runs.

Limitations and Future Work

  • Scope of Families: The tests are specifically engineered around the structural properties of Red-Green, Fixed-Sampling, and Cache-Augmented watermarks. Entirely novel watermarking paradigms might evade these specific tests.
  • Empirical Power: The authors provide strong empirical validation but note the lack of theoretical bounds or guarantees on the statistical power of their tests.
  • Model Assumptions: The tests assume standard model behaviors like symmetric error terms and consistent sampling behavior, which might not hold true for heavily customized or highly quantized architectures.
  • Future Directions: The authors suggest that future watermarking research must focus on "entropy-conditioned" schemes (disabling watermarks in low-entropy text segments) to achieve true practical stealth, though this introduces a trade-off by weakening the watermark's strength.

Summary updated

Abstract

Watermarking has emerged as a promising way to detect LLM-generated text, by augmenting LLM generations with later detectable signals. Recent work has proposed multiple families of watermarking schemes, several of which focus on preserving the LLM distribution. This distribution-preservation property is motivated by the fact that it is a tractable proxy for retaining LLM capabilities, as well as the inherently implied undetectability of the watermark by downstream users. Yet, despite much discourse around undetectability, no prior work has investigated the practical detectability of any of the current watermarking schemes in a realistic black-box setting. In this work we tackle this for the first time, developing rigorous statistical tests to detect the presence, and estimate parameters, of all three popular watermarking scheme families, using only a limited number of black-box queries. We experimentally confirm the effectiveness of our methods on a range of schemes and a diverse set of open-source models. Further, we validate the feasibility of our tests on real-world APIs. Our findings indicate that current watermarking schemes are more detectable than previously believed.
BibTeX
@inproceedings{gloaguen2025black,
  author = {Thibaud Gloaguen and Nikola Jovanović and Robin Staab and Martin Vechev},
  title = {{Black-Box Detection of Language Model Watermarks}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=E4LAVLXAHW},
}
Figure