Host Snapshot Threat Scoring and Automated Containment Pipeline
System DesignModel answerLast updated
Design a cloud pipeline that scores host snapshots as normal or abnormal, applies safe automated containment or alerts, and exposes warning history to tenants.
Problem
You are building a managed security service for cloud customers. Software agents on customer machines periodically upload a snapshot of the operating system state (running processes, network connections, listening ports, loaded kernel modules, file hashes, resource usage, recent logins). An ML model classifies each snapshot as Normal or Abnormal.
When a snapshot is Abnormal, the platform may:
- send a warning email,
- quarantine the machine (isolate it from the network), or
- shut the machine down.
Customers must be able to look up the history of warnings and actions for their own machines.
Task
Design the end-to-end service. Your answer should cover:
- Requirements and your assumed scale (fleet size, snapshot frequency, payload size, expected abnormal rate).
- Data collection and ingestion.
- Model serving and how you keep cost under control.
- The decision layer that turns a model score into a response.
- Action orchestration, including what happens when an action fails and how a customer or operator reverts it.
- Storage for raw data, detections, actions and the audit trail, plus the query API for history.
- Access control and tenant isolation.
- Latency, throughput and availability targets.
- How you handle false positives, and which safeguards make automated destructive actions acceptable.
- How you roll out and roll back new models.
State your assumptions explicitly and call out the trade-offs you are making.
Hints
Hint 1
Do the capacity math first: machines times snapshot frequency gives requests per second, and payload size gives bandwidth and daily storage. Then use the expected abnormal rate to work out how many alerts per second the response path must handle.
Hint 2
Even a detector with high specificity produces mostly false alerts when true anomalies are rare. Let that drive the design: graduated responses based on confidence and reversibility, corroboration across snapshots, and human approval for irreversible steps.
Hint 3
Treat every automated action as a durable, idempotent workflow with a saved pre-action state, plus fleet-wide limits (a circuit breaker), protected-machine lists, a kill switch and shadow mode, so one bad model release cannot harm a whole fleet.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Clarify and size the problem
The model's output triggers destructive automated actions, so safety matters as much as accuracy. The action path must be correct before it is available.
Assumed scale
- 1M machines, one snapshot per 5 minutes: about 3.3K snapshots/s average, about 10K/s peak.
- About 50 KB compressed per snapshot: roughly 170 MB/s ingress and about 14 TB/day.
- Raw data hot for 30 days then cold storage; features and detections kept one year.
- Abnormal rate around 0.1%, so about 3 alerts/s fleet-wide.
- Targets: score within 30 s (p99) of upload, act within about 2 minutes. This is near-real-time, not millisecond-critical. Ingestion and history reads at 99.9%+.
2. Interfaces
POST /v1/snapshots: agent upload over mTLS with a signed payload; idempotency key(machine_id, seq).GET /v1/warnings?machine_id&from&to&severity&page_token: history.GET /v1/actions/{id},POST /v1/actions/{id}:approve,POST /v1/actions/{id}:rollback.PUT /v1/policies/{tenant}: thresholds, allowlists, action modes.POST /v1/detections/{id}:feedback: true/false positive labels.
3. Architecture
Agent -> Ingestion gateway (mTLS, authN, rate limit, dedupe)
-> Partitioned log (key = machine_id)
-> Feature service (parse + per-machine baseline from feature store)
-> Tier 1 model (rules + cheap GBDT / isolation forest, CPU, all traffic)
-> Tier 2 model (sequence model / autoencoder, GPU, ~5% escalated)
-> Decision engine (policy, calibration, corroboration, blast-radius checks)
-> Action orchestrator (durable workflow) -> executors + notifier
-> History DB + append-only audit log <- Query API (tenant-scoped)
Why this shape:
- The log decouples ingest from scoring, absorbs bursts, and keeps per-machine ordering via partitioning.
- Two tiers keep cost down: the cheap model handles 10K/s, and only suspicious snapshots pay for GPU inference (batched for throughput).
- Every stage is idempotent on
(machine_id, seq), so at-least-once delivery never produces duplicate actions.
4. Storage
- Raw snapshots: object storage, with a lifecycle policy to cold tier.
- Detections, decisions, actions: a strongly consistent store keyed
(tenant_id, machine_id, ts DESC), which serves history queries directly. - Audit log: append-only, hash-chained, written to WORM storage. Every state change records who, what, when and why.
- Action state machine: PENDING, APPROVED, EXECUTING, SUCCEEDED or FAILED, then optionally ROLLED_BACK, with
pre_action_statestored.
5. Handling false positives
Base rates dominate. With 0.1% true anomalies and 99% specificity, roughly 10 false alerts occur per true one, so most alerts are wrong. Mitigations:
- Per-machine and per-role baselines: a build server's normal differs from a database's. Score deviation from the machine's own history.
- Calibrated scores (Platt or isotonic) so thresholds are real probabilities and stay comparable across model versions.
- Graduated response by confidence and reversibility:
- Medium score: email only.
- High score plus corroboration (two consecutive abnormal snapshots or a known-bad hash rule): automatic quarantine, which is reversible.
- Shutdown: human approval by default; tenants may opt into auto-shutdown only for high-confidence known signatures.
- Feedback loop: operator TP/FP labels feed retraining and precision tracking.
- Monitoring: feature drift, alert rate per tenant, precision on reviewed alerts.
6. Safeguards for automated actions
- Blast-radius limits: for example at most 1% of a tenant's fleet or 20 machines per 10 minutes. Beyond that a circuit breaker trips, actions stop, on-call is paged and the system degrades to alert-only.
- Protected assets: allowlists and tags (domain controllers, critical databases) are never auto-actioned.
- Kill switches at global and tenant level.
- Shadow mode for every new model or policy: log intended actions and compare alert rates before enabling.
- Canary rollout to a few tenants with automatic rollback on alert-rate spikes.
7. Orchestration and rollback
- Each action is a durable workflow: capture
pre_action_state(firewall rules, instance state), execute, verify, mark success. - Failure or a customer
:rollbacktriggers compensating steps: restore previous security groups or restart the instance. - Notifications use an outbox pattern with deduplication and digesting to avoid email floods.
- Model rollback: a versioned registry with the version pinned per tenant, so reverting is a config change.
- Detector outage: take no automated actions and alert operators. Failing closed would cause mass outages.
- A missing agent heartbeat is itself suspicious (the agent may have been disabled), but it yields a warning, not an action.
8. Access control and security
- Every record carries
tenant_id; authorization is enforced in the query layer, not just the UI. Use per-tenant encryption keys where feasible. - Agents authenticate with mTLS and per-machine credentials; snapshots are signed to prevent spoofing or replay.
- Least-privilege executor roles: the action executor can only touch resources of the tenant that owns the machine, and cross-tenant calls are rejected.
- Approvals and policy changes require RBAC roles and are audited.
9. Trade-offs and common mistakes
- Latency vs. cost: the two-tier model trades a small detection delay on escalated cases for large GPU savings.
- Consistency vs. availability: the action path uses strong consistency; history reads can tolerate slightly stale replicas.
- Automation vs. safety: more automation shortens response time but raises the cost of a false positive. Reversible actions are the lever.
- Common mistakes: shutting machines down on a single score; no fleet-wide rate limit; ignoring duplicate deliveries; failing closed on detector outages; no pre-action state, making rollback impossible; mixing tenants in queries; skipping shadow mode for new models.