AI Model Security: Protecting the Model Itself
AI model security protects the model itself: its weights, training data and behaviour, from theft, copying, tampering and misuse. Here is how it works.
On this page
Short answer
AI model security is the practice of protecting the model itself: its weights, its training data, its behaviour and the systems that serve it. Attackers copy models through APIs, poison training data and slip malicious code into model files. The defences are access control, endpoint limits, data checks and regular testing.
What is AI model security?
AI model security is the practice of protecting the model itself: its weights, its training data, its behaviour and the systems that serve it, from theft, copying, tampering and misuse.
Most AI security talk focuses on prompts: what users type and what the model says back. Model security looks one layer deeper, at the asset that cost time and data to build. A stolen or poisoned model can damage a business even when no prompt was ever abused.
The threats are concrete, not theoretical. Attackers copy models through APIs, poison training data, slip malicious code into model files, and use a model's own outputs to reconstruct what it was trained on.
| Threat | What the attacker gets | Main defence |
|---|---|---|
| Model extraction | A copy of the model's behaviour | Query limits, output controls |
| Weight theft | The model files themselves | Access control, encryption |
| Data poisoning | A model that misbehaves on command | Data checks, provenance |
| Model inversion | Training data reconstructed | Output filtering, privacy checks |
| Supply chain attack | Malicious code in a model file | Scanning, signed releases |
Model security sits alongside the wider work of protecting AI systems. For the broad overview, see security for AI.
How do attackers steal or copy a model?
Attackers copy a model by asking it many questions and training a cheaper copy on the answers. This is called model extraction, and it needs no access to the model files at all.
The attack works like this: the attacker sends thousands of carefully chosen queries through the public API, records the outputs, and trains a smaller model to imitate them. With enough queries, the copy behaves much like the original on the tasks that matter to the attacker.
The signs are patterns in the API logs: a single key making far more requests than a normal user, questions that systematically probe the model's boundaries, or traffic at odd hours from one account. Normal users ask varied questions; extraction looks methodical.
Defences start with the API itself: rate limits per key, cost limits that stop runaway queries, and output controls that add noise or truncate detail where it is not needed. These do not make extraction impossible, but they make it slow and expensive, which is usually enough.
How do you protect model weights and files?
You protect model weights the way you protect any valuable file: limit who can read them, encrypt them at rest, and track every copy.
Access control comes first. Weights should live in a private store with per-person permissions, not in a shared drive or a public bucket. Only the training and serving systems should have read access, and human access should require a reason and an audit entry.
Encryption protects weights when storage is breached, and signing protects them when they move. A signed model file lets the serving system check that the file came from your build pipeline and was not swapped on the way.
Watermarking adds a quieter layer: a hidden signal embedded in the model's behaviour that lets you prove a suspicious copy came from your model. It does not stop theft, but it gives you evidence when a copy appears in the wild.
How do you secure the inference endpoint?
You secure the inference endpoint by treating every request as untrusted: authenticate the caller, limit what it can ask, and log what it asked.
Authentication means each caller has its own key with its own limits, not one shared key for the whole product. When a key leaks, you revoke that one key instead of breaking the product for everyone.
Limits mean the endpoint enforces how many requests a key may make, how large the inputs may be, and how much output it may return. These limits also protect the business from runaway costs, since every request costs money to serve.
Logging means every request is recorded with the key, the time and the result, so abuse can be spotted and investigated. A weekly review of the unusual patterns, such as a single key at ten times its normal rate, catches most extraction attempts early. For the prompt-level attacks that target the same endpoint, see prompt injection security.
How do you check training data and the supply chain?
You check training data by knowing where every dataset came from, testing it for poisoned or mislabelled examples, and keeping a record of what went into each model version.
Data poisoning is the quiet threat: a small number of bad examples, inserted into a large dataset, that teach the model to misbehave on specific inputs. The defence is provenance and sampling: record the source of each dataset, check a sample of examples by hand, and compare new data against what you already trust.
The supply chain needs the same care. Model files downloaded from public hubs can contain malicious code that runs when the file is loaded, so scan every file before use and prefer signed releases from sources you trust. The same applies to the libraries around the model: keep them updated and pinned to known versions.
Keep a record that links each model version to its data, its code and its tests. When a problem appears, that record tells you which models are affected and what needs to be retrained. For the data side of this work, see data security in AI systems.
Example (hypothetical): a small team locks down its model
Example (hypothetical): a 20-person startup sells a document classifier trained on its clients' documents. The model files sit in a shared cloud folder, the API uses one key for all customers, and the team has never checked what the model reveals about its training data.
The team starts with access. It moves the weights into a private store with per-person permissions, encrypts them, and signs each release so the serving system can verify the file came from its own pipeline.
Next it fixes the endpoint. Each customer gets its own key with a daily request limit, and the team starts a weekly review of API logs. In the first month the review catches one customer making 40,000 requests in a day, far above its normal 400, and the team revokes the key and asks what happened.
Finally it tests the model for data leakage, asking it about specific training documents and checking whether the answers reveal them. Two gaps are found and fixed with output filtering. The work took six weeks, and the model is now an asset the team can defend.
What are the common mistakes?
The most common model security mistakes are sharing one API key for all customers, storing weights where anyone can read them, and never testing what the model reveals about its training data.
- One shared key. A single key for the whole product means a leak breaks everything and abuse cannot be traced to one caller.
- Weights in shared storage. Model files in a shared drive or public bucket are one misconfigured permission away from being copied.
- No extraction monitoring. Without log reviews, an attacker can query the model for months before anyone notices the pattern.
- Unscanned model files. A downloaded model file can run malicious code when loaded. Scan it first, every time.
- No data provenance. If you cannot say where your training data came from, you cannot tell whether it was poisoned.
Start with the three basics: separate keys per caller, weights in private storage, and a weekly log review. For the wider security programme around these controls, AI security covers the rest.
Key takeaways
- Model security protects the weights, training data and behaviour, not just prompts
- Extraction copies a model through the API; rate limits and log reviews slow it down
- Weights need private storage, encryption and signed releases
- Each caller gets its own key with its own limits
- Scan every downloaded model file and record where training data came from
Frequently asked questions
What is the difference between AI model security and AI security?
AI security is the broad field: prompts, data, agents, governance and the model itself. Model security is the part that protects the model as an asset: its weights, its training data, its behaviour and the systems that serve it.
Can a model really be stolen through an API?
Yes, through model extraction. An attacker sends many carefully chosen queries, records the outputs and trains a cheaper copy to imitate them. Rate limits, per-key quotas and log reviews make this slow and expensive, which is usually enough to deter it.
What is data poisoning?
Data poisoning is the insertion of a small number of bad examples into a training dataset, so the model misbehaves on specific inputs. Defences include recording the source of each dataset, sampling examples by hand and comparing new data against trusted data.
How do I know if my model leaks training data?
Test it. Ask the model about specific training documents and check whether the answers reveal them. Output filtering, privacy checks and regular leakage tests are the standard defences, especially for models trained on personal or client data.
Are open-weight models less secure?
Open-weight models are easier to copy by design, since the weights are public. The security focus shifts to the data, the serving endpoint and the behaviour of the system around the model, rather than protecting the weights themselves.
What should I do first?
Give each caller its own API key with a limit, move model weights into private storage with per-person access, and start a weekly review of API logs. Those three steps close the most common gaps.