Engineering Atlas › Problem Solving & Incidents (AI era)

Security Incident Response

13 min read · last reviewed 2026-10-17

Open in the interactive app: practice, quiz, mock interview →

In one minute

How it works

What makes security incidents different

In an outage, the system is your adversary only by accident. In a security incident, a person is actively trying to keep access, hide their tracks and expand their reach. That changes three things. Evidence: logs, disk images and memory may be needed to understand scope and for legal reasons, so you capture them before rebuilding machines. Secrecy: until containment is ready, alerting the attacker can make them destroy evidence or dig in deeper. Obligations: data protection laws and contracts often require notifying regulators or customers within fixed deadlines (GDPR's is 72 hours after the controller becomes aware of a personal data breach, where feasible; a processor must tell the controller without undue delay and has no separate 72-hour clock, per GDPR Article 33), so legal and communications join early.

The lifecycle

Prepare. Logging that would let you answer "who did what, when" (cloud audit logs, authentication logs, database access logs), retained for months. A response plan with roles and contacts, including legal. Break-glass accounts. Practised drills.

Detect and analyse. Alerts from secret scanning, anomaly detection (logins from new countries, unusual API calls), customer or researcher reports. Confirm it is real, assess severity, declare. Most alerts are not crises: triage weighs the data at risk, the trust relationships the attacker could use, which controls still hold, and whether the activity looks commodity or targeted (Building Secure and Reliable Systems, ch. 17). Name an incident commander who accepts the role, as in any other incident.

Contain. Short-term: revoke credentials, isolate hosts (network quarantine rather than shutdown, to keep memory evidence), block attacker IPs, disable compromised accounts. Long-term: patch the hole, harden. The pull towards fixing at once is strong, but locking accounts or wiping machines before you know the scope tells the attacker you are there, and they may hide footholds or destroy data. Google's security responders therefore finish enough investigation first, unless an imminent, clearly identified risk justifies shutting things down and revealing the response (Building Secure and Reliable Systems, ch. 17).

Eradicate and recover. Remove persistence (new accounts, keys, scheduled tasks, backdoors the attacker created), rebuild from known-good images, restore data, monitor closely for return.

Learn. Blameless review, as for any incident, plus the specific question: how did they get in, and how would we have detected it sooner?

NIST published SP 800-61 Rev. 3 in April 2025, superseding the 2012 revision. It drops the four-phase loop as the organising model and uses the six CSF 2.0 functions instead (Govern, Identify, Protect, Detect, Respond, Recover). Detect, Respond and Recover are the incident response itself; Govern, Identify and Protect are the wider risk management that supports it, and lessons learned are meant to flow into improvement continuously instead of waiting for the end (NIST SP 800-61r3). The activities in this lesson are the same; only the packaging changed.

The leaked credential playbook

A secret in a public repository, a log file, a screenshot, or an agent's context sent to the wrong place. Steps:

  1. Revoke or rotate immediately. Assume it was used. Automated scanners find public secrets within minutes.
  2. Determine capability: what could this credential do? Its IAM policy, scopes and network restrictions.
  3. Determine use: what did it do? Query audit logs for every action by this credential since the earliest time it could have leaked, separating known legitimate sources (your servers' IPs, CI) from unknown ones.
  4. Scope impact: which resources were read, changed or created; was data copied out; were new credentials or accounts created (persistence)?
  5. Remove persistence and fix the leak path (secret scanning in pre-commit and CI, secrets in a manager, short-lived credentials).

The same shape everywhere

A security incident is the trust-but-verify and partial-failure shapes under adversarial pressure: you cannot trust the system's own view of itself, so you rely on independent records, and you assume the worst until evidence narrows it down. Fraud teams, auditors and physical security follow the same pattern: contain, preserve evidence, scope, remediate, report.

Down the stack

Layer 1The contract

A security response capability promises: any credential can be revoked within minutes; audit logs answer "what did this identity do" for at least the retention period; responders can isolate a host or account without destroying evidence; and legal and communication decisions are made by named people within the required deadlines.

Layer 2The mechanism

Cloud audit logs record every API call with the identity, source IP, user agent, time, action and resource; AWS CloudTrail, Google Cloud Audit Logs and Azure Activity Log all follow this pattern. Investigation is a query: filter by access key ID, sort by time, group by action and resource, mark source IPs that are not yours. Revocation depends on the credential type: long-lived keys can be deactivated immediately; issued session tokens may remain valid until expiry unless you also revoke active sessions. AWS temporary credentials last 15 minutes to 36 hours (12 hours by default), and to cut off a stolen session you change the permissions of the user or role, or deny the session by condition, since permissions are evaluated on every request (AWS IAM docs). That is why short-lived credentials limit exposure. Secret scanners match known token formats (prefixes such as ghp_ for GitHub tokens or AKIA for AWS access keys, where ASIA marks temporary keys (AWS IAM identifiers)) plus entropy checks. GitHub scans public repositories automatically and notifies partner providers, who can then act, for example by revoking the credential (GitHub docs).

Layer 3The machine

On a compromised host, evidence lives in volatile and durable layers. Memory holds running processes, network connections and decrypted secrets, lost on reboot, so responders capture it first or isolate the host's network while leaving it running. ss -tanp and /proc/<pid>/ show live connections and process details; the kernel's audit subsystem (auditd) can log system calls such as execve for every command run. Disk images preserve files and timestamps, though attackers may alter modification times; file system journals and log shipping to a separate, append-only store make tampering harder. This is why logs should leave the host as soon as they are written.

Why it's built this way

  1. An adversary adapts and hides, so you need records they cannot alter and actions they do not see coming.
  2. Credentials are the most common entry point, so revocation must be fast and detection of misuse must be possible from logs.
  3. Evidence is fragile, so it is captured before systems are rebuilt.
  4. Legal deadlines and customer trust require early, coordinated communication.
  5. Learning focuses on entry and detection, because those determine the next incident's size.

Diagram

flowchart TD
  D["Detect: secret scanner alert"] --> R["Revoke and rotate key now"]
  R --> C["Capability: what could it do?"]
  C --> U["Use: audit logs since leak time"]
  U --> S["Separate known sources from unknown"]
  S --> I["Impact: resources read, changed, created"]
  I --> P["Remove persistence: new keys, users, roles"]
  P --> L["Legal and comms decide notification"]
  L --> F["Fix leak path, learn"]

Worked example

At 14:05, GitHub secret scanning alerts that an AWS access key was pushed to a public repository at 13:52 in a demo project. The key belongs to a CI user with read access to two S3 buckets and permission to create IAM access keys (an over-broad permission left from an old migration).

14:08: the key is deactivated. 14:10: an incident is declared with a security lead as incident commander, a separate channel, and legal informed. 14:15 to 14:50: CloudTrail is queried for all events by the key ID since 13:52. Results: 214 events from the CI system's known NAT IPs (legitimate builds); 37 events from an unknown IP starting at 13:58, six minutes after the push. Those include ListBuckets, GetObject on 1,240 objects in the exports bucket, and one CreateAccessKey for a different IAM user at 14:01.

The created key is persistence: the attacker had a second key that survived the first revocation. It is deactivated at 14:52; queries on it show 12 more calls, all reads, ending at 14:40. The exported objects included a customer CSV with names and emails for about 30,000 users, so legal begins the notification assessment within the 72-hour window. Fixes: remove iam:CreateAccessKey from CI, replace long-lived keys with short-lived OIDC federation for CI, pre-commit secret scanning, and an alert on any CreateAccessKey call.

In the wild

Trade-offs

ChoiceStrengthsWeaknessesChoose when
Revoke immediatelyStops further use fastMay alert attacker, may break legitimate jobsLeaked credentials, almost always
Observe before containingLearn attacker's scope and toolsRisk of more damageRare, with expert responders and low data risk
Isolate host, keep runningPreserves memory evidenceAttacker may still act locallySuspected host compromise
Rebuild from known-good imageRemoves hidden persistenceLoses evidence if not captured firstAfter evidence capture
Short-lived credentialsLimits exposure windowSetup effortDefault for automation and agents

Pitfalls in production

Leadership lens

Check yourself

  1. Why search for actions like CreateAccessKey after a key leak?

    Show answer

    Attackers create new credentials to keep access after the original is revoked; finding and revoking them is part of containment.

  2. Why might you isolate a compromised host rather than shut it down?

    Show answer

    Shutting down loses memory evidence such as running processes, connections and keys; isolation stops network activity while preserving it.

  3. Why do short-lived credentials reduce incident impact?

    Show answer

    A leaked token expires quickly on its own, shrinking the window in which an attacker can use it.

  4. Why coordinate on a separate channel during a security incident?

    Show answer

    The attacker may have access to normal systems, including chat or email, and could watch the response and adapt.

Sources and further study

Primary

Systems docs

Books

Other curricula

Free resources

Open in the interactive app: practice, quiz, mock interview →