SECURITY ENGINEERING · PART 10 · CLOUD SECURITY · DETECTION · 144 OF 229

CloudTrail, GuardDuty and Cloud Threat Detection

You cannot respond to what you cannot see. This episode covers cloud logging and threat detection: the audit log that records every API call, where the logs are and how to protect them, managed threat detection services, what cloud attacks look like in the logs, central log aggregation, and why turning on and protecting the logs is the foundation of every cloud investigation.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. 22
  22. 23
  23. 24
  24. 25
  25. 26
  26. 27
  27. 28
  28. 29
  29. 30
  30. 31
  31. 32
  32. 33
  33. 34
  34. 35
  35. 36
  36. 37
  37. 38
  38. 39
  39. 40
  40. 41
  41. 42
  42. 43
  43. 44
  44. 45
  45. 46
  46. 47
  47. 48
  48. 49
  49. 50
  50. 51
  51. 52
  52. 53
  53. 54
  54. 55
  55. 56
  56. 57
  57. 58
  58. 59
  59. 60
  60. 61
  61. 62
  62. 63
  63. 64
  64. 106
  65. 107
  66. 108
  67. 109
  68. 110
  69. 111
  70. 112
  71. 113
  72. 114
  73. 115
  74. 116
  75. 117
  76. 118
  77. 119
  78. 120
  79. 121
  80. 122
  81. 123
  82. 124
  83. 125
  84. 126
  85. 127
  86. 128
  87. 129
  88. 130
  89. 131
  90. 132
  91. 133
  92. 134
  93. 135
  94. 136
  95. 137
  96. 138
  97. 139
  98. 140
  99. 141
  100. 142
  101. 143
  102. 144
1 / 10

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Audit log on everywhere
  • ship to a locked-down log account
  • guardrail against deletion
  • managed detection on

Notes

The audit log

The foundation is the management audit log: CloudTrail on AWS, the Activity Log on Azure, Cloud Audit Logs on Google. It records every API call, who did what, when, and from where. This is the single most important source for any investigation, because in the cloud everything is an API call. Turn it on for all regions and all accounts, not just one. Store it in immutable storage and retain it a long time, because you often investigate things from months ago.

The management audit log
  • AWS CloudTrail, Azure Activity Log, GCP Cloud Audit Logs
  • records every API call: who, what, when, from where
  • this is the primary record for investigations
  • turn it on for ALL regions and accounts
  • immutable storage; retain for a long time

Protect the logs

Logs an attacker can delete are not evidence. So ship them from each account to a separate, locked-down logging account the compromised account cannot reach. Add the governance guardrail that denies disabling or deleting the audit log for everyone, including account admins. And enable more than the management log: data-event logs for operations like object reads, and network flow logs, so you see not just control-plane actions but data access and traffic. Protected, complete logs make an investigation possible.

Guard the evidence
  • ship logs to a separate, locked-down log account
  • attackers cannot reach them from the compromised account
  • guardrail: deny disabling or deleting the audit log (SCP, from the governance episode)
  • turn on data-event and network/flow logs too

Managed detection

You do not have to write all the detection yourself. Managed services, GuardDuty on AWS, Defender for Cloud on Azure, Security Command Center on Google, analyse your logs, DNS and network traffic for known attack patterns and anomalies. They produce findings like crypto-mining, credential exfiltration, reconnaissance, or unusual API calls. Low effort and high value, so turn them on across all accounts and route the findings into your alerting. They catch many common cloud attacks automatically.

Threat detection services
  • GuardDuty (AWS), Defender for Cloud (Azure), SCC (GCP)
  • analyse logs, DNS, network for known attack patterns
  • findings: crypto-mining, credential exfiltration, recon, anomalous API calls
  • low effort, high value: turn them on feed findings into your alerting

Reading the trail

An audit entry answers the investigator's questions directly. This one shows a create-user action, by the web application role, from an external IP, using the command-line tool, and it succeeded. Each is a clue: a web app role should never create IAM users, the source IP is not your infrastructure, and the command-line agent is unusual for an app. Reading entries like this is the core of cloud investigation, and alerting on suspicious combinations, like a service role creating users, is how you catch it live.

a CloudTrail-style entry
{
  "eventName": "CreateUser",
  "userIdentity": "role/web-app",
  "sourceIPAddress": "203.0.113.9",
  "userAgent": "aws-cli",
  "errorCode": null
}
# a web-app role creating an IAM
# user, from an odd IP = suspicious

What attacks look like

It helps to know what the attacks from this part look like in the logs. A new access key created and used from a new country. Instance role credentials used from an external IP, the metadata-SSRF attack. Someone calling stop-logging or changing policies. A sudden burst of object reads, signalling exfiltration. Threat detection being disabled, or new admin users created. Each breach pattern has a log signature, and knowing them lets you build targeted alerts rather than drowning in raw events.

Signals in the logs
  • new access key created, then used from a new country
  • instance creds used from an external IP (the SSRF attack)
  • StopLogging / policy changes
  • mass GetObject or data downloads
  • disabling GuardDuty; creating admin users

Aggregate and alert

Raw logs are not detection; you turn them into signal. Centralise logs from every account into one place, a SIEM or query tool, which Part thirteen covers in depth. Then alert on the high-value events, a new admin user, logging disabled, off-instance credential use, rather than on everything, and tune to cut noise. The goal is to shrink the time to notice an intrusion from the typical weeks to minutes, because detection speed limits the damage of every breach.

From logs to signal
  • centralise logs from all accounts in one place
  • into a SIEM or query tool (Part 13 covers detection engineering)
  • alert on high-value events, not everything
  • tune to cut noise
  • the goal: minutes to notice, not weeks

Common mistakes

Mistakes. The audit log turned off, or only enabled in one region while the attacker works in another. Logs stored in the same account an attacker compromises, so they are deleted. Managed threat detection never switched on, despite being cheap and easy. Logs dutifully collected but with nobody alerting on them, so they are only read after the breach. No data-event or flow logs, so you see control actions but not data access. And alerting on everything, so the few real signals are lost in noise.

Avoid these
  • audit log off, or only in one region
  • logs an attacker can delete (same account)
  • managed detection not turned on
  • logs collected but nobody alerting on them
  • no data-event or flow logs
  • alerting on everything, so real signals are missed

Say it like this

In the interview: detection starts with logging. I enable the management audit log in every region and account, ship it to a separate locked-down logging account, and guardrail against anyone disabling or deleting it. I turn on the managed threat detection service for broad coverage. Then I centralise logs into a SIEM, add data-event and flow logs, and alert on high-value signals, a new admin user, logging disabled, off-instance credential use. The goal is to cut time-to-notice from weeks to minutes.

In the interview
  • "Turn on the audit log in all regions and accounts, ship it
  • to a locked-down log account
  • with a guardrail against
  • deletion. Enable managed
  • detection (GuardDuty etc.).
  • Centralise logs, alert on high-value events like new admins or off-instance creds, and aim for minutes to notice."

Interview questions

Q1What is the cloud audit log and why does it matter?

A record of every API call in an account, who did what, when and from where (AWS CloudTrail, Azure Activity Log, GCP Cloud Audit Logs). Since everything in the cloud is an API call, it is the primary evidence source for investigations and must be enabled in all regions and accounts.

Q2Why ship logs to a separate account?

So that an attacker who compromises an account cannot reach, alter or delete the logs. A dedicated, locked-down logging account, combined with a guardrail that denies disabling or deleting the audit log, keeps the evidence trustworthy.

Q3What are managed cloud threat detection services?

Services like AWS GuardDuty, Microsoft Defender for Cloud and Google Security Command Center that analyse logs, DNS and network data for known attack patterns and anomalies, producing findings such as crypto-mining, credential exfiltration or reconnaissance with minimal setup.

Q4What do cloud attacks look like in the logs?

Signals such as a new access key used from a new location, instance credentials used from an external IP (the SSRF attack), StopLogging or policy changes, sudden mass object downloads, disabling threat detection, or creating new admin users. Each breach pattern has a log signature.

Q5Why enable data-event and flow logs, not just the management log?

Because the management log records control-plane API calls but not data access or network traffic. Data-event logs capture sensitive operations like object reads, and flow logs capture network traffic, which are needed to detect data exfiltration and lateral movement.

Q6What is the difference between collecting logs and detecting threats?

Collecting logs stores evidence; detection turns it into signal by centralising logs and alerting on high-value events. Logs that nobody alerts on are only useful after the fact. Tuning alerts to reduce noise is what makes detection actionable.

Q7Why do attackers disable logging first?

To operate unseen. Disabling the audit log or threat detection removes the record of their actions. This is why a guardrail that prevents anyone, including account administrators, from stopping or deleting logs is a critical control.

Q8What is the goal of cloud detection?

To reduce the time to notice an intrusion from the typical weeks to minutes. Faster detection limits the blast radius of every breach, so logging coverage, managed detection and well-tuned alerting on high-value events are prioritised accordingly.