Threat Hunting AWS CloudTrail with Sentinel: Part 1

Binary Defense

Binary Defense

Built from the minds of the industry’s top security researchers and continuously evolving to detect next-generation threats, Binary Defense is your company’s security solution.
Share on facebook
Share on twitter
Share on linkedin

Part 1: Intro to Threat Hunting AWS CloudTrail with Sentinel

By Sean Fernandez | Threat Researcher | Binary Defense

Note: this is a four-part blog post based on research from our threat hunting team. We will release this series over the next few weeks.

The adoption of cloud has been sharply rising in recent years. Global and small enterprises are flocking to large scale cloud computing such as Amazon Web Services (AWS) for increased security, stability, cost efficiency and greater networking and development tools.

Growth in Cloud Adoption in the last 8 yearsIDG Cloud Computing Survey, 2020

Concurrently, this rapid digital change has expanded the attack surface propelling threat actors to evolve their exploit strategies across cloud environments. Cyber security teams working in cloud platforms are also rapidly evolving their strategies but face setbacks when approaching cloud challenges with on-premises tools and practices. Cloud providers use a shared responsibility model, where the provider is responsible for protecting the infrastructure that runs all the services offered in the cloud and the customer responsibility will be determined by the cloud services selected. According to Amazon Web Services (AWS), “customers are responsible for managing their data (including encryption options), classifying their assets, and using IAM tools to apply the appropriate permissions.”

AWS Shared Responsibility Model

Global reports show that some Security Operation Centers (SOCs) lack familiarity in cloud security tooling and are challenged by the monitoring of high-volume data. Uncommon log collection methods can lead to increased visibility gaps that make detections harder to fine-tune, and in turn, increase false positives. Not developing a proper foundation of processes in AWS could result in budgetary shortfalls, alert fatigue, and lack of mitigation in a timely manner.

Threat actors have modified their tactics, capitalizing on misconfigured assets and Identity and Access Management (IAM) permissions sprawl. Common cloud-based vulnerabilities include IAM policies and permissions, misconfigured S3 buckets and security tokens. SOC teams will benefit from taking a proactive approach to uncover these types of malicious behaviors. Threat hunting in Sentinel with Kusto Query Language (KQL) will quickly narrow down the focus and efficiently uncover AWS CloudTrail anomalies.

AWS CloudTrail

AWS CloudTrail is a native service which operates as a central logging source for almost any API call in an AWS account. CloudTrail logs, continuously monitors, and retains account activity related to actions across an AWS infrastructure, giving users control over storage, analysis, and remediation actions. By default, CloudTrail stores logs for 90 days but can be configured for longer storage in S3 buckets. The data is stored in JSON format for each event. The JSON records can be extracted, translated, and manipulated by standard tooling.

What makes this a valuable out-of-the-box tool is that the span of visibility can potentially uncover suspicious activity, such as listing buckets, creating users, changing policies, and stopping logs.

Augmented Threat Hunting with Sentinel SIEM

Microsoft Sentinel is a security information and event management (SIEM) system for detecting and responding to threats. By ingesting the AWS service log data into a SIEM such as Microsoft Sentinel, Splunk, AT&T Cybersecurity, or another system, we can run custom investigative queries to build detections. Sentinel makes it easy to add sophisticated search capabilities and fine-tune search indices. In addition, connecting AWS logging into Sentinel can provide alerts and run threat checks using multiple threat intelligence feeds. Sentinel can initiate a coordinated response and retain data long term for compliance purposes.

Threat Hunting AWS CloudTrail with Sentinel

In this blog series, we will identify threat hunting opportunities in AWS logs. Using a test AWS environment that emulated a small organization (with a set of users, roles, groups, and policies) we will go over attack simulations to identify suspicious activity that can be leveraged into hunting queries and custom detections. In each section, we will break down each simulation attack, from its set up to how to analyze the logs uncovered by Sentinel using KQL queries. This series provides SOC teams valuable insight into adversary tactics, techniques and procedures (TTPs) that are cloud-specific.

Threat Hunting with Sentinel Diagram

Simulated Attacks in AWS Environment

Attacks and detection techniques deployed in our AWS testing environment can be mapped back to the MITRE ATT&CK® framework, which was expanded to cover cloud attacks. This is a great resource for strategizing hunting methods. Refer to the table below to view the breakdown of each attack.[KJ1] [SF2] 

 PlatformTacticTechnique IDTechniqueDescription
Operations in S3 Buckets (Part II -add link)AWSCollectionT1530Data from Cloud Storage ObjectAccess data from improperly secured S3 bucket
Back Door (Part III-add link)AWSPersistenceT1078.004Valid Accounts: Cloud AccountsSecond IAM key created
Atomic (Part IV-add link)AWSPersistenceT1136.003Create Cloud AccountCreate New IAM User
AWSPersistenceT1098.001Account Manipulation: Additional Cloud CredentialsCreate Programmatic Access Keys
AWSPersistenceT1098Account ManipulationCreate New AWS Group 

Attacks executed in our AWS test environment:

  1. Steals credentials from a misconfigured S3 buckets
  2. Creates a second set of keys for an admin user
  3. Obtains security token within the compromised AWS account
  4. Creates a new IAM user
  5. Creates access keys for the new IAM user
  6. Creates group and adds new user to the group

Offensive Security Toolkits Used for Attacks

To conduct our simulations, we utilized open-source toolkits. In the first attack, we used the multi-cloud OSINT tool “cloud_enum” that produced a scan of our S3 buckets. In the second attack, we utilized “Pacu,” from Rhino Security Labs, with the backdoor module. And in our final attacks, we used the “Atomic Red Team” library that was built specific to AWS.

Summary

Conducting adversary simulations can provide a clearer image of what threat actors may do in cloud environments and how they differ from traditional on-premises attacks. In this four-part series, we demonstrated common attack scenarios. We enabled log data via CloudTrail and ingested them into Sentinel – which recently released new data connector that can ingest VPC Flow Logs, GuardDuty and CloudTrail (management and data events). Sentinel also has built-in hunting queries supporting MITRE ATT&CK techniques. Once all relevant data was onboarded onto Sentinel, we were able to detect our simulated threat activity with KQL queries that you can apply in your own threat hunts.

In part 2 of this blog series, we simulated an attack on a misconfigured S3 bucket with the open-source OSINT tool “cloud_enum” and the AWS CLI.

References:

  • https://attack.mitre.org/matrices/enterprise/cloud/
  • https://github.com/schwartz1375/aws
  • https://github.com/toniblyx/my-arsenal-of-aws-security-tools#defensive-hardening-security-assessment-and-inventory
  • https://github.com/toniblyx/my-arsenal-of-aws-security-tools#continuous-security-auditing
  • https://medium.com/@george.fekkas/quick-and-dirty-cloudtrail-threat-hunting-log-analysis-b64af10ef923
  • https://www.blackhillsinfosec.com/breaching-the-cloud-perimeter-w-beau-bullock/
  • https://www.activecountermeasures.com/aws-vpc-traffic-mirroring/
  • https://www.activecountermeasures.com/webcasts/02-27-2020-acm-webcast-sniffing-traffic-in-amazon-ec2-with-traffic-mirroring/
  • https://medium.com/@maarten.goet/threat-hunting-in-the-cloud-with-azure-notebooks-supercharge-your-hunting-skills-using-jupyter-8d69218e7ca0
  • https://riptutorial.com/aws-cli/example/22749/aws-cli-cheat-sheet—list-of-all-cli-commands
  • https://docs.microsoft.com/en-us/azure/sentinel/connect-aws
  • https://www.linkedin.com/pulse/ingesting-aws-guard-duty-findings-azure-sentinel-marko-lauren
  • https://github.com/Azure/Azure-Sentinel/tree/master/DataConnectors/AWS-S3-AzureFunction
  • https://redcanary.com/blog/art-cloud-containers/
  • https://github.com/redcanaryco/invoke-atomicredteam/wiki/Installing-Atomic-Red-Team
  • https://github.com/redcanaryco/atomic-red-team
  • https://www.shellntel.com/blog/2019/8/27/aws-metadata-endpoint-how-to-not-get-pwned-like-capital-one
  • https://expel.io/blog/finding-evil-in-aws/
  • https://expel.io/blog/following-cloudtrail-generating-aws-security-signals-sumo-logic/
  • https://github.com/initstring/cloud_enum
  • https://github.com/RhinoSecurityLabs/cloudgoat
  • https://github.com/RhinoSecurityLabs/pacu
  • https://www.kali.org/docs/containers/installing-docker-on-kali/
  • https://stedolan.github.io/jq/download/
  • https://github.com/Azure/Azure-Sentinel/tree/master/Hunting%20Queries/AWSCloudTrail
  • https://techcommunity.microsoft.com/t5/azure-sentinel/hunting-for-capital-one-breach-ttps-in-aws-logs-using-azure/ba-p/1019767
  • https://blog.appsecco.com/an-ssrf-privileged-aws-keys-and-the-capital-one-breach-4c3c2cded3af
  • https://rhinosecuritylabs.com/penetration-testing/penetration-testing-aws-cloud-need-know/
  • https://rhinosecuritylabs.com/cloud-security/cloudgoat-aws-scenario-ec2_ssrf/
  • https://rhinosecuritylabs.com/cloud-security/aws-security-vulnerabilities-perspective/
  • https://github.com/bishopfox/dufflebag
  • https://github.com/dafthack/PowerMeta
  • https://github.com/dafthack/CloudPentestCheatsheets/blob/master/cheatsheets/AWS.md
  • https://github.com/zricethezav/gitleaks
  • https://github.com/Cloud-Yeti/aws-labs/tree/master/terraform-aws
  • https://www.we45.com/blog/how-an-unclaimed-aws-s3-bucket-escalates-to-subdomain-takeover
  • https://aws.amazon.com/security/penetration-testing/
  • https://aws.amazon.com/guardduty/
  • https://aws.amazon.com/blogs/security/how-security-operation-centers-can-use-amazon-guardduty-to-detect-malicious-behavior/
  • https://aws.amazon.com/cloudtrail/
  • https://aws.amazon.com/security-hub/
  • https://aws.amazon.com/detective/?nc2=type_a
  • https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-concepts.html
  • https://aws.amazon.com/macie/
  • https://aws.amazon.com/cloudwatch/
  • https://aws.amazon.com/inspector/
  • https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html
  • https://docs.aws.amazon.com/whitepapers/latest/classic-intrusion-analysis-frameworks-for-aws-environments/command-and-control.html

More Articles