Extraction and Inference Attacks
A prediction API looks simple: send an input, receive an output. Repeated outputs can reveal much more than the product team intended.
In a model-extraction attack, the attacker collects input-output pairs and trains a surrogate to imitate the target. In an inference attack, the attacker uses outputs to learn something hidden, such as whether a record was in the training data or which features drive a decision.
A surrogate attack follows a practical loop:
- Collect seed inputs from the target domain.
- Query the target and save its outputs.
- Train a surrogate model on those input-output pairs.
- Create new queries where the surrogate is uncertain or changes rapidly.
- Ask the target for labels on the new queries and retrain the surrogate.
- Generate white-box attacks against the surrogate.
- Submit those attacks to the target and measure how many transfer.
Train a Surrogate from Queries
What the attacker fits
p(y=1|x) = sigmoid(w1x1 + w2x2 + b)
w = [3.16, -2.25]
b = -0.97
Gradient descent minimizes binary cross-entropy on the labels returned by the target API.
Query budget
8
Grid agreement
87.3%
Query count matters, but coverage matters too. Repeatedly probing one corner can produce a large dataset and a poor copy.
Query a hidden classifier, fit a logistic surrogate to its returned labels, and compare query count with query coverage.
The surrogate does not need the target's exact weights. It needs a boundary that is similar in the part of feature space the attacker cares about. That is why query selection matters. A new query near the current surrogate boundary often teaches more than another query in a region where every model already agrees.
Fraud Detection API
A fraud ring submits transactions with controlled changes: amount, merchant, time, device, and location. A label-only response teaches something. A probability score teaches more. After enough probes, the group can estimate where review thresholds sit and shape transactions to remain below them.
Defenses make extraction more expensive. Rate limits reduce the query budget. Coarser outputs reveal less than full probability vectors. Monitoring can flag systematic boundary searches. Authentication and per-user quotas make it harder to spread queries across accounts.
Each defense also affects legitimate use. A useful API may need calibrated scores. A researcher may need enough queries to audit fairness. The threat model decides which information and volume are acceptable.
Why does an attacker train a surrogate model?