Incident Response Day 3
SCS-C03 · Domain 2 · Incident Response (14%) · Day 3 of 3

Responding to security events

Day 2 automated the response and captured forensic evidence. Today is the response itself: searching and correlating logs, checking whether a finding is real and how big it is, containing stolen credentials, hacked instances, buckets, functions and containers, recovering from clean backups and images, and finding the root cause with Amazon Detective. It ends with a review quiz across all three Incident Response days.

Skill 2.2.2 search and correlate logsSkill 2.2.3 validate findingsSkill 2.2.4 contain, eradicate, recoverSkill 2.2.5 root cause analysisDomain 2 review~95 min read + 30 min lab
01

Searching logs: CloudTrail Lake, Athena and Logs Insights

When an alert fires, the first question is always “what exactly happened?”. Skill 2.2.2 asks you to search and correlate logs across services. In practice that means asking the same questions of CloudTrail (who called which API), VPC Flow Logs (which IPs talked), application logs and service logs, and lining the answers up by time, user and IP address.

AWS gives you three main query tools. Which one is right depends mostly on where the logs already live. The exam likes the cheapest tool that works without moving data.

Concept profile

Amazon Athena on CloudTrail logs

often confused with CloudTrail Lake
?What is it?

Serverless SQL over log files stored in Amazon S3. You create a table that describes the CloudTrail JSON format (the CloudTrail console can create it for you), then query months of API history with standard SQL.

⚙How does it work?
  • Point a table at the trail’s S3 prefix. Use partition projection on Region and date so queries scan only the days you ask for.
  • You pay for the data scanned, so always filter on the date partition.
  • The same approach works for VPC Flow Logs, ALB access logs, S3 server access logs and WAF logs, so you can join them on IP address and time.
  • Results go to an S3 output location, which is useful as evidence.
{ }Structure
CloudTrail LakeEvent data stores (ORC, immutable)SQL (Trino SELECT) + AI generatorRetention up to about 10 yearsNon-AWS events: PutAuditEventsClosed to new customersfrom 31 May 2026Amazon AthenaSQL on CloudTrail logs in S3Table from the CloudTrail consolePartition projection = fasterPay per data scannedJoin with VPC Flow / ALB logsWorks on any log in S3CloudWatch Logs InsightsLog groups (trail sent to CWL)Logs Insights QL, PPL or SQLNatural-language query helpTimeout 60 min, results 7 daysPay per GB scannedFast for recent app logsPick the tool by where the logs already areTrail delivered to S3 only → Athena. Logs in CloudWatch Logs → Logs Insights.Existing event data store → CloudTrail Lake SQL. Many sources, one schema → Security Lake.
Three query tools and how to choose between them.
⇄Athena vs CloudTrail Lake
Athena on S3 logsCloudTrail Lake
Data locationYour S3 bucket (trail files)Managed event data store
FormatJSON files you describe with a tableORC, already queryable
RetentionAs long as you keep the S3 objectsUp to about 10 years (one-year extendable pricing) or 7 years
Non-AWS eventsAny file you put in S3PutAuditEvents integrations
New customersOpenClosed from 31 May 2026; existing customers continue
!Common mistakes the exam tests
  • Querying CloudTrail with Athena without date partitions: slow and expensive.
  • Expecting data events (S3 object reads, Lambda invokes) in a trail that only logs management events: they must be enabled before the incident.
  • Choosing CloudTrail Event history for a 6-month search: it covers only 90 days of management events.
  • Picking CloudTrail Lake for a brand-new account in a 2026 scenario: AWS closed it to new customers on 31 May 2026.
  • Forgetting that Logs Insights can only search what was sent to CloudWatch Logs; a trail that goes only to S3 needs Athena.
✓Benefits and use cases
  • Find every API call made with a leaked access key.
  • List all actions from one source IP across accounts (organization trail).
  • Join CloudTrail with VPC Flow Logs to follow an attacker from login to data transfer.

CloudTrail Lake and CloudWatch Logs Insights

CloudTrail Lake stores events in event data stores that you query with SQL (Trino SELECT statements), and it has a query generator that writes SQL from an English prompt. It can also hold AWS Config items and events from outside AWS. Important for 2026: CloudTrail Lake is no longer open to new customers from 31 May 2026; existing customers keep using it, and AWS recommends migrating to Amazon CloudWatch (organization-wide CloudTrail ingestion, OCSF pipelines, S3 Tables for Athena). CloudWatch Logs Insights queries log groups with the Logs Insights query language, OpenSearch PPL or OpenSearch SQL. Queries time out after 60 minutes, results stay available for 7 days, and you pay per GB of data scanned. It is the natural choice for application logs, Lambda logs, VPC Flow Logs sent to CloudWatch, and a trail delivered to CloudWatch Logs.

Think of it like · a library after a theft

Different ways to search the records.

AWS conceptFamiliar thing
CloudTrail≈The visitor book: who came in, when, and what they asked for
Athena on S3≈Reading old visitor books from the archive room with a good index
Partition projection≈Shelves labelled by year and month so you only open the right box
CloudTrail Lake≈A ready-made searchable database of the visitor book, now only for existing members
Logs Insights≈Searching today’s CCTV notes and staff reports quickly
Correlation≈Matching the visitor book with the CCTV time stamps
Real AWS example · follow a leaked key in Athena and Logs Insights

First Athena over the S3 trail, then Logs Insights over the trail’s log group.

-- Athena (table created from the CloudTrail console)
SELECT eventtime, eventsource, eventname, sourceipaddress, errorcode
FROM cloudtrail_logs_org_trail
WHERE useridentity.accesskeyid = 'AKIAIOSFODNN7EXAMPLE'
  AND timestamp >= '2026/10/08'
ORDER BY eventtime;

# CloudWatch Logs Insights (log group: aws-cloudtrail-logs-org)
fields @timestamp, eventName, sourceIPAddress, errorCode
| filter userIdentity.accessKeyId = "AKIAIOSFODNN7EXAMPLE"
| stats count(*) as calls by eventName, sourceIPAddress
| sort calls desc

Look for CreateUser, CreateAccessKey, AttachUserPolicy and RunInstances: attackers create persistence and crypto miners first.

Many AccessDenied errors from one IP usually mean the attacker was exploring permissions.

Exam-style scenario

A security engineer must find every API call made with a compromised access key over the last 8 months. The organization trail delivers logs only to an S3 bucket. The company has never used CloudTrail Lake. What is the most cost-effective approach?

  1. A. Use CloudTrail Event history in the console.
  2. B. Create an Athena table with partition projection over the trail’s S3 prefix and query by access key ID and date.
  3. C. Create a CloudTrail Lake event data store and import the logs.
  4. D. Stream the S3 logs to CloudWatch Logs and use Logs Insights.
Show the worked answer

Answer: B

Athena queries the logs where they already are, and partitions keep the cost low.

Why not the others

  • A: Event history covers only the last 90 days of management events.
  • C: CloudTrail Lake is closed to new customers since 31 May 2026, and importing costs more.
  • D: Moving months of logs into CloudWatch is slow and expensive.
How the exam tests this
  • “Query CloudTrail logs stored in S3 with SQL”→ Athena (partition projection).
  • “Search Lambda or app logs in CloudWatch”→ Logs Insights.
  • “Last 90 days of management events, no setup”→ CloudTrail Event history.
  • “Who read objects in a bucket?”→ CloudTrail data events (must be enabled first).
  • “SQL over existing event data stores”→ CloudTrail Lake (existing customers).
Must remember
  • Pick the tool by where the logs are.
  • Athena: filter on date partitions.
  • Event history = 90 days, management events.
  • Logs Insights: 60 min timeout, results 7 days.
  • CloudTrail Lake: closed to new customers from 31 May 2026.
02

Correlating across sources: Security Lake and OpenSearch

A real attack crosses many log types: a phishing login (identity logs), API calls (CloudTrail), DNS lookups (Route 53 Resolver), network traffic (VPC Flow Logs) and maybe a firewall outside AWS. Each tool writes its own format. To correlate them you want one schema and one place to query.

Concept profile

Amazon Security Lake

often confused with CloudTrail Lake
?What is it?

A managed security data lake in your own account. It collects logs and findings from AWS services and third parties, converts them to the Open Cybersecurity Schema Framework (OCSF), and stores them as Apache Parquet in S3.

⚙How does it work?
  • Native AWS sources: CloudTrail management and data events, VPC Flow Logs, Route 53 Resolver query logs, Security Hub CSPM findings, EKS audit logs and AWS WAF logs.
  • Custom sources (on-premises, SaaS, partner tools) write OCSF Parquet into the lake.
  • Rollup Regions combine data from many Regions into one, which also helps with data residency rules.
  • Subscribers: query access through Lake Formation tables (Athena, Redshift, OpenSearch) or data access where a tool is notified of new objects and reads the files.
{ }Structure
SourcesCloudTrail mgmt + data eventsVPC Flow LogsRoute 53 Resolver logsSecurity Hub CSPM findingsEKS audit logsAWS WAF logsCustom: SaaS, on-prem (OCSF)Amazon Security LakeConverts data to OCSFStores Apache ParquetS3 buckets in YOUR accountRollup Region: many to oneLake Formation controlswho reads which sourceQuery accessAthena / Redshift SQLOpenSearch ServiceDetective raw log searchData accessNotified of new objectsPartner SIEM reads theParquet files directly
Many sources in, one schema out, controlled subscribers.
⇄Security Lake vs CloudTrail Lake
Security LakeCloudTrail Lake
ScopeMany log types and findingsCloudTrail events (plus Config and audit events)
SchemaOCSF, ParquetCloudTrail event format, ORC
StorageS3 buckets you ownManaged by CloudTrail
Query withAthena, Redshift, OpenSearch, partner SIEMsCloudTrail Lake SQL, or Athena via federation
Exam hint“normalize”, “OCSF”, “third-party SIEM”“SQL on CloudTrail events, existing store”
!Common mistakes the exam tests
  • Thinking Security Lake replaces GuardDuty: it stores data; it does not detect threats by itself.
  • Forgetting that the data stays in your S3 buckets, so bucket and Lake Formation permissions matter.
  • Giving a SIEM subscriber all sources in all Regions when it needs only some: subscribers are scoped to sources and Regions.
  • Expecting custom sources to be converted for you: custom data must already be in OCSF.
  • Confusing OCSF (open schema) with ASFF (the older Security Hub CSPM finding format).
✓Benefits and use cases
  • One SQL query across CloudTrail, DNS and flow logs during an investigation.
  • Feeding a partner SIEM without building many pipelines.
  • Keeping long-term security data under your own retention rules.

Amazon OpenSearch Service for investigations

Amazon OpenSearch Service is a search and dashboard engine. Security teams use it as a log analytics platform: near real-time search, dashboards, alerting, and the Security Analytics plugin with detection rules. It can ingest logs (for example through OpenSearch Ingestion) or query data in place, including Security Lake data, through direct query integrations. Choose it when the question says interactive dashboards, full-text search or near real-time alerting over large log volumes. Choose Athena for occasional SQL over S3 at the lowest cost.

Think of it like · an international airport’s control room

Many feeds, one big screen.

AWS conceptFamiliar thing
Different log formats≈Reports from airlines in different languages
OCSF≈Translating every report into one shared language
Security Lake≈A central archive where all translated reports are filed
Rollup Region≈Regional airports send copies to the main hub
Subscriber≈A visiting inspector allowed to read only certain folders
OpenSearch dashboards≈The live wall of screens in the control room
Real AWS example · one IP across all sources in Security Lake

Athena query on the OCSF CloudTrail table. Table names include the Region and source version.

SELECT time_dt, api.service.name, api.operation,
       actor.user.uid, src_endpoint.ip
FROM amazon_security_lake_glue_db_us_east_1
     .amazon_security_lake_table_us_east_1_cloud_trail_mgmt_2_0
WHERE src_endpoint.ip = '203.0.113.9'
  AND time_dt > TIMESTAMP '2026-10-08 00:00:00'
ORDER BY time_dt;

Run the same src_endpoint.ip filter on the VPC flow and Route 53 tables: OCSF uses the same field names, so the queries look alike.

Exam-style scenario

A company has 30 accounts in 4 Regions and an on-premises firewall. Investigators need one schema to query CloudTrail, VPC Flow Logs, DNS logs and firewall logs together, and a third-party SIEM must receive only CloudTrail data from two Regions. What should they use?

  1. A. CloudTrail Lake with event data stores in each account.
  2. B. Amazon Security Lake with a rollup Region, the firewall as an OCSF custom source, and a subscriber limited to CloudTrail in two Regions.
  3. C. CloudWatch Logs cross-account sharing.
  4. D. Amazon Detective.
Show the worked answer

Answer: B

Security Lake normalizes all sources to OCSF and scopes each subscriber to sources and Regions.

Why not the others

  • A: Does not cover flow, DNS or firewall logs in one schema, and is closed to new customers.
  • C: No common schema and no source-level subscriber control.
  • D: Detective visualizes for investigation; it is not a data lake for a SIEM.
How the exam tests this
  • “Normalize security logs into one open schema”→ Security Lake (OCSF).
  • “Combine data from many Regions”→ Rollup Region.
  • “SIEM may read only some sources”→ Subscriber scoped to sources and Regions.
  • “Dashboards and near real-time log search”→ OpenSearch Service.
  • “Bring on-premises firewall logs”→ Custom source in OCSF.
Must remember
  • Security Lake = OCSF + Parquet in your S3.
  • Query access (Lake Formation) vs data access (notifications).
  • Rollup Region = many Regions to one.
  • It stores; GuardDuty detects.
  • OpenSearch = dashboards, search, alerting.
03

Validating findings: scope and impact

A finding is a claim, not a proof. Skill 2.2.3 asks you to validate findings from AWS security services and work out scope (which accounts, identities and resources are involved) and impact (what data, money or availability was affected). Only then do you choose how hard to contain. A false positive treated as a real attack can cause an outage; a real attack treated as noise can cause a breach.

Concept profile

A GuardDuty finding

often confused with A Security Hub finding
?What is it?

A record that GuardDuty detected possibly malicious or unauthorized activity. The finding type tells you the threat purpose, the resource type and the behavior, for example UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS.

⚙How does it work?
  • Severity runs from 1.0 to 10.0: Low 1.0–3.9, Medium 4.0–6.9, High 7.0–8.9, Critical 9.0–10.0.
  • Resource shows the affected entity (access key, user type, instance, bucket); Action shows the API or connection and the remote IP.
  • Count and first/last seen: if Updated at differs from Created at, the activity is repeating and still going on.
  • GuardDuty keeps findings for 90 days; export them (to S3 or Security Hub) to keep them longer.
  • Extended Threat Detection raises attack sequence findings that link many signals into one story with MITRE tactics.
{ }Structure
1 Read the findingtype, severityresource, actor IPCount, first/last seen2 Is it expected?ask the ownerknown scanner, pentest?trusted IP list3 Scopesame key/role elsewhere?Detective finding groupAccess Analyzer, Macie4 Impactwhat data was touched?new users, keys, roles?cost, availabilityGuardDuty severityLow 1.0–3.9Medium 4.0–6.9High 7.0–8.9Critical 9.0–10.0False positive? Archive it, or add a suppression rule for that exact pattern.Suppressed findings are not sent to Security Hub CSPM, S3, Detective or EventBridge.
Read, check, scope, measure impact. Then contain.
⇄GuardDuty finding vs A Security Hub finding
GuardDuty findingSecurity Hub finding
Produced byGuardDuty threat detectionAggregated from GuardDuty, Inspector, Macie, Access Analyzer, CSPM controls
Answers“Something suspicious happened”“What matters most across everything?”
FormatGuardDuty format (also sent on as OCSF)OCSF; CSPM findings in ASFF
Extra contextActor, IP, API, countExposure findings, attack path graph, correlation
ResponseEventBridge, suppression rulesAutomation rules, tickets, EventBridge
!Common mistakes the exam tests
  • Containing without checking: a finding from a known vulnerability scanner or pentest may be expected. Ask the resource owner first, but quickly.
  • Deleting findings you think are false: archive them, or create a suppression rule for that exact pattern. Suppressed findings are not sent to Security Hub CSPM, S3, Detective or EventBridge, and they do not count as signals for attack sequences.
  • Using a broad suppression rule (for example a whole finding type) that hides real attacks.
  • Adding a public IP to a trusted IP list without care: GuardDuty does not create findings for those IPs.
  • Judging impact without data context: use Macie to learn whether the touched bucket really held sensitive data.
✓Benefits and use cases
  • Decide between “close as benign” and “start the incident runbook”.
  • List all resources and accounts touched by one stolen key.
  • Report impact (data types, records, cost) to management and legal.

IAM Access Analyzer and Macie help measure scope

IAM Access Analyzer answers “who could reach this?”. External access findings show buckets, roles, keys and other resources shared outside your account or organization; unused access findings show idle roles, keys and permissions; and policy generation can build a least-privilege policy from CloudTrail activity after the incident. The new AWS Security Hub correlates findings from GuardDuty, Inspector, Macie and CSPM checks into exposure findings with an attack path graph, which helps you see how far an attacker could go. Amazon Macie answers “was the data sensitive?”: run a sensitive data discovery job on the buckets the attacker read to see if they held personal or financial data.

Think of it like · a smoke alarm in an apartment block

What a building manager does when an alarm rings.

AWS conceptFamiliar thing
GuardDuty finding≈The alarm in flat 4B goes off
Validation≈Checking: is it real smoke or just toast?
Suppression rule≈Telling the system that the bakery’s oven always sets off sensor 7
Scope≈Checking which other flats share the same air vent
Access Analyzer≈A list of every door that opens from outside
Macie≈Checking whether the burnt room held the important papers
Real AWS example · read a finding from the CLI

Key fields you check first (output shortened).

$ aws guardduty get-findings --detector-id 12abc34d567e8fa901bc2d34e56789f0 \
    --finding-ids 6eb2d7b1example --query "Findings[0]"
{ "Type": "UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS",
  "Severity": 8,
  "Resource": { "AccessKeyDetails": {
      "AccessKeyId": "ASIAEXAMPLE7Q", "UserName": "web-app-role",
      "UserType": "AssumedRole" } },
  "Service": { "Count": 14, "Archived": false,
      "EventFirstSeen": "2026-10-09T02:11:40Z",
      "EventLastSeen": "2026-10-09T03:58:02Z",
      "Action": { "AwsApiCallAction": { "Api": "ListBuckets",
          "RemoteIpDetails": { "IpAddressV4": "198.51.100.23" } } } } }

Severity 8 is High. An ASIA key is temporary: the instance role’s credentials are being used outside AWS. Count 14 over two hours means it is ongoing, so revoke the role’s sessions now.

Exam-style scenario

GuardDuty reports Recon:EC2/PortProbeUnprotectedPort on dozens of instances every week. Investigation shows the source is the company’s approved external vulnerability scanner with a fixed IP. The team wants to stop the noise in Security Hub without hiding real attacks. What should it do?

  1. A. Disable GuardDuty in the affected Regions.
  2. B. Create a suppression rule that matches this finding type AND the scanner’s IP address.
  3. C. Create a suppression rule for all Recon findings.
  4. D. Ignore the findings in Security Hub.
Show the worked answer

Answer: B

A narrow suppression rule archives only this known benign pattern, and suppressed findings are not forwarded to Security Hub.

Why not the others

  • A: Removes all detection.
  • C: Too broad: real reconnaissance would be hidden.
  • D: Leaves the noise and trains people to ignore alerts.
How the exam tests this
  • “Benign, repeating finding from a known source”→ Narrow suppression rule.
  • “Is the activity still happening?”→ Count, first/last seen, Updated at.
  • “Which resources are shared outside the org?”→ IAM Access Analyzer external access.
  • “Did the attacker touch sensitive data?”→ Macie discovery job.
  • “Linked multi-stage attack across signals”→ GuardDuty attack sequence finding.
Must remember
  • Severity: Low 1–3.9, Med 4–6.9, High 7–8.9, Critical 9–10.
  • GuardDuty keeps findings 90 days.
  • Suppressed = archived, not forwarded.
  • Access Analyzer = who could reach it.
  • Macie = was it sensitive?
04

Containing compromised IAM credentials

Stolen credentials are the most common AWS incident. Skill 2.2.4 asks you to contain, eradicate and recover. For credentials the order is: stop the credentials working, then remove anything the attacker created, then give the real owner new, safer credentials. The exam tests one detail again and again: long-term keys and temporary sessions are stopped in different ways.

Concept profile

Revoke active sessions (AWSRevokeOlderSessions)

often confused with Deactivating an access key
?What is it?

An IAM console action on a role that attaches an inline policy named AWSRevokeOlderSessions. The policy denies every action for any session whose credentials were issued before that moment.

⚙How does it work?
  • The policy is Deny * on * with DateLessThan on aws:TokenIssueTime; the console adds about 30 seconds to allow for propagation.
  • Everyone using the role must assume it again. New sessions work normally, so fix the role’s trust policy first if the attacker can still assume it.
  • It affects temporary credentials only. aws:TokenIssueTime is not present for long-term IAM user keys.
  • You cannot use it on service-linked roles. For IAM Identity Center, revoke the user’s permission set session in Identity Center instead.
  • Pressing the button again later just refreshes the time in the policy.
{ }Structure
1 Contain user keysDeactivate the accesskey (status Inactive)do not delete it yet2 Kill role sessionsRevoke active sessionsAWSRevokeOlderSessionsDeny * if issued before3 Eradicatedelete key, issue newreset password, MFAremove attacker's IAM4 Review, recoverCloudTrail: what didthe key create or read?tighten permissionsWhy you often need both step 1 and step 2The revoke policy uses aws:TokenIssueTime, which exists only for temporary credentials.Long-term access keys keep working until you deactivate them.Stolen instance role credentials: revoke the role’s sessions; the instance simply gets new ones.
Contain, eradicate, review. Two kinds of credentials, two kinds of stop.
⇄Revoke sessions vs Deactivating an access key
Revoke sessionsDeactivate access key
Works onRole sessions (temporary, ASIA… keys)IAM user long-term keys (AKIA…)
EffectOld sessions denied, new ones allowedKey stops working at once
ReversibleRemove the inline policySet status back to Active
Evidence keptYesYes (better than deleting)
Exam hint“instance credentials used outside AWS”“access key found in a public repo”
!Common mistakes the exam tests
  • Deleting the role or user first: you lose evidence and may break production. Deactivate and revoke first, delete later.
  • Revoking sessions for a leaked IAM user key: it does nothing to long-term keys.
  • Rotating a key without checking CloudTrail for new users, keys, roles, trust policy changes or Lambda functions the attacker created for persistence.
  • Forgetting STS tokens already issued with GetSessionToken or AssumeRole from the stolen key: also add a deny policy (or revoke) for those sessions.
  • Ignoring the root cause: a key in a public Git repo, or an SSRF bug that reads instance metadata (use IMDSv2).
✓Benefits and use cases
  • Leaked access key found on GitHub (AWS may also attach a quarantine policy).
  • Instance role credentials used from an IP outside AWS.
  • A departing admin’s live console session must end now.

The full credential runbook

1. Identify the entity from the finding (user type, user name, access key ID) and the API calls. 2. Contain: set the IAM user’s key to Inactive; for a role, revoke active sessions; for a console user, also reset the password and attach a deny-all policy if needed. 3. Eradicate: search CloudTrail for everything that identity did, then delete attacker-created users, keys, roles, EC2 instances and Lambda functions; delete the old key; issue a new one (or better, move the workload to a role). 4. Recover and learn: check the billing for crypto mining, use Access Analyzer’s unused access and Access Advisor to tighten permissions, and add Secrets Manager or roles so long-term keys are not needed. If AWS detects your key in public, it may attach the AWSCompromisedKeyQuarantineV3 managed policy to the user; do not simply remove it, finish the runbook first.

Think of it like · lost office keys and visitor badges

How a company handles a lost key.

AWS conceptFamiliar thing
IAM user access key≈A permanent metal key to the office
Deactivate the key≈Change the lock so that key stops turning, but keep it as evidence
Role session≈A visitor badge that works until it expires
Revoke sessions≈Security says: every badge printed before 10:00 no longer opens doors
Assume role again≈Real visitors go back to reception for a new badge
Persistence check≈Looking for spare keys the thief cut while inside
Real AWS example · contain a user key and a role in two commands

Deactivate the key, then add the same deny policy the console button creates.

$ aws iam update-access-key --user-name ci-deployer \
    --access-key-id AKIAIOSFODNN7EXAMPLE --status Inactive

$ cat revoke.json
{ "Version": "2012-10-17",
  "Statement": [{ "Effect": "Deny", "Action": "*", "Resource": "*",
    "Condition": { "DateLessThan":
      { "aws:TokenIssueTime": "2026-10-10T09:30:00Z" } } }] }

$ aws iam put-role-policy --role-name web-app-role \
    --policy-name AWSRevokeOlderSessions --policy-document file://revoke.json

The instance will get fresh role credentials automatically, so the app keeps working while the stolen copies fail.

Exam-style scenario

GuardDuty raises UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS for credentials of the role attached to a web server. The application must keep running. What is the BEST immediate containment step?

  1. A. Delete the IAM role.
  2. B. Revoke active sessions on the role (AWSRevokeOlderSessions), then investigate how the credentials were stolen, for example SSRF with IMDSv1.
  3. C. Deactivate all IAM user access keys in the account.
  4. D. Stop the instance.
Show the worked answer

Answer: B

Revoking older sessions kills the stolen temporary credentials, while the instance gets new ones and the app keeps working.

Why not the others

  • A: Breaks the application and destroys evidence.
  • C: The leaked credentials are role credentials, not user keys.
  • D: Causes an outage and loses memory evidence; the stolen credentials would still work until they expire.
How the exam tests this
  • “Access key exposed in a public repository”→ Deactivate the key, then rotate and review CloudTrail.
  • “Role credentials used from outside AWS”→ Revoke active sessions.
  • “Deny all sessions issued before a time”→ aws:TokenIssueTime + DateLessThan.
  • “Revoke does not stop the attacker”→ Stolen long-term key, or attacker can assume the role again.
  • “Stop instance metadata credential theft”→ Require IMDSv2.
Must remember
  • User key: Inactive first, delete later.
  • Role: AWSRevokeOlderSessions inline policy.
  • Revoke = temporary creds only (TokenIssueTime).
  • Not for service-linked roles.
  • Hunt for persistence in CloudTrail.
05

Containing a compromised EC2 instance and the network

For a compromised instance the goal is to stop the damage but keep the evidence. Do not terminate first. Take it out of service, cut its network, capture its memory and disks, and only then decide whether to analyze or rebuild. The exam’s favorite trap is connection tracking: changing security groups does not end sessions that are already open.

Concept profile

Isolation security group

often confused with Network ACL deny rule
?What is it?

A dedicated security group with no rules that allow 0.0.0.0/0, usually with only access from a forensic workstation IP, that becomes the instance’s only security group during an incident.

⚙How does it work?
  • Create the Isolation group ahead of time (part of preparation, Day 1).
  • Attach it and remove all other security groups from the instance.
  • Tracked connections are not ended by the change; only new traffic is blocked. Existing sessions keep going until they time out.
  • Flows allowed by a 0.0.0.0/0 rule in both directions are untracked and are cut immediately when that rule is removed; most real sessions are tracked.
  • To stop existing traffic at once, add a network ACL deny for the attacker’s IPs (or the instance) on the subnet.
{ }Structure
1 Protect evidencetermination protectiontag: Quarantinekeep it running2 Out of serviceASG: enter Standbyor detach the instanceELB: deregister target3 Isolation SGno 0.0.0.0/0 rulesremove all other SGstracked conns survive!4 NACL denystateless: cuts existingconnections at onceaffects whole subnet5 Capturememory first (volatile)then EBS snapshotscopy to forensic account6 Decideanalyze offlineterminate, then rebuildfrom a golden AMIChanging security groups blocks only new traffic. Use a NACL when existing sessions must stop now.
Six steps. Evidence first, network second, decision last.
⇄Isolation SG vs Network ACL deny rule
Isolation SGNACL deny
LevelInstance (ENI)Subnet
StateStateful: tracked connections surviveStateless: breaks existing connections
Blast radiusOnly this instanceEvery instance in the subnet
Rule typesAllow onlyAllow and deny, numbered
Best useIsolate one instance cleanlyBlock a bad IP now, or cut live sessions
!Common mistakes the exam tests
  • Thinking the new security group cut the attacker’s live reverse shell: tracked connections survive.
  • Terminating the instance first: memory, running processes and network connections are lost.
  • Stopping the instance before a memory capture: RAM is lost on stop.
  • Leaving the instance in its Auto Scaling group: a failed health check may terminate it, destroying evidence. Use Standby or detach it, and turn on termination protection.
  • Leaving it behind the load balancer: real users keep reaching a compromised host. Standby deregisters it automatically.
✓Benefits and use cases
  • Crypto mining or bot activity from one instance.
  • A web server with a confirmed web shell.
  • Malware found by GuardDuty Malware Protection for EC2.

Auto Scaling, load balancers and evidence

Putting an instance into Standby deregisters it from attached target groups (after connection draining) and stops Auto Scaling health checks on it. If you do not decrement desired capacity, Auto Scaling launches a clean replacement, so the service stays up. You can also detach the instance from the group, or suspend the health check and replace processes. Then capture volatile data first (memory, process list, network connections) with a tool run through Systems Manager, take EBS snapshots of every volume, tag everything with the case ID, and copy the snapshots to the forensic account (share with a KMS key the forensic account can use). This is the work the Day 2 automated forensics tools do for you.

Think of it like · a sick passenger on a cruise ship

Keep others safe, keep the facts.

AWS conceptFamiliar thing
Termination protection≈Nobody may throw the passenger overboard
ASG Standby≈Take the cook off the kitchen rota; a replacement cook starts
Isolation SG≈Lock the cabin door so no new visitors come in
Tracked connections≈People already inside the cabin are still talking to the patient
NACL deny≈Close the whole corridor so even people already inside are cut off
Memory capture first≈Ask the patient questions before they fall asleep
Real AWS example · contain one instance from the CLI

Order matters: protect, remove from service, isolate, snapshot.

$ aws ec2 modify-instance-attribute --instance-id i-0abc12345def67890 \
    --disable-api-termination
$ aws autoscaling enter-standby --auto-scaling-group-name web-asg \
    --instance-ids i-0abc12345def67890 --no-should-decrement-desired-capacity
$ aws ec2 modify-instance-attribute --instance-id i-0abc12345def67890 \
    --groups sg-0isolation11111111
$ aws ec2 create-network-acl-entry --network-acl-id acl-0aa11bb22 \
    --ingress --rule-number 50 --protocol -1 --rule-action deny \
    --cidr-block 198.51.100.23/32
$ aws ec2 create-snapshot --volume-id vol-0123456789abcdef0 \
    --description "IR-2026-042 root volume" \
    --tag-specifications 'ResourceType=snapshot,Tags=[{Key=Case,Value=IR-2026-042}]'

--groups replaces all security groups on the primary interface with the isolation group.

Add a matching egress NACL deny too: NACLs are stateless.

Exam-style scenario

A security engineer replaces all security groups on a compromised EC2 instance with an isolation security group that has no rules. Network monitoring shows the attacker’s existing SSH session to the instance is still active. What should the engineer do to stop this traffic immediately while keeping the instance running for forensics?

  1. A. Wait; the security group change takes up to 24 hours.
  2. B. Add network ACL deny rules for the attacker’s IP (inbound and outbound) on the instance’s subnet.
  3. C. Detach the instance’s IAM role.
  4. D. Stop the instance.
Show the worked answer

Answer: B

Security groups do not end tracked connections; a stateless NACL deny breaks existing connections at once.

Why not the others

  • A: The change is fast; the session survives because it is tracked.
  • C: Does not affect network sessions.
  • D: Loses memory evidence.
How the exam tests this
  • “Isolate one instance”→ Isolation security group, remove others.
  • “Existing sessions survive the SG change”→ Tracked connections: add a NACL deny.
  • “Keep the instance from being terminated by Auto Scaling”→ Standby or detach + termination protection.
  • “Stop users reaching the bad host”→ Deregister from the target group.
  • “Preserve disk evidence”→ EBS snapshots, copied to a forensic account.
Must remember
  • Evidence first: don’t terminate, don’t stop yet.
  • SG change ≠ end of tracked sessions.
  • NACL deny breaks existing connections.
  • ASG Standby also deregisters from the LB.
  • Memory before snapshots; tag with case ID.
06

S3, Lambda, containers and recovery

The same contain, eradicate, recover pattern applies to every resource type, but the buttons are different. For S3 you close access; for Lambda you stop invocations; for containers you isolate the pod or task and the node. Then you recover: restore clean data from backups and rebuild compute from known-good images instead of trying to clean a hacked server.

Concept profile

Rebuild from a golden AMI

often confused with Cleaning the instance in place
?What is it?

Replacing a compromised server with a new one launched from a hardened, patched, scanned image (a golden AMI, often built by EC2 Image Builder), with data restored from a backup taken before the compromise.

⚙How does it work?
  • Keep the old instance or its snapshots for forensics; do not reuse them for production.
  • Fix the root cause in the image or code first (patch, close the port, remove the bad dependency).
  • Launch replacements from the golden AMI through the launch template and Auto Scaling group.
  • Restore data with AWS Backup or snapshots to a new resource, and check it before switching traffic.
  • Rotate every secret the old server could read.
{ }Structure
S3 bucketBlock Public Access onDeny policy for thebad principalRestore old versionsMacie: what leaked?Lambda functionReserved concurrency 0(stops all invokes)Fix role, rotate secretsRedeploy a known-goodversion or aliasContainersDeny-all network policyor isolation SG (task)Cordon the nodeRebuild image, scanwith InspectorRecoverAWS Backup restoreto a NEW resourceVault Lock / air-gapGolden AMI rebuild(EC2 Image Builder)Contain → eradicate → recover. Restore a backup taken before the compromise, patch it, then watch it.
Different resources, same three phases.
⇄Rebuild vs Cleaning the instance in place
RebuildClean in place
Confidence attacker is goneHighLow: hidden backdoors may remain
EvidenceOld host kept intactChanged by the cleanup
SpeedFast if images are automatedSlow, manual
NeedsGolden AMI, IaC, backupsAdmin access to the hacked host
Exam hint“ensure the threat is removed”Rarely correct
!Common mistakes the exam tests
  • Restoring the latest backup when the attacker was already inside then: pick a recovery point from before the compromise.
  • Restoring over the original resource and destroying evidence: restore to a new resource.
  • Backups in the same account the attacker controls: use AWS Backup Vault Lock or a logically air-gapped vault and cross-account copies.
  • Making a bucket public again while “fixing” access: keep Block Public Access on.
  • Throttling a Lambda function but leaving its role’s credentials usable: also revoke the role’s sessions.
✓Benefits and use cases
  • Ransomware or a wiper attack on EC2 or EBS.
  • Web server with an unknown backdoor.
  • Corrupted or encrypted S3 objects (restore earlier versions).

S3, Lambda and containers

S3: turn on Block Public Access (account and bucket level), add a bucket policy that denies the compromised principal or allows only your VPC endpoint, revoke the principal’s credentials, then use versioning to restore overwritten or deleted objects (Object Lock prevents deletion if it was set up earlier). Use CloudTrail data events or server access logs to see which objects were read, and Macie to judge sensitivity. Lambda: set reserved concurrency to 0 to stop every invocation, remove or narrow triggers, revoke the execution role’s sessions, rotate secrets in its environment, and redeploy a known-good version or alias. Containers: on EKS, isolate the pod with a deny-all network policy, label it for forensics, cordon the node so nothing new is scheduled there, and revoke the pod or node role credentials; on ECS, attach an isolation security group to the task’s ENI. GuardDuty Runtime Monitoring and EKS Protection give the findings; Inspector scans the rebuilt image.

Think of it like · a flooded house

What you do after a pipe bursts.

AWS conceptFamiliar thing
Block Public Access≈Close the front door so passers-by stop walking in
Lambda concurrency 0≈Turn off the water at the main valve
Cordon the node≈Put tape across the flooded room so nobody new goes in
AWS Backup restore≈Bring furniture back from the storage unit, from before the flood
Vault Lock≈A storage unit even the house owner can’t empty early
Golden AMI rebuild≈Replace the soaked walls with new boards instead of drying them
Real AWS example · contain S3 and Lambda, then restore

Three fast actions, one restore job.

$ aws s3api put-public-access-block --bucket customer-exports \
    --public-access-block-configuration \
    BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true

$ aws lambda put-function-concurrency --function-name orders-api \
    --reserved-concurrent-executions 0

$ aws backup start-restore-job \
    --recovery-point-arn arn:aws:ec2:eu-west-1::snapshot/snap-0aa11bb22cc33dd44 \
    --iam-role-arn arn:aws:iam::111122223333:role/BackupRestoreRole \
    --resource-type EBS --metadata file://restore-ebs.json

Choose a recovery point from before the first malicious event you found in the logs.

Exam-style scenario

Ransomware encrypted the data volumes of several EC2 instances. The company uses AWS Backup with daily backups copied to a locked vault in another account. The first malicious activity in CloudTrail was 3 days ago. What is the best recovery plan?

  1. A. Restore yesterday’s backups over the existing volumes.
  2. B. Keep the encrypted instances for forensics, rebuild instances from a patched golden AMI, and restore volumes from a recovery point older than 3 days to new resources.
  3. C. Pay the ransom.
  4. D. Run antivirus on the encrypted instances and reuse them.
Show the worked answer

Answer: B

Rebuild from clean images, restore pre-compromise data to new resources, and keep the evidence.

Why not the others

  • A: Yesterday’s backup may already include the attacker’s changes, and overwriting destroys evidence.
  • C: Never the exam answer.
  • D: Cleaning in place leaves possible backdoors.
How the exam tests this
  • “Stop a Lambda function now”→ Reserved concurrency 0.
  • “Bucket made public by attacker”→ Block Public Access + deny policy.
  • “Recover deleted or overwritten objects”→ S3 versioning.
  • “Backups attacker can’t delete”→ Vault Lock / logically air-gapped vault.
  • “Be sure the threat is gone from servers”→ Rebuild from golden AMI.
Must remember
  • Restore from before the compromise.
  • Restore to a new resource.
  • Lambda: concurrency 0.
  • EKS: deny-all policy + cordon.
  • Rebuild, don’t clean in place.
07

Root cause analysis with Amazon Detective

After the fire is out, you must know how it started so it does not happen again. Skill 2.2.5 asks you to describe methods for root cause analysis, and it names Amazon Detective. Root cause means the first weakness: a leaked key, an unpatched app, an open security group, a too-wide trust policy. You find it by building a timeline backwards from the first finding.

Concept profile

Amazon Detective behavior graph

often confused with Amazon GuardDuty
?What is it?

A managed investigation service. It builds a behavior graph, a linked set of data about accounts, roles, users, IP addresses, instances and their interactions over time, and shows it as visual profiles and timelines.

⚙How does it work?
  • Core source packages: CloudTrail logs, VPC Flow Logs, GuardDuty findings. Optional: EKS audit logs and Security Hub CSPM findings. It can also search raw logs in Security Lake.
  • Keeps up to 1 year of history for visualizations, so you can compare normal and unusual activity.
  • Finding groups join related findings and entities (same role session, same IP, close in time, similar tactics); a group is built within 48 hours.
  • Investigations check an IAM user or role for indicators of compromise using machine learning and threat intelligence.
  • One administrator account per Region, with member accounts or AWS Organizations; 30-day free trial the first time.
{ }Structure
Source packagesCoreCloudTrail logsVPC Flow LogsGuardDuty findingsOptionalEKS audit logsSecurity Hub CSPMfindings+ raw logs via Security LakeBehavior graphIAM roleIP 203.0.113.9EC2 i-0abcS3 bucketFinding group4 related findingsWhat you getFinding groups(built within 48 hours)Entity profile pagesActivity timeline,up to 1 year backInvestigations (IOCs)Pivot in from GuardDutyor Security Hub
Logs and findings in, a linked graph and timelines out.
⇄Detective vs Amazon GuardDuty
DetectiveGuardDuty
JobInvestigate and explainDetect
OutputGraphs, profiles, finding groupsFindings
Needs GuardDuty?Uses GuardDuty findings (and is best with it)No
HistoryUp to 1 year of activityFindings kept 90 days
Exam hint“root cause”, “visualize”, “related activity”“detect”, “threat”, “alert”
!Common mistakes the exam tests
  • Choosing Detective to detect threats or to block anything: it neither detects nor responds; it helps you investigate.
  • Choosing GuardDuty for “visualize the related activity and find the root cause”: that is Detective.
  • Expecting Detective to show data from before it was enabled: the graph starts collecting when you turn it on (plus whatever it can read from Security Lake).
  • Thinking Detective needs you to build log pipelines: it pulls CloudTrail and flow data itself.
  • Forgetting the human steps of root cause analysis: a timeline, the “5 whys”, and fixes added to runbooks and preventive controls.
✓Benefits and use cases
  • Explain a High GuardDuty finding: which role, from where, what else it did.
  • See every account and resource one malicious IP touched.
  • Prepare a post-incident report with a clear timeline.

Integrations and the timeline method

From a GuardDuty finding or a Security Hub finding, choose Investigate in Detective to open the right entity profile with the time window already set. In the profile, look at new behavior: first-time API calls, new geolocations, new user agents, unusual data volume. Then build the timeline: initial access (for example the first call from a new IP with the leaked key) → persistence (new user or key) → actions on objectives (data read, instances launched). The earliest step tells you the root cause. Finish with lessons learned: fix the weakness, add a detection, update the runbook and test it (Day 1).

Think of it like · a detective’s wall of photos and string

Joining clues into a story.

AWS conceptFamiliar thing
Behavior graph≈The wall with photos of people, places and cars, joined by string
Finding group≈A cluster of clues that all point to the same suspect
Entity profile≈The suspect’s file with their normal routine
New behavior≈The suspect visited a town they have never been to
Timeline≈Putting the events in order to find the first break-in
GuardDuty≈The burglar alarm that called the detective
Real AWS example · start a Detective investigation on a role

Ask Detective to check one role for indicators of compromise over two days.

$ aws detective start-investigation \
    --graph-arn arn:aws:detective:eu-west-1:111122223333:graph:abc123 \
    --entity-arn arn:aws:iam::111122223333:role/web-app-role \
    --scope-start-time 2026-10-08T00:00:00Z --scope-end-time 2026-10-10T00:00:00Z
{ "InvestigationId": "000000000000000000001" }

$ aws detective get-investigation --graph-arn arn:aws:detective:eu-west-1:111122223333:graph:abc123 \
    --investigation-id 000000000000000000001 --query "[Status,Severity]"
[ "SUCCESSFUL", "HIGH" ]

Then open the role’s profile in the console to see the indicators: new geolocations, unusual API calls and related findings.

Exam-style scenario

A company has GuardDuty in all accounts. After a High finding on an IAM role, the security lead wants to see all related findings and entities, how the role behaved compared with normal over the past months, and where the activity started, with the least setup. What should the team use?

  1. A. Write Athena queries joining CloudTrail and VPC Flow Logs.
  2. B. Amazon Detective: open the finding group and the role’s profile from the GuardDuty finding.
  3. C. AWS Config timeline.
  4. D. Amazon Inspector.
Show the worked answer

Answer: B

Detective already links GuardDuty findings, CloudTrail and flow data into finding groups and profiles with history.

Why not the others

  • A: Possible but needs much more effort and gives no baseline.
  • C: Config tracks resource configuration changes, not API behavior of a role.
  • D: Inspector finds vulnerabilities; it does not investigate activity.
How the exam tests this
  • “Visualize related activity, find root cause”→ Amazon Detective.
  • “Group related findings into one event”→ Detective finding groups.
  • “Compare behavior with the normal baseline”→ Detective entity profiles.
  • “Pivot from a finding to investigation”→ Investigate in Detective from GuardDuty / Security Hub.
  • “Detective core data”→ CloudTrail, VPC Flow Logs, GuardDuty.
Must remember
  • Detective investigates; GuardDuty detects.
  • Core: CloudTrail + Flow Logs + GuardDuty.
  • Optional: EKS audit, Security Hub.
  • Up to 1 year of history.
  • Finding group within 48 h.
08

Cheatsheet extras: account-compromise checklist and KMS key emergencies

Two cheat-sheet lists are worth knowing by heart: what to do when the whole account may be compromised, and what to do with a KMS key during an incident. One old list needs updating too.

Older material says “EC2 hacked: stop the instance immediately, snapshot, terminate”. Today’s AWS guidance is different: don’t stop or terminate first. Isolate it (isolation security group, detach from the ASG, deregister from the load balancer), turn on termination protection, capture memory while it runs, snapshot the volumes, then investigate copies in the forensics account. Stopping throws away memory evidence.

The account-compromise checklist

When AWS Support or Trust & Safety says your account may be compromised, AWS’s own checklist is: change the root user password and turn on MFA for root and console users; rotate and delete all root and IAM access keys; delete IAM users (and roles) you didn’t create and change the passwords of the others; check your bill and every Region for resources you didn’t create (EC2 instances, Spot requests, Lambda functions, snapshots, AMIs, S3 buckets) and delete them after you have kept evidence; check your account contact details; and reply to the notice in the Support Center. With an organization, also check for new accounts or SCP changes the attacker made.

Concept profile

Disabling a KMS key

often confused with Scheduling key deletion
?What is it?

DisableKey stops a KMS key from being used in any cryptographic operation at once. It is reversible with EnableKey. Deletion (ScheduleKeyDeletion) is permanent after a waiting period.

⚙How does it work?
  • Disable: key state Disabled; Encrypt, Decrypt and GenerateDataKey fail. Use it to cut off a key you think is being misused, or to test what depends on a key.
  • Schedule deletion: waiting period 7 to 30 days (default 30). State PendingDeletion: the key can’t be used. CancelKeyDeletion brings it back as Disabled (enable it again yourself).
  • After deletion, every ciphertext under that key is lost for ever.
  • Imported key material: DeleteImportedKeyMaterial makes the key unusable immediately, with no waiting period; it works again only if you re-import the same material.
  • Detect: an EventBridge rule (or CloudTrail metric filter) on DisableKey and ScheduleKeyDeletion; KMS also warns when a key pending deletion is used.
{ }Structure
Enablednormal use DisableKey EnableKey Disabledinstant, reversible ScheduleKeyDeletion PendingDeletion7–30 days, unusable CancelKeyDeletion period ends Deleteddata lost for ever Imported materialDeleteImportedKeyMaterial= unusable at once
Disable is the brake; deletion is the scrapyard with a 7–30 day grace period.
⇄Disable key vs Schedule key deletion
DisableKeyScheduleKeyDeletion
Takes effectImmediatelyKey unusable now; deleted after 7–30 days
Reversible?Yes, EnableKey any timeOnly during the waiting period (CancelKeyDeletion)
DataSafe, readable again after enableLost for ever once deleted
Incident useContain misuse of a keyRarely; crypto-shredding when data must be destroyed
Exam hint“stop use now, may need it later”“someone scheduled deletion, recover it” → CancelKeyDeletion
!Common mistakes the exam tests
  • Scheduling deletion to “contain” a key: you risk losing data; disable instead.
  • Thinking a key is deleted the moment you click: there is always a 7-day minimum waiting period (except removing imported key material).
  • Expecting CancelKeyDeletion to return the key to Enabled: it returns as Disabled.
  • Not alarming on ScheduleKeyDeletion: an attacker can use it as ransomware against your data.
  • Leaving an attacker’s IAM user in place after rotating keys: delete what you didn’t create.
✓Benefits and use cases
  • Fast, reversible containment when a key’s grants or policy were abused.
  • A safety net: the waiting period lets you notice and cancel a malicious deletion.
  • Crypto-shredding with imported material when data must be unreadable at once.
Think of it like · the keys to a safe-deposit box

A bank keeps your box key; you can freeze it, or ask to destroy it.

AWS conceptFamiliar thing
DisableKey≈“Freeze my key”: nobody can open the box until you unfreeze it
ScheduleKeyDeletion≈“Destroy my key in 30 days”: a cooling-off period
CancelKeyDeletion≈Changing your mind before the date: the key comes back still frozen
Deleted key≈The key is melted: the box can never be opened
Account-compromise checklist≈Change every lock, cancel lost cards, check the statement for strange charges
Real AWS example · alert on, and undo, a malicious key deletion

An EventBridge rule catches the call; the responder cancels and re-enables.

{ "source": ["aws.kms"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": { "eventName": ["ScheduleKeyDeletion", "DisableKey"] } }

$ aws kms describe-key --key-id 1234abcd-12ab-34cd-56ef-1234567890ab \
    --query "KeyMetadata.[KeyState,DeletionDate]"
[ "PendingDeletion", "2026-11-19T10:02:11Z" ]

$ aws kms cancel-key-deletion --key-id 1234abcd-12ab-34cd-56ef-1234567890ab
$ aws kms enable-key --key-id 1234abcd-12ab-34cd-56ef-1234567890ab

After cancelling, the state is Disabled; enable-key makes it usable again. An SCP that denies kms:ScheduleKeyDeletion to everyone except a break-glass role prevents a repeat.

Exam-style scenario

CloudTrail shows that a compromised administrator role called ScheduleKeyDeletion on the customer managed key that encrypts the company’s production RDS database, with a 7-day waiting period, two days ago. The database now fails to read data. What should the security engineer do first to restore service with the least data loss?

  1. A. Restore the database from a snapshot encrypted with a new key.
  2. B. Call CancelKeyDeletion, then EnableKey, and revoke the compromised role’s sessions.
  3. C. Create a new key with the same key ID.
  4. D. Ask AWS Support to recover the key after it is deleted.
Show the worked answer

Answer: B

The key is still in its waiting period, so it can be recovered. Cancelling leaves it disabled; enabling it restores service. Then contain the role.

Why not the others

  • A: Snapshots are encrypted with the same key, and you would lose recent data.
  • C: Key IDs and key material can’t be recreated.
  • D: After deletion, no one, including AWS, can recover the key.
How the exam tests this
  • “AWS says the account may be compromised”→ Root password + MFA, rotate/delete keys, remove unknown users and resources, check the bill, reply.
  • “Stop a KMS key being used, may need it later”→ DisableKey.
  • “Key was scheduled for deletion by mistake or by an attacker”→ CancelKeyDeletion (then EnableKey).
  • “Make data unreadable immediately”→ DeleteImportedKeyMaterial (imported material only).
  • “EC2 hacked: what first?”→ Isolate and capture, not stop or terminate.
Must remember
  • Deletion waiting period: 7–30 days, default 30.
  • CancelKeyDeletion → key is Disabled.
  • Imported material can be removed instantly.
  • Alarm on ScheduleKeyDeletion and DisableKey.
  • Compromised account: keys, users, resources, bill, reply.
09

Lecture summary map

Day 3 on one screen.

1. Mind map

① Search + correlateAthena on S3 trailLogs InsightsSecurity Lake OCSF② Validate findingsSeverity 1–10Suppression rulesAccess Analyzer, Macie③ CredentialsUser key: InactiveRole: revoke sessionsHunt persistence④ EC2 + networkIsolation SGTracked conns surviveNACL, ASG Standby⑤ Other + recoverS3 BPA, Lambda 0Backup to NEW resourceGolden AMI rebuild⑥ Root causeDetective graphFinding groupsTimeline backwardsIncident Response 3responding to events
Tap a branch to jump back to that part of the lecture. Try redrawing this map from memory on paper.

2. Match the requirement to the tool

“Query CloudTrail logs in S3 with SQL”→Amazon Athena“Search application logs in CloudWatch”→CloudWatch Logs Insights“One schema for logs from many sources”→Security Lake (OCSF)“Finding is noisy and expected”→Validate, then suppression rule“IAM user access key leaked”→Deactivate key, then rotate“Stolen role credentials still work”→Revoke active sessions“Stop existing connections now”→NACL deny, not only an SG“Related findings, root cause, graph”→Amazon Detective
The left column is the exam wording; the right column is the answer.

3. “If the question says… pick…”

CloudTrail logs in S3, months of history, SQLAthena with partition projection
Only the last 90 days, no setupCloudTrail Event history
Application or Lambda logs in CloudWatchCloudWatch Logs Insights
Normalize many sources, feed a SIEMSecurity Lake (OCSF), subscriber
Known scanner causes noisy findingsNarrow suppression rule
Was the stolen data sensitive?Macie discovery job
Access key leaked on GitHubDeactivate key, review CloudTrail, rotate
Instance role credentials used outside AWSRevoke active sessions on the role
Attacker session still open after SG changeNACL deny (stateless)
Instance must not be terminated by scalingASG Standby + termination protection
Stop a Lambda function immediatelyReserved concurrency 0
Root cause, related findings, visual timelineAmazon Detective
Day 3 in one sentence

Search the logs, validate the finding, contain without destroying evidence, recover from clean copies, and let Detective show you where it all began.

10

Must-remember cheat sheet

1. Event history = 90 days, management events only.
2. Athena on trail: partition projection, filter dates.
3. Logs Insights: QL, PPL, SQL; 60 min timeout.
4. CloudTrail Lake: closed to new customers 31 May 2026.
5. Security Lake: OCSF + Parquet in your S3.
6. Severity: High 7–8.9, Critical 9–10.
7. GuardDuty keeps findings 90 days.
8. Suppressed findings are not forwarded.
9. User key: set Inactive, delete later.
10. Role: AWSRevokeOlderSessions (TokenIssueTime).
11. SG change keeps tracked connections.
12. NACL deny cuts existing connections.
13. ASG Standby deregisters from the LB.
14. Lambda stop: reserved concurrency 0.
15. Restore pre-compromise point to a new resource.
16. Detective: 1 year, finding groups, root cause.
17. KMS: Disable = instant + reversible. Delete = 7–30 days, then gone. Cancel → Disabled.
18. Account compromised: root pw + MFA, rotate/delete keys, delete unknown users/resources, check bill, reply.
11

Core quiz

Check the basics first. Pick an answer, then press Check.

12

Hard quiz

Harder than most real exam questions on purpose, with one “choose two” and one matching question. Aim for 9 out of 12.

13

Domain 2 review quiz (Days 1–3)

Questions from every Incident Response day. If you miss one, reopen that day’s lecture and its “Must remember” boxes.

14

Practice test questions (from your mock exams)

8 questions taken from your own SCS-003 mock exams and matched to today’s topics. Each answer was checked against current AWS behaviour; where a mock’s answer was outdated or wrong, the explanation says so. The source is shown at the end of each explanation.

15

Hands-on lab (30 minutes, low cost)

  1. In the CloudTrail console, choose Create Athena table for your trail’s bucket. Run a query that lists your own eventname and sourceipaddress for today (filter on the date to keep the scan tiny).
  2. In GuardDuty, choose Generate sample findings. Open a sample UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS finding and note the severity, Count, resource and remote IP. Then create a suppression rule for one sample type and see it move to Archived.
  3. Create a test IAM user with an access key. Deactivate the key with update-access-key --status Inactive and confirm a call with it fails. Create a test role, assume it, then press Revoke active sessions and confirm the old session gets AccessDenied while a fresh assume works.
  4. Launch a t3.micro (Free Tier eligible) and SSH in. Replace its security group with an empty isolation group and notice the SSH session stays up; then add a NACL deny for your IP and watch it drop. Take an EBS snapshot with a Case tag.
  5. Optional: enable Amazon Detective (30-day free trial in a Region) and open a sample finding with Investigate in Detective. Real data appears only after it has collected some activity.
  6. Clean up: terminate the instance, delete the snapshot, the NACL entry and isolation group, the test user, key and role, the suppression rule and archived samples. Disable Detective before the trial ends, and drop the Athena table (the query results bucket keeps costing a little).