AWS detection and investigation

Lessons on GuardDuty and CloudTrail Lake: what an account id, a readOnly flag, an event source, or a query id does not prove.

  • 24 lessons
  • 4.5 h of reading
  • 2 topics

GuardDuty says something looks wrong; CloudTrail says exactly what happened. These lessons move from a finding to the API calls behind it, and from those calls to containment and a fix list.

Work in a sandbox account you own. Sample findings let you practise triage without an incident, and both services bill by volume, so clean up when you finish.

  1. 01GuardDuty triage: read a finding from type name to next actionGenerate GuardDuty sample findings in a sandbox account, decode a finding type name, and work through resource, actor, and timing fields with the AWS CLI to decide whether to contain or close.12 min
  2. 02GuardDuty at scale: delegated admin, suppression rules, and EventBridge routingManage GuardDuty from a delegated administrator account, write a narrow suppression rule for a known benign pattern, and route high-severity findings to the on-call channel through EventBridge.11 min
  3. 03GuardDuty: the four clocks on a findingCopy CreatedAt, UpdatedAt, EventFirstSeen, and EventLastSeen as separate times, and mark a sample so practice output is not filed as a live incident.11 min
  4. 04GuardDuty: what the actor fields do not proveRecord the access key id, the user type, and the source IP. Treat the city and organization text as a lookup, and the user name as a label that may be a session name.11 min
  5. 05GuardDuty: severity is not the event countSeverity is the finding’s score. Service.Count is how many times the activity was included. Write both numbers with their field names, and do not page a count you read off the score.11 min
  6. 06GuardDuty: archived is a workflow flag, not a closed caseArchived means the finding was marked off the default view. Write Service.Archived and the filter you used. An empty high-score list can be the filter, not a quiet account.11 min
  7. 07GuardDuty: the finding id needs its region and detectorA finding id is meaningful with the region and the detector id from the same JSON. Write all three. The region selected in the console is not a field you already copied.11 min
  8. 08GuardDuty: the description is generated textThe Description on a finding is prose the service generated. The Type string is the stable name. Write Type as the name and Description as generated text, not as a list of API calls.11 min
  9. 09GuardDuty: the resource type picks which block is filledResource.ResourceType says which nested object the finding filled. Write that type and only the block it names. Do not read instance fields on a finding whose type is an access key.11 min
  10. 10GuardDuty: the account id is not the detector idAccountId on a finding is the AWS account the finding belongs to. The detector id is the detector in that region. Write both. Do not pass the account number to a command that asks for a detector.11 min
  1. 01CloudTrail Lake: create an event data store and answer questions in SQLCreate a CloudTrail Lake event data store in a sandbox account, run SQL queries with the AWS CLI, and read the results to see who made failed calls and which principals created access keys.11 min
  2. 02CloudTrail Lake investigation: everything one leaked role session didFollow a GuardDuty credential-exfiltration finding into CloudTrail Lake, list every call made with the leaked access key, and check for persistence such as new users, keys, or role trust changes.12 min
  3. 03CloudTrail Lake: query status, pages, and the noteRead QueryStatus before any rows, follow NextToken until it is absent, and file the statement, query id, store id, and result count with the note.12 min
  4. 04CloudTrail Lake: what one result row provesA finished row is one API call the store recorded. An empty error code means the call was accepted, not that the account is still in that state.12 min
  5. 05CloudTrail Lake: two account ids on one rowuserIdentity.accountId is the caller’s account. recipientAccountId is the account that received the call. Write both. Do not say “our account” from only one of them.11 min
  6. 06CloudTrail Lake: an insight row is not the list of callsAn eventCategory of Insight is CloudTrail’s own summary of unusual activity. Write that category. The API calls themselves are management events in the same window, queried separately.12 min
  7. 07CloudTrail Lake: eventID is the recordeventID identifies the CloudTrail record. requestID identifies the API request as the service logged it. Write eventID when you cite the row. Do not use requestID as a substitute you did not also keep.11 min
  8. 08CloudTrail Lake: values follow the select listA Lake result row is values in the order of the SELECT list. Write the SELECT text above the values. A pasted line with no column names can swap an account and an address.12 min
  9. 09CloudTrail Lake: eventTime is UTCeventTime on a Lake row is UTC. Write the zone when you compare it with a local clock. Do not shift the digits and still call the result eventTime.11 min
  10. 10CloudTrail Lake: bytes scanned are the query’s volumeBytes scanned on a finished query is how much data that query read. It is not the size of the account and not the number of events. Write it next to the query id, and do not compare two queries that scanned different stores.11 min
  11. 11CloudTrail Lake: the error message is not the codeerrorCode is the code on the row. errorMessage is the service’s string. Write the one you have, and do not invent a code from the wording or a sentence from a code you did not read.12 min
  12. 12CloudTrail Lake: readOnly is about this callreadOnly on a Lake row says whether that API call was a read. It does not say the principal can only read, and it does not say the resource never changes. Write the flag with the event name.11 min
  13. 13CloudTrail Lake: eventSource is the serviceeventSource names the AWS service API on that row, such as the EC2 or IAM endpoint the call used. It is not the account and not the person. Write it beside eventName.11 min
  14. 14CloudTrail Lake: the query id is not the eventA query id identifies the Lake query you started. eventID identifies one CloudTrail record in a result. Write both when you cite a call. Do not file the query id as if it were the API event.12 min