Security Incident and Breach Response Questions
Responding to security incidents and data breaches: containment, breach-response protocols, coordinating with security and legal, and post-breach analysis. Covers security-specific incident handling including cryptographic monitoring and lessons learned from security incidents. The security-operations overlap of incident response, distinct from general reliability incidents.
Design a detection pipeline to identify data exfiltration from object storage (for example S3) and network logs. Include data sources to ingest, anomaly detection approaches, baseline modeling, alerting thresholds, and investigative actions once exfiltration is suspected. Discuss how you would reduce false positives while catching stealthy exfiltration.
Sample Answer
Requirements & constraints:
- Detect small-scale and bulk exfiltration from object storage (S3) and network egress with low false positives, near real-time (minutes), scalable to petabyte logs, and support forensic investigation.
High-level architecture:
- Ingest: S3 access logs, CloudTrail (or provider audit), VPC flow logs, firewall/proxy logs, DNS logs, GuardDuty-like findings, IAM/auth logs, endpoint telemetry (optional).
- Streaming pipeline: log collectors → Kafka/Kinesis → enrichment (user, role, geo, asset tags) → feature store → detection engines (stateless rules + ML) → alerting & case management (PagerDuty, SIEM).
- Storage: hot store for recent sliding window (Elasticsearch/ClickHouse), cold S3 for long-term forensics.
Detection approaches:
- Rule-based (fast): large GET/HEAD counts, high bytes out, anomalous public ACL changes, data-transfer API spikes, use of new keys/roles, anomalous presigned URL creation.
- Behavioral baselines: per-entity (user, role, service account, IP, bucket) time-series baselines for volume, object count, unique keys accessed, time-of-day patterns using EWMA or seasonal ARIMA.
- Anomaly scoring / unsupervised ML: isolation forest / LOF / gaussian-mixture on features (bytes/hour, objs/hour, uniq prefixes, destination ASN, DNS entropy, transfer chunk sizes). Sequence models (LSTM) to detect subtle pattern deviations (slow drip).
- Graph analytics: build bipartite graphs (principal ↔ object prefixes) and flag sudden creation of new dense edges or exfil path chains.
Baseline modeling & thresholds:
- Use 30–90 day rolling baselines, with seasonal decomposition (weekday/hour). Compute z-scores and percentile bands per-entity; adaptive thresholds: alert if z > 4 or if combined anomaly score > calibrated value. Require multi-signal correlation: e.g., elevated S3 bytes + unusual destination ASN + new access key used.
Alerting & triage:
- Tiered alerts: P0 (mass exfil > X TB or many objects), P1 (sustained elevated bytes + suspicious external IP/ASN), P2 (single high-risk artifact like public ACL change).
- Include contextual enrichment in alert: actor, source IP, geo, bucket sensitivity tag, objects/prefixes, presigned URL tokens, recent IAM changes, related network flows.
- Automated response playbooks: short-term containment (revoke key, block IP, suspend role, apply bucket policy), preserve evidence (snapshot logs, object versions, VPC mirror), and notify stakeholders.
Investigation actions:
- Pivot on actor → list accessed objects, last-modified, presigned URLs; pivot on dest IP/ASN → reverse DNS, passive DNS, threat intel match; reconstruct transfer timeline from logs; capture memory/endpoint artifacts if host involved.
- Forensic steps: preserve S3 versions, CloudTrail logs, flow logs; escalate to incident response with legal chain if P0.
Reducing false positives while catching stealthy exfil:
- Require multi-signal correlation; use risk-scoring combining behavior z-scores with asset sensitivity and threat intel (risk = sensitivity * anomaly_score).
- Use adaptive thresholds (percentiles) per-entity rather than global static thresholds.
- Implement cooldowns and suppression based on known maintenance/backup windows and whitelists for high-volume services (with short-lived exceptions tracked).
- Continuous feedback loop: label analyst-verified alerts to retrain ML models; use active learning for rare true positives.
- Monitor concept drift and rebaseline frequently; apply anomaly explainability (feature contributions) so analysts can triage quickly.
Operational considerations:
- SLOs: detection latency, false positive rate target, mean time to acknowledge.
- Scalability: partitioning by account/region; sampling for heavy flows but ensure sensitive buckets always fully monitored.
- Privacy/compliance: minimize PII in central stores, role-based access to forensic data.
This design balances fast deterministic signals for urgent containment with behavioral and graph models to surface stealthy slow exfiltration while minimizing analyst noise via correlation, enrichment, and continuous model feedback.
You discover a persistent backdoor across thousands of Linux hosts created by a malware campaign. Design an eradication plan that uses immutable infrastructure or automation to remove the backdoor, rotate credentials, and verify remediation without causing unacceptable downtime. Include rollback and verification steps and how to handle hosts that cannot be immediately replaced.
Sample Answer
Goal: Remove the backdoor from all Linux hosts with zero-trust, automated, immutable-infrastructure principles—minimize downtime, rotate credentials, verify remediation, and provide rollback + handling for hosts that can’t be immediately replaced.
Plan (phases)
- Triage & containment (hours)
- Stop further spread: update network controls (ACLs, NAC, firewall) to block known C2 IPs/domains and suspicious egress. Disable exposed management ports at edge and isolate high-risk subnets.
- Notify stakeholders, open incident channel, declare SLO/availability constraints.
- Snapshot forensic evidence (disk, memory) of representative infected hosts and preserve hashes.
- Assessment & scope (hours)
- Inventory infected population via orchestration/CMDB, DNS logs, EDR/osquery fleet queries, and SIEM indicators.
- Identify which workloads are ephemeral (containers, autoscaled VMs) vs. stateful (DBs, appliances) and which cannot be replaced immediately.
- Build immutable replacement images (day 1)
- Create golden images (AMI/container images) from a clean build pipeline (Packer/CI). Bake:
- OS patches, minimal packages, audited SSH config, host-based firewall, endpoint agent config, and read-only root where possible.
- File integrity agent (AIDE/osquery), syscalls auditing (auditd), telemetry/OTel metrics and logs.
- Sign images/artifacts and publish to trusted registry.
- Automated rollout with canary and batching (day 1–3)
- Use orchestration (K8s DaemonSets for nodes where relevant; autoscaling groups or cluster node replacement for VMs via Terraform/ASG) to replace hosts:
- Canary small percentage (1–3%) in low-risk zone; run smoke tests and integrity checks.
- Gradual progressive rollout in batches sized to meet availability SLOs; warm new nodes before draining old ones.
- For services behind load balancers: drain connections from old host, wait for graceful shutdown, cutover.
- Credential and secret rotation (parallel)
- Immediately revoke and rotate all privileged credentials associated with compromised hosts:
- Rotate cloud IAM keys, service account tokens, SSH keys, API tokens via Secrets Manager (HashiCorp Vault/AWS Secrets Manager) with short TTLs.
- Force reissue of ephemeral certs (vault/ACME) and revoke long-lived credentials.
- Automate rotation via API: disable old creds, create new creds, deploy to new images only. Log and monitor all rotations.
- Verification & attestation (continuous)
- Post-deploy automated checks on each replaced host:
- File-integrity baseline comparison, process whitelisting, known malicious indicators (YARA), kernel module list, listening ports check.
- Run osquery queries to assert absence of backdoor artifacts and check cron/systemd units.
- Endpoint telemetry: confirm no suspicious outbound connections, CPU/network anomalies.
- Use remote attestation/TPM or signed image verification where available.
- Centralize results in SIEM; gate progression on 100% pass for batch before next.
- Rollback & safety nets
- Keep previous known-good image and deployment pipeline to roll back quickly if new image causes regressions.
- Rollback strategy: stop new deployment, re-launch previous signed image via automation, restore traffic by reversing DNS/load-balancer targets, revoke problematic configs.
- Maintain canary health checks with automatic abort of rollout on threshold (e.g., 5xx, latency, error budget breach).
- Handling hosts that cannot be immediately replaced
- Quarantine: move to isolated VLAN, restrict outbound traffic, block management access except forensic team.
- Live remediation: run immutable, idempotent cleanup scripts via signed automation (Ansible playbook with attestations) that:
- Stop malicious processes, remove artifacts, reset file permissions, enforce immutable configs.
- Reinstall from package manager and reapply signed config from central repo.
- Enroll into monitoring and attestation agents.
- If live remediation is used, require reimage within defined SLA (e.g., 72 hours). For critical stateful systems, perform staged reimage with data migration/backups and verified restores.
- Post-incident validation & hardening
- Full audit trail: collect telemetry, SIEM dashboards, and run a second independent scan (third-party AV/IR).
- Enforce infrastructure changes: mandatory immutable images for all new deployments, remove SSH from images, use bastion + ephemeral SSH certs, shift to short-lived credentials, and enable mandatory signed image verification.
- Update runbooks, incident report, and run tabletop exercises.
Key automation & tools
- CI/CD + Packer for image builds; Terraform/CloudFormation + Autoscaling for infra; Kubernetes for container workloads.
- Secrets Manager/Vault for rotation automation.
- Orchestration for live commands: Ansible/Runbooks for controlled remediation.
- osquery, AIDE, EDR (CrowdStrike/Carbon Black) and SIEM (Splunk/Datadog) for verification.
- Feature flags, health checks, and circuit breakers for safe rollout.
Metrics & acceptance criteria
- % hosts reimaged per hour, mean time to remediate (MTTR), percentage of hosts passing integrity checks, service error rates, and incident mean time to detect (MTTD).
- Rollout abort thresholds: service SLO degradation > X% or error spikes.
Why this works
- Immutable images guarantee clean state and reduce human error.
- Automation and canary/batched rollouts preserve availability and enable quick rollback.
- Credential rotation closes lateral movement.
- Quarantine + live remediation handles edge cases while enforcing eventual reimage.
This plan balances speed, safety, and forensic preservation while using immutable infrastructure and automation to eradicate the backdoor reliably.
Design an incident response process for an enterprise handling regulated financial data. Requirements: preserve evidence for audits, complete regulatory reporting within 24 hours of detection, restrict communications appropriately, and automate data preservation where possible. Describe roles, data preservation steps, templates, and validation/testing of the process.
Sample Answer
Requirements clarification:
- Preserve chain-of-custody and immutable evidence for audits
- Meet regulatory report filing within 24 hours of detection
- Limit external/internal communications per policy
- Automate preservation where possible
High-level process (phases):
- Detect & Triage (0–1h)
- Automated alerts enrich with context (asset owner, data classification, regulatory flags). SRE runbook triggers containment if availability impacted.
- Contain & Preserve (1–4h)
- Immediately invoke automated preservation playbook: snapshot VMs/containers, enable write-block on affected storage, export relevant logs (app, OS, network, cloud audit) to WORM storage (immutable S3/GCS bucket) and SIEM with retention tags.
- Capture volatile memory where required using forensics tool (automated via orchestrator on affected host).
- Record chain-of-custody in an audit ledger (timestamped, signed entries).
- Investigate & Remediate (4–18h)
- Forensic team (SRE + Security + Legal + Compliance + Business owner) performs analysis on preserved artifacts.
- All actions recorded; no destructive changes to preserved copies.
- Report & Communicate (within 24h)
- Compliance completes regulatory report using prefilled template (see below). Communications must follow approved whitelist: internal incident channel, legal-approved statements, and regulator contact.
- Post-Incident (after 24h)
- Postmortem, root-cause, remediation plan, lessons learned, and evidence retention verification.
Roles & responsibilities:
- Incident Commander (rotating SRE on-call): coordinate technical response, declare containment.
- Forensics Lead (Security): direct evidence capture, maintain chain-of-custody.
- Compliance Officer: prepare regulatory filings, liaise with regulator.
- Legal: approve external communications and escalation decisions.
- Service Owners/Dev Teams: supply context, implement fixes.
- Automation Engineer (SRE): author/maintain automation playbooks.
Data preservation steps (automated where possible):
- Tag incident assets and trigger IaC job to snapshot disks & containers.
- Export logs: systemd/journal, application logs, auth logs, cloud provider audit logs, network PCAP for a limited window to immutable storage.
- Lock relevant user accounts and API keys (automated rotation workflows).
- Store checksums and digital signatures of artifacts in the audit ledger.
Templates (pre-approved):
- Regulatory Report Template: incident ID, detection time, systems affected, data classification, containment actions, preservation artifacts (locations + checksums), estimated impact, next steps, contact points.
- Internal Communication Template (tiered): internal urgent, business stakeholders, approved external statement.
- Chain-of-Custody Form: artifact ID, timestamp, captured-by, capture-method, storage location, integrity hash, signer.
Automation examples (implementation snippets):
- IaC/Orchestration job triggers snapshot and uploads logs to WORM bucket; sample pseudocode (cron/CI job) automates S3 put with ObjectLock.
- SIEM integration rule auto-tags artifacts and creates incident ticket with prefilled regulatory template.
Validation & testing:
- Quarterly tabletop exercises with Compliance, Legal, Security, SRE, and Business to validate timelines and decision paths.
- Monthly automated drill: simulate low-severity incident that runs preservation playbook end-to-end (snapshots, log export, ledger entry) in staging; verify immutability and hashes.
- Annual full-scale live drill with regulator-facing reporting exercise to confirm 24-hour reporting pipeline.
- KPIs: time-to-preserve (target <2h), time-to-report (<=24h), preservation completeness (percentage of required artifact types captured).
- Audit checks: periodic verification that WORM storage enforces retention policies and ledger integrity (signed hashes match stored artifacts).
Trade-offs and controls:
- Limit PCAP collection window to balance privacy and storage costs; preserve metadata as fallback.
- Use role-based access control and approval workflows to prevent unauthorized communication or evidence tampering.
This design ensures technical automation for rapid preservation, clear roles for compliance demands, templates to accelerate reporting, and regular validation so the 24-hour regulatory requirement and auditability are reliably met.
Compare and contrast the primary responsibilities and handoff points between SRE and SOC teams during a security incident that impacts service availability. Provide a concrete example workflow describing who owns detection, containment, forensic evidence collection, customer communication, and regulatory notification.
Sample Answer
High-level comparison:
- SRE primary focus: restore availability and limit customer impact quickly using runbooks, mitigations, rollbacks, and infrastructure controls. SRE owns service-level triage, traffic routing, scaling, and short-term containment to meet SLOs.
- SOC/SECOPS primary focus: detect, analyze, attribute, and remediate security threats, preserve forensic integrity, and fulfill compliance/regulatory obligations. SOC owns threat investigation, evidence collection, and external reporting requirements.
- Handoff principle: SRE leads availability-first actions; SOC leads security investigation — both coordinate continuously and escalate ownership as scope shifts from operational to security.
Concrete example workflow (suspected DDoS causing service outage):
-
Detection
- SRE alert: monitoring (latency/error-rate/traffic anomalies) fires and SRE on-call investigates. Simultaneous SOC IDS/IPS and SIEM alerts flag abnormal source IP distribution.
- Ownership: initial detection — SRE; correlated security signals — SOC. They immediately notify each other.
-
Containment / Mitigation (minutes)
- SRE actions: apply traffic-shaping, enable rate-limiting, scale edge/proxy, shift traffic to healthy regions, or switch to static maintenance page per runbook to protect backend.
- SOC actions: provide blocklists, confirm malicious patterns, update WAF/edge ACLs.
- Ownership: SRE executes availability mitigations; SOC validates and recommends security filters. Changes are coordinated and logged.
-
Forensic Evidence Collection (during/after containment)
- SOC leads chain-of-custody and log preservation: collect packet captures, SIEM logs, authentication trails, WAF logs, and snapshot affected instances with forensic tools.
- SRE supports by freezing affected systems, exporting application logs, preserving metrics and deployment metadata, and ensuring no further writes overwrite evidence.
- Ownership: SOC owns integrity and legal standards; SRE provides technical access and artifacts.
-
Customer Communication
- SRE owns real-time service status updates: incident pages, status.io, ETA for service restoration, and mitigation steps to customers.
- SOC provides sanitized security details if needed (e.g., "malicious traffic identified") and advises on messaging to avoid exposing sensitive investigative details.
- Ownership: SRE leads operational communication; SOC reviews security-sensitive language.
-
Regulatory Notification & Post-Incident
- SOC determines if the incident meets breach/regulatory thresholds (data exfiltration, PII exposure) and manages legal/Compliance notifications (e.g., GDPR/PCI).
- SRE contributes timelines, impact metrics, and remediation actions for reports and the postmortem.
- Ownership: SOC leads regulatory notifications; SRE co-authors technical sections and implements long-term hardening.
Coordination practices:
- Use a joint incident bridge with clear roles: Incident Commander (SRE for availability), Security Lead (SOC), Communications owner, and Recorder.
- Share a shared timeline and artifact bucket; every action logged with timestamps.
- Post-incident: joint postmortem separating availability remediation (SRE action items) from security remediations (SOC action items) with owners and SLAs.
This separation ensures fast restoration while preserving forensic integrity and meeting compliance obligations.
Design a concise runbook / playbook for suspected service compromise where an unauthorized admin session was detected. The runbook should include detection validation steps, containment actions safe for production, evidence collection commands or automation, stakeholder notification steps, and criteria to escalate to the security team or legal.
Sample Answer
Situation: An alert or log indicates an unauthorized admin session (e.g., console login, sudo/root shell, kubectl cluster-admin use). This runbook gives steps for validation, safe containment in production, evidence collection, notifications, and escalation.
- Detection validation (first 10–15 min)
- Confirm alert source: SIEM/IDS, cloud console, audit logs, PAM.
- Verify session details: user account, source IP, auth method, time window, MFA status.
- Quick checks:
- Linux: last -F, who, w, sudo -l -U <user>
- Cloud: aws iam get-login-profile, gcloud audit-logs query
- K8s: kubectl get events --all-namespaces; kubectl auth can-i --as=<user> --namespace=...
- Tag incident in tracker (ID + timeline).
- Containment (safe for production)
- Do NOT immediately reboot or terminate unless active malicious activity confirmed.
- Isolate session: revoke active tokens/sessions for the account first.
- Linux: pkill -u <user> (if safe), kill <pid> for suspicious shells
- K8s: kubectl delete token secrets for serviceaccount; cordon affected node only if node-compromise suspected
- Cloud: revoke API keys, rotate credentials, disable account in IAM with temporary deny
- Apply network-level controls: block source IP via WAF/security group/NSG or firewall, add temporary ACL rule.
- Evidence collection (immutable-first, document timestamps)
- Capture volatile evidence before changing state:
- ps auxwww > /tmp/ps.out; lsof -nP > /tmp/lsof.out
- netstat -tunap or ss -tunap
- last -F; who; history (copy ~/.bash_history)
- dmesg > /tmp/dmesg.out; /var/log/auth.log or /var/log/secure: tail -n 500
- K8s: kubectl get pods --all-namespaces -o wide; kubectl describe pod <suspect>
- Cloud: export CloudTrail / Audit logs for timeframe; snapshot VM disks (read-only) and export to secure storage.
- Hash and store artifacts: sha256sum files, upload to central evidence bucket with access logging.
- Automate with playbook (example): run a vetted script via bastion that collects above and pushes to S3/GCS.
- Stakeholder notification
- Immediately notify: on-call SRE, team lead, SOC (if available).
- Post initial validation (within 30–60 min): notify Incident Commander, Product/Service owner, and Legal (if PII/compliance).
- Use configured channels: pager duty, secure chat channel, and incident tracker with statuses and actions taken.
- Escalation criteria to Security/Legal
- Escalate to Security ASAP if any of:
- Evidence of data exfiltration, lateral movement, persistence, or privileged credential theft.
- Compromise spans multiple hosts/accounts or production-impacting resources.
- Adversary left backdoors (new users, scheduled tasks, unknown binaries).
- Escalate to Legal/Compliance if:
- Personal data access/exposure, regulatory scope, or breach notification thresholds.
- If escalated, freeze further remediation that could destroy evidence until SOC/legal advise.
- Post-containment actions
- Rotate credentials, rebuild compromised hosts from known-good images, re-deploy containers from trusted artifacts.
- Conduct root cause analysis, timeline, and post-incident review; update runbook and playbooks.
Keep logs of every action (who, what, when, why). Prioritize preserving evidence and minimizing production impact while removing attacker access.
Unlock Full Question Bank
Get access to all 19 Security Incident and Breach Response interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.