Model Distillation Attacks and Defenses: How API Watermarking Protects AI Capability Moats

    This article examines how large-scale distillation attacks exploit legitimate API access to extract proprietary model capabilities, why traditional defenses fail to detect them, and how techniques such as output watermarking, behavioral analysis, dynamic inference strategies, and semantic-level API gateway controls can be combined to raise attack costs and provide forensic evidence—while balancing security with user privacy.

    An Open “Tech Cold War”: Why Distillation Attacks Are Hard to Eliminate

    Recently, a leading AI lab publicly disclosed that it had detected three AI research organizations conducting large-scale, systematic “distillation-style capability extraction” against its core conversational model, using bulk account creation. In the deep learning context, distillation refers to using the outputs of a powerful teacher model to train a smaller, cheaper student model, preserving most of the capability while enabling faster inference and simpler deployment.

    This is a routine technique in model compression. However, when it happens without authorization, and when the target is the core reasoning logic and stylized outputs of a commercial API, the nature of the act shifts from academic research to intellectual property infringement and the theft of competitive advantage. What makes it even trickier is that this attack relies on no system vulnerability at all—it is built entirely on legitimate API calls. The attacker simply “asked” too many questions, and asked them very strategically.

    The incident shook the industry because it exposed a deep contradiction in the AI sector: the tension between a model’s commercial value and how easily it can be replicated. When model capability becomes a core asset of cloud providers, proving that “you used my capability”—let alone stopping such theft—has become an urgent technical challenge for the entire industry.

    The Attacker’s Classic Playbook: Seemingly Harmless “High-Frequency Conversations”

    From a technical perspective, a typical distillation attack is highly engineered and usually consists of four stages:

    1. Account pooling and identity disguise: Attackers do not rely on a single account. They register large numbers of accounts and rotate network egress through proxy IP pools, simulating the dispersed access patterns of real users to evade rate limits based on single-account QPS (queries per second). This part of the operation is extremely stealthy—it involves no reverse engineering or penetration of the API and falls purely within normal business usage.

    2. Targeted prompt corpus construction: Attackers select high-value domains where the target model excels—such as code generation, complex logical reasoning, and multi-turn dialogue—and construct massive volumes of prompts with known answers or specific knowledge contexts. These prompts are carefully designed to induce the teacher model to produce structured, high-signal-to-noise chains of thought (CoT), so the student model can “learn better.”

    3. Streaming output capture and cleaning: To maximize distillation efficiency, attackers typically use the API’s streaming return feature, recording tokens the moment they are generated. They then clean the raw outputs into an instruction-tuning dataset through deduplication, truncation, and format restructuring.

    4. Iterative feedback optimization: Attackers first train an initial student model, then use its failures on a test set to generate harder, more targeted follow-up questions for a second and third round of “interrogation” of the teacher model. This closed-loop iteration continuously squeezes out the teacher model’s residual knowledge value.

    The frightening aspect of this approach is that every individual action—asking, receiving, saving—falls within the API’s terms of service. It triggers no privilege-escalation alerts and relies on no exploit tooling. At its core, it is a form of “data arbitrage” conducted over a legitimate interface.

    The Defender’s Dilemma: Detection Is Harder Than It Looks

    Against such attacks, traditional security systems are almost powerless.

    • Rule-based rate limiting: Sensitive only to request frequency from a single IP or account, it is easily bypassed by “account pool + IP rotation” strategies. Attackers keep request rates below detection thresholds, so the aggregate logs still look like “normal user behavior.”
    • Content-based keyword filtering: Prompts for distillation attacks are often complex professional questions containing code, formulas, or multilingual text, with no malicious payloads. Traditional content security engines cannot identify their “malicious intent.”
    • Inference cost auditing: While it is possible to tally the total token consumption of an account group, cost auditing only provides after-the-fact evidence against large volumes of dispersed small consumptions—it cannot intervene in real time during an ongoing attack.

    This is why the lab’s disclosed “detection capability” is so significant. The disclosure implies that its detection logic does not rely on traditional security rules, but on a watermarking technique based on the statistical distribution of generated content. The core principle: through fine-tuning, an inconspicuous but verifiable “probability shift vector” (the watermark) is embedded in the model’s output layer. When an attacker uses the model’s outputs to train a student model, this watermark signal is unconsciously inherited by the student as a “hidden feature.” The defender then only needs to run a targeted “probe test” against the suspect model—feeding it a set of specially constructed inducement questions and observing whether the output distribution’s statistical characteristics contain the original watermark—to determine the model’s lineage with the distilled model.

    Notably, this watermark is not bound to any account; it is bound to the model’s semantic feature space. This means that no matter how the attacker cleans the data or alters the model architecture, as long as the student model’s output distribution retains enough of the original model’s statistical signature, the watermark cannot be fully removed.

    Building an Active Defense System: From “Anti-Attack” to “Anti-Distillation”

    Since distillation cannot be entirely prevented, the ideal defensive strategy is not to attempt a complete blockade (which is logically impossible), but to raise the cost of distillation, lower its payoff, and provide an indisputable chain of evidence after the fact. A defense architecture can be built along three dimensions:

    Dimension 1: Deep Fusion of Behavioral Features and Causal Inference

    Traditional log analysis records only “what happened,” whereas deep behavioral defense focuses on “why it happened.” For example, graph neural networks (GNNs) can model call relationships and analyze behavioral sequence similarity across accounts. If thousands of accounts show abnormally concentrated topic clustering in their prompt distributions, and their context-switching frequency per call falls below the natural thought-jump patterns of human users, the account group can be flagged as being driven by automation. This analysis does not rely on a fixed attack signature database; it is grounded in statistical modeling of the “entropy of human questioning behavior.”

    Dimension 2: Dynamic Inference Strategies and Response Obfuscation

    At the model-serving layer, a vulnerability-aware scheduling mechanism can be introduced. For suspected high-risk call sources, decoding parameters can be adjusted dynamically without affecting normal user experience. For example:

    • Top-k sampling perturbation: Inject small amounts of random noise into suspected distillation requests to disturb the determinism of the output distribution, forcing the student model to learn a “contaminated distribution” rather than the exact one.
    • Reasoning chain truncation: For high-value logical reasoning questions, provide the result by default while withholding the long intermediate reasoning steps (i.e., not exposing CoT), thereby cutting off the most critical learning signal in the distillation process.
    • Response fingerprint obfuscation: For high-frequency similar prompts, randomly mix in synonymous but structurally different answer formulations, increasing the alignment difficulty of the attacker’s data cleaning.

    Dimension 3: Semantic-Level Risk Control at the API Gateway

    An LLM itself can serve as the risk-control engine. A lightweight discriminator model is deployed in front of the API gateway, taking as input not only the text content but also metadata such as token distribution entropy, time-to-first-token, and syntactic complexity of the query. When the discriminator outputs a “malicious distillation probability” score, different policy actions are triggered: observe, throttle, obfuscate, or reject outright. In this way, defense is elevated from “post-hoc tracing” to “real-time blocking.”

    Technical Ethics and Ecosystem Reflection: Where Are the Boundaries of Defense?

    It must be acknowledged that watermarking and behavioral detection face an inherent ethical paradox: if a cloud provider watermarks all content generated by its model, does that amount to invisible surveillance of user-generated content (UGC)? And if the API risk-control model misjudges a legitimate researcher’s compliant testing, could that trigger a crisis of trust in academic collaboration?

    Therefore, defensive techniques must be combined with tiered authorization mechanisms. Enterprise developers who have completed identity verification and signed compliance agreements can be granted more lenient call policies, while anonymous public users are subject to stricter frequency-response policies. At the same time, watermark granularity should be kept at the “model level” rather than the “user level”—that is, proving that “this student model derives from that teacher model” without necessarily tracing “who completed the distillation, when, and through which account.” This protects model security while respecting the privacy baseline of users.

    Conclusion: A Critical Contest for AI Industry Security

    The evolution of large model technology is entering an era of “capability equalization.” As a low-cost, high-efficiency means of capability replication, distillation attacks will persist for a long time to come. For cloud providers and AI companies, this is not a war that can be “won outright,” but an arms race requiring sustained investment. Every round of the contest between attack techniques and detection methods will push AI security systems toward ever more refined and intelligent iterations.

    Meanwhile, vendors such as Baidu AI Cloud continue to deepen their governance capabilities in model security and data compliance, offering end-to-end security solutions covering model auditing, access control, and data encryption to help enterprises safeguard their core assets while benefiting from large models. As AI technology becomes increasingly widespread, building a full-lifecycle protection system—from model training to service deployment—is not only a demonstration of technical capability, but also a fundamental responsibility of every responsible technology service provider.