Design a defense-in-depth strategy against adversarial evasion on a deployed image classifier
Your ability to layer training-time and inference-time defenses for adversarial robustness.
Proactive: adversarial training, preprocessing, ensembles.
What's really being asked
The interviewer is evaluating whether you view adversarial robustness as a systems-level MLOps problem rather than a single algorithmic patch. They want to see layered thinking that connects model hardening, input sanitization, infrastructure controls, and operational monitoring into a coherent defense architecture.
The full answer
Proactive training-time measures first. These include adversarial training with methods like PGD or TRADES to improve robustness within an epsilon ball; input preprocessing defenses such as JPEG compression, bit-depth reduction, or spatial smoothing to disrupt gradient-based perturbations; and ensemble strategies or randomized smoothing to increase attacker uncertainty. Second, reactive inference-time controls. These include strict input validation with bounds checking and format constraints; statistical anomaly detection on input distributions, intermediate embeddings, or output logits to catch out-of-distribution or adversarial samples; rate limiting and query throttling to impede iterative attacks and model extraction; graduated response workflows that route suspicious requests to a safer secondary model or human review; and comprehensive logging of predictions and metadata for forensic analysis. Third, infrastructure hardening such as authenticated API gateways, encrypted model artifacts, and runtime isolation.
The mistakes people make
Claiming that adversarial training alone guarantees safety. Proposing only superficial input checks like resizing or format validation without behavioral monitoring. Ignoring the inference API attack surface and failing to mention rate limiting or authentication. Neglecting incident response and the need for production monitoring. Suggesting security through obscurity or model secrecy as the primary defense.
What usually comes next
How do you trade off clean accuracy against adversarial robustness? What is your approach when attackers adapt to known defenses? How would you handle a confirmed adversarial example in production? Can you quantify the latency and cost impact of ensemble inference at scale?
A concrete example
Consider a production image classifier that accepts user uploads. The pipeline begins with JPEG compression and resizing to strip subtle perturbations. A lightweight autoencoder checks reconstruction error; if it is anomalous, the request is flagged. The primary model then produces a prediction. If softmax entropy exceeds historical thresholds or confidence drops abruptly, the request graduates to a secondary ensemble. After three flagged requests from the same API key within one minute, rate limiting activates and alerts fire. All anomalous embeddings and inputs are logged to a SIEM and batched for monthly adversarial retraining.
Interview question
Which approach best embodies a defense-in-depth strategy for protecting a deployed image classifier against adversarial evasion?
- a.Restricting model architecture details to internal teams to prevent attackers from computing effective perturbations
- b.Enforcing strict input format checks such as file extensions and dimension resizing before classification
- c.Relying primarily on adversarial training with PGD to ensure robustness within a known epsilon ball
- d.Layering JPEG preprocessing, embedding anomaly detection, graduated response to a secondary ensemble, and query rate limitingCorrect
Why? this is the answer
Defense-in-depth requires combining training-time preprocessing with inference-time behavioral monitoring, graduated response, and operational controls. Option C relies on a single proactive layer that does not address the inference API attack surface, while option A represents security through obscurity and option B relies on superficial validation without anomaly detection or rate limiting.
Just read this? Test yourself on what you have been reading.
Read the original → cheatsheetseries.owasp.org
- #mlops
- #adversarial-robustness
- #security
- #infrastructure
- #machine-learning
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on mlops — each one lists the topics its interview covers.
See open roles