AI Red Teaming course · lesson 13 of 26
- 1What Is AI Red Teaming?
- 2Ethics, Authorization, and Rules of Engagement
- 3AI and Machine Learning Basics for Red Teamers
- 4Security Principles and AI Threat Modeling
- 5Build a Safe AI Red Team Test Lab
- 6Jailbreaks and Safety Filter Bypasses
- 7Prompt Injection: Direct and Indirect
- 8Code Injection and Tool Abuse
- 9System Prompt and Data Leakage
- 10Countermeasures for Prompt Attacks
- 11Data Poisoning and Backdoors
- 12Adversarial Examples
- 13Model Extraction and Weight Theft
- 14Model Inversion and Privacy Leaks
- 15Model Manipulation and the AI Supply Chain
- 16AI Infrastructure, Deserialization, and Remote Code Execution
- 17API Authentication and Authorization
- 18Black, Grey, and White Box Testing
- 19Manual, Automated, and Continuous AI Testing
- 20AI Red Teaming Tools, Frameworks, and Datasets
- 21Write Your Own AI Security Test Harness
- 22Report AI Security Findings and Track Fixes
- 23Defense in Depth for AI Systems
- 24Red Teaming LLM Applications and Agents
- 25Disclosure, Law, Careers, and What's Next
- 26Capstone: Red Team a Practice App
After this lesson, you will be able to distinguish query-based model extraction from theft of model files, identify the access each path depends on, and review controls for a model's API and stored artifacts. The lesson stays at the level of threat modeling and defense. It does not give instructions or code for copying a real model.
A trained model can represent years of research, engineering, data preparation, and compute. When a business or research team exposes a model to users, it needs to decide what information and capabilities the service should reveal, and who can access the model files themselves. These are related confidentiality questions, but they are not the same problem.
Weights are learned numeric values inside a model that help determine its outputs. A model usually has many weights, often stored in files alongside its architecture and configuration. Its architecture is the arrangement of components and connections that defines how those values are used.
The NIST model extraction glossary entry, based on its Adversarial Machine Learning taxonomy, describes model extraction as an attack that obtains details about a model's architecture or parameters. Security research also uses model extraction or model stealing for attempts to reproduce a model's behavior by querying a prediction interface. The original USENIX Security research on prediction APIs describes the central idea: an interface reveals predictions, and someone tries to build a different model that behaves similarly.
These uses overlap but should be described carefully. A functional copy may only approximate the original on a selected set of inputs. It is not necessarily the same model, the same weights, or a copy of its training data. Weight theft is the unauthorized acquisition of the actual model parameter files or other sensitive model artifacts. It usually involves access to a storage location, deployment environment, registry, backup, or build system that should have been restricted.
Two paths to model value
Imagine a fictional image-classification service. Users can submit images to an API and receive a label. If the API also returns detailed confidence values and accepts a large volume of requests, a person with legitimate query access may be able to learn more about how the classifier behaves than the owner intended. They might train a separate approximation that agrees with the original on some inputs. That is a query-based extraction concern.
Now imagine a model file saved in an internal artifact store so a serving service can load it. If an account or service has broader access than it needs, the file might be copied by someone who obtains that access. That is a weight-theft or artifact-confidentiality concern. The prevention point is the identity and permission boundary around the file and the systems that can retrieve it.

A model API is designed to answer requests, so ordinary use requires some output. The question is whether the interface returns more than the product needs, whether access is tied to a real identity, and whether use is monitored against a fair limit. A file store, by contrast, usually does not need to expose model parameters to end users at all. It can be restricted to deployment identities and authorized maintainers.
The risks also differ in effect. A behaviorally similar model could reduce the owner's competitive advantage, increase unauthorized use, or help someone develop a competing service. A copied weight file may enable direct deployment, further analysis, or use in an offline environment. The actual impact depends on the model, its intended use, the attacker's access, and what the copy can reproduce. Avoid assuming that any extracted approximation has the same quality or value as the original.
What access might an attacker have?
A black-box interface lets a caller submit inputs and observe outputs without seeing the model's internals. A prediction API is one example. The output might be a single class label, a ranked list, a confidence score, or a richer response. More detailed responses can be useful for legitimate product features, but they may disclose more about model behavior. The design should return the information users need and avoid exposing internal details without a clear reason.
Query-based extraction depends on access to the model's input-output behavior. It may also depend on the type and granularity of the output, the number of queries a caller can make, and whether the model can be queried with inputs chosen by the caller. This lesson does not describe query strategies or extraction procedures. For a defender, the key planning questions are whether the interface is public or authenticated, what outputs it returns, what usage rules apply, and how the service detects and handles unusual request patterns.
Weight theft depends on access to artifacts or the systems that handle them. A model artifact may include parameter files, architecture configuration, tokenizer or preprocessing files, adapter weights, checkpoints (saved snapshots from training), and build metadata. A model registry is an organized store for model versions and related information. An organization may also store artifacts in an object store, container image, build workspace, deployment volume, or backup. Exposure can occur through an overly broad permission, a compromised account, a shared service identity, or an insecure handling process. These are familiar access-control and supply-chain problems around a sensitive AI asset.
Authentication answers “who is making this request?” Authorization answers “what is that identity allowed to do?” A secure system needs both. A successful login should not automatically grant permission to read model files, modify a model deployment, or access every prediction endpoint. OWASP's Authorization Cheat Sheet recommends checking permission for each request and following least privilege. Apply that idea to both the API and the infrastructure around the model.
Model extraction is also different from extracting training examples or private facts. A model approximation concerns the behavior or design of the model. Training-data extraction concerns recovering information from the data used to train a model. Model inversion infers information about particular input records or features from model behavior. Those privacy risks are covered in the next lesson. A model can be exposed to one risk without the others, and an investigation should name the asset that may have been disclosed.
Protect the prediction interface
Start with the product requirement. Does a user need a label, a probability, a ranked list, an explanation, or several outputs? Return the least detailed response that still supports the feature. Avoid returning debug traces, internal identifiers, training metadata, raw model scores, or version details simply because they are easy to expose. A more detailed interface is not automatically unsafe, but each field should have a purpose and an owner.
Require authentication when the model service is not meant to be public. Then authorize each operation against the user's or service's role. Keep administrative endpoints separate from ordinary inference. Do not rely on an unguessable URL, a hidden route, or a prompt instruction as the permission check. Protect service-to-service access as carefully as user-facing access, and rotate credentials when exposure is suspected.
Use quotas and rate limits that fit normal use. A quota limits total use over a period; a rate limit limits how quickly a caller can send requests. These controls help prevent excessive use and can make large-scale probing more difficult. They do not prove that extraction is happening, and they do not stop every determined caller. A low request rate can be legitimate or suspicious depending on context, and an overly strict limit can interrupt real users. Apply limits by an accountable identity and product need, with a documented path for legitimate higher-volume use.
Monitor API activity for patterns that merit review. Useful signals may include unusual volume, repeated access to many different input categories, a sharp change in request distribution, repeated use of outputs that are not needed by the feature, or several identities behaving in a coordinated way. A single signal is rarely conclusive. Researchers, developers, and accessibility features may also generate unusual traffic. Monitoring should trigger investigation and be reviewed for false positives rather than automatically treating every outlier as an attacker.
Record enough operational evidence to investigate abuse, while avoiding unnecessary sensitive content. Useful fields can include the authenticated service or user, endpoint, timestamp, response type, request count, status, and policy decision. Protect these logs, restrict access, and set retention rules. Avoid logging credentials, full private inputs, or detailed outputs unless there is a reviewed need and a safe handling plan.
Protect weights and model artifacts
Treat model files as sensitive assets when their confidentiality matters. Keep them in approved stores with access limited to the people and services that need them. Use distinct service identities instead of shared human credentials, and grant those identities only the read or write access required for their role. The system that serves predictions may need read access to a specific model version; it does not need permission to browse every research checkpoint or training artifact.
Separate development, training, evaluation, and production environments where practical. This reduces the chance that an account used for routine experimentation can also retrieve production weights or change a live deployment. Protect the systems that build and publish artifacts, since an attacker who changes a build pipeline may be able to replace what the serving system loads. Review changes to model registries and deployment configurations, and keep an auditable record of who approved them.
Protect artifact transfer and storage using the controls appropriate to the environment, such as encryption, restricted network paths, secrets management, and access logging. Verify that the artifact loaded by a deployment is the reviewed version. A hash or signature can help detect unexpected changes when compared with a trusted value. It does not tell you whether the original artifact was safe or whether the trusted source itself was compromised, so pair integrity checks with provenance and review.
Maintain an inventory of model versions, where each version is stored, which workloads use it, who owns it, and when it can be retired. Remove stale copies when they are no longer needed, including temporary checkpoints and abandoned test exports. Backups also need appropriate access controls and retention. A model file that is forgotten in an old workspace can remain exposed after the production service has been secured.

What can monitoring and watermarking tell you?
Model watermarking refers to techniques intended to associate a model or its outputs with an owner or source. Some approaches place a detectable pattern in model behavior; others add a mark to generated content. The idea is to help support an ownership or provenance claim if a suspicious copy appears. A watermark is not an access-control mechanism and does not stop someone from obtaining a model file or querying an API.
Watermarks can be fragile or ambiguous. A transformation, fine-tuning, compression, or change to the model may weaken a mark. Researchers have studied both watermark robustness and methods that remove or undermine particular schemes, so results for one method should not be generalized to every model. See, for example, this ICCV study of robust watermarking and this IJCAI study of watermark removal. A watermark may also produce false matches or be difficult to verify independently. Treat it as one possible forensic signal, not proof by itself and not a replacement for protecting files, accounts, and services. If a team considers watermarking, it should understand what the method can detect, how it is validated, and what evidence it provides.
Monitoring query patterns has similar limits. An unusual pattern can be a useful alert, but monitoring is not a prevention boundary. A caller may make ordinary-looking requests, while a legitimate customer may generate high volume. Combine monitoring with authentication, authorization, quotas, output minimization, and a response process. Define who reviews an alert, what evidence they need, and how a legitimate user can appeal an incorrect block.
Review your exposure without extracting a model
A defensive review can map the routes to both the prediction service and the model files without attempting to reproduce or copy a protected model. Start with the asset: which model version has commercial, safety, privacy, or research value? Then list how a user gets predictions and how a serving workload obtains its artifact. For each route, identify the identity, permission, returned information, logging, and owner.
| Asset or path | Review question | Evidence to check |
|---|---|---|
| Prediction API | Is each endpoint authenticated and authorized as intended? | API configuration, role rules, and approved access tests |
| API outputs | Does each response expose only fields the feature needs? | Response schema and product requirement |
| Usage limits | Are limits tied to users or service identities and appropriate to normal use? | Quota policy, monitoring rules, and exception process |
| Model registry and storage | Which people and services can read or change each artifact? | Access lists, service identities, access logs, and ownership records |
| Build and deployment | Can the approved artifact be changed or replaced without review? | Pipeline permissions, release approvals, and integrity checks |
| Backups and old copies | Are unused versions still retained, and who can access them? | Artifact inventory and retention policy |
If you need to test permissions, use an approved test account and a harmless model or test artifact in a controlled environment. Confirm the expected allow and deny outcomes with the system owner. Do not try to obtain files or automate queries against a service unless the written scope explicitly authorizes that work. For this lesson, the exercise is a review of access paths and policy, not a model extraction test.
If a model or artifact may have been exposed, preserve relevant access and deployment records, restrict the affected identity or path, and follow the organization's incident process. Determine which versions and copies were accessible, whether they were downloaded or changed, and whether any credentials need rotation. Avoid making a public claim about a model clone based only on similar outputs; functional similarity is not proof that the original weights were copied.
Mistakes beginners make
- Treating a behaviorally similar surrogate as a bit-for-bit copy of the original weights.
- Assuming that a public prediction API automatically exposes the model file.
- Confusing model extraction with training-data extraction, model inversion, or system prompt extraction.
- Relying on rate limits alone while leaving artifacts or administrative endpoints broadly accessible.
- Returning detailed confidence values or internal metadata without checking whether the product needs them.
- Blocking every high-volume user without checking for legitimate use or providing an appeal path.
- Treating a watermark as proof of ownership or as a substitute for access controls.
- Forgetting checkpoints, backups, temporary exports, and old model versions when reviewing storage.
- Claiming an extraction incident from output similarity without checking artifact access and evidence.
Recap and try it yourself
Query-based model extraction uses outputs from an inference interface to build an approximation or infer details about a model. Weight theft means obtaining the actual model artifacts through an access or handling failure. Protect the API with authentication, per-request authorization, output minimization, quotas, rate limits, monitoring, and useful logging. Protect weights with least-privilege identities, restricted storage, secure build and deployment paths, integrity checks, artifact inventory, and controlled retention. Watermarking may provide a forensic signal, but it cannot replace these controls.
Try this: draw two paths for a model you own or a fictional one. Trace one from a user request through an API response; trace the other from an approved artifact store to a serving workload. Mark the identity and permission at every boundary, the information returned or copied, and the team that reviews unusual access. Identify one allow test and one deny test you could run with an approved test account, without copying model files or probing a public service.