🕳️
The Cyber Security Library
  • The Library
  • Offensive Security
    • Solar, Exploiting log4j
      • Reconnaissance
      • Discovery
      • Proof of Concept
      • Exploitation
    • Basic Authentication Bypass
      • Username Enumeration
      • Brute Force
      • Logic Flaw
      • Cookie Tampering
    • Insekube
      • Recon with Nmap
      • Checking out the web address
      • Creating a Reverse shell
      • Inside the Kubernetes pod
      • CVE-2021-43798
    • Snort
      • What is Snort? (For the uninitiated)
      • Task exercise
      • Traffic Generator
      • Brief overview of IDS and IPS
      • Checking Snort
      • Snort Sniffer mode
      • Packet Logger mode
    • Runtime Detection Evasion
      • Learning Objectives of AMSI
      • Runtime detections
      • AMSI Overview
      • AMSI Instrumentation
      • Powershell Downgrade
      • Powershell Reflection
      • Patching AMSI
    • Red team recon using OSINT
      • Taxonomy of Reconnaissance
      • Built-in tools
      • Advanced Searching
      • Specialized Search Engines
  • Malware
    • Introduction to Malware Analysis
      • What are the different types of malware analysis
      • Doing different types of analysis
      • Anti analysis techniques
    • Ransomeware: Maze
    • Exploring Steganography
    • Simple Trojan with Python
      • The Python Trojan
      • Breaking down the python code
  • Vulnerability Management
    • Nessus
      • Introduction
      • Nessus Essentials
      • Scans
      • Authenticated Scans
      • Results
      • Running custom scans
  • Cloud
    • AWS
      • AWS CDK: Deploy and using amazon SQS Que from Repo
        • Node modules and Bootstrapping troubleshooting
        • Sending and Receiving information from the stack
        • Destroying the stack and cleaning up
      • Using Different AWS Services with Splunk
        • AWS Config
          • How Does Config work?
          • How to enable Config
          • Settings
          • Aggregation
          • Creating Config Resource
          • Creating Aggregator
          • Adding Rules
        • CloudTrail
          • What is CloudTrail?
          • Features of CloudTrail
          • Benefits of CloudTrail
          • CloudTrail Event History
          • Securing CloudTrail
        • EventBridge
          • Configuring EventBridge and Event Patterns
          • EventBridge Targets
        • CloudWatch
          • The CloudWatch Dashboard
            • Virtual Machine
          • CloudWatch Alarms and Metric Filters
            • Searching logs using metric filters
            • CloudWatch Alarms
          • CloudWatch CIS Alarms
            • SNS
        • Configuring VPC Flow Logs
          • An introduction to VPC flow logs
        • Automating Incident Response with EventBridge
          • Creating Lambda functions
        • CloudTrail SIEM Integration (Splunk)
          • AWS architecture for integrating with Splunk
      • AWS DevOps EBS Volumes
        • CloudWatch
        • EBS Volume
        • Lambda
      • EKS Creating a deployment with AWS in the command Line
        • Setting up AWS Cloud9
        • Creating a Cluster
        • Creating Deployment
      • How to CloudShell SSH in to ec2 Instances
    • Azure
      • Worker CTF (Azure DevOps)
        • Enumeration
        • Using SVN
        • Exploring the Domain
        • Cracking Azure DevOps console
      • Software development environments and Azure DevOps pipeline abuse
        • Accessing Azure Devops
        • Exploring Project Pages
  • Splunk
    • Splunk SIEM Integration
      • AWS architecture for integrating with Splunk
    • Splunk Threat Hunting Ep.6 Credential Access
  • DevOps
    • Using AWS, Docker, Jenkins and SonarQube to improve code quality
      • Updating the Cloud Instance and Getting Docker
      • Installing SonarQube
      • Creating Jenkins Server
      • Manaing SonarQube and Jenkins
    • Creating a Codebuild project and getting the output with CloudWatch Logs
      • IAM
      • CodeBuild
  • CTF's
    • THM Wonderland
      • Nmap and Gobuster
      • Entering Wonderland
      • Privilege Escalation
    • Healthcare OpenEMR system -THM Plotted EMR
      • Recon with Nmap
      • Exploring the ports found
      • Gobuster
      • Searchsploit Open emr
    • Steam Cloud CTF Exploiting Kubernetes
      • SteamCloud Privilege Escalation
    • THM Flatline CTF
      • Recon with Nmap
      • Searchsploit for freeswitch
      • Using the exploit
      • Escalating my privileges
      • Gaining access inside the Windows RDP
    • Biteme CTF
      • Recon
      • Looking into the PHP code and decoding hexadecimal
      • Python script and Bash script
      • Bruteforcing MFA Code
      • Trying to gain access via SSH
      • Inside SSH
      • Fail2ban Privilege Escalation
    • Devoops CTF
      • Enumeration
      • Exploiting Web Page
      • Creating Python exploit
    • GoBox CTF
      • Enumeration
      • Using Burpsuite and creating Reverse shell
    • Explore: Android Box
      • Enumeration
      • Initial foothold
      • Privilege escalation
Powered by GitBook
On this page
  • The CloudTrail console
  • Editing a trail
  • Creating a trail
  • Specifying events
  • Retrieving log files
  • Interpreting events
  1. Cloud
  2. AWS
  3. Using Different AWS Services with Splunk
  4. CloudTrail

Securing CloudTrail

PreviousCloudTrail Event HistoryNextEventBridge

Last updated 1 year ago

Enabling a trail in your AWS account is a significant first step toward improving observability, but ensuring you have configured it securely is vital. AWS provides several tools to ensure your logging isn’t at risk:

  • You can enable log file validation on trails to ensure you're confident that logs have not been tampered with after generation. This will allow you to remove elements of uncertainty and help prevent non-repudiation when teams carry out investigations after security incidents.

  • Logging across all regions will mean you don’t miss any activity in your account. While you and your team may only work in one or two different regions, attackers are likely to disperse their activity across all regions to avoid detection.

  • AWS automatically encrypts your log files with Amazon server-side encryption. If you want more direct control over the encryption, you can use customer-managed keys with AWS KMS.

  • Access to the trail, the buckets that store the logs, and any KMS keys you use for encryption should be restricted. Your IAM policies should follow the principle of least privilege, and only those that require access for their roles should be able to view logs.

The CloudTrail console

Searching “CloudTrail” in the top search bar of the console will let you navigate to the CloudTrail console home, where you can select the dashboard (as seen in the image above). If you struggle to view the images, right-click on them and select Open image in a new tab.

From here, you can see the trails currently running in the account for the region you've selected. You should be in the eu-west-1 region for this series, unless otherwise specified. As mentioned in the introduction lab, you will not have access to the event history for this series.

Editing a trail

Clicking on a trail will allow you to see its configuration options. This is where you can see various security options for the trail such as:

  • If the trail is recording multi-region data

  • Enabling log file validation

  • Configuring SSE-KMS encryption

  • Trail log location (S3 bucket used to store the logs)

Clicking on the Edit button will allow you to change these settings.

This is also where you can manage the trail’s functionality by stopping logging, which will stop the trail from delivering logs to the specified location, or deleting the trail, which will remove it from your account altogether. Deleting a trail will not delete log files that are stored in an S3 bucket.

Creating a trail

Selecting Create trail from the dashboard will take you through several screens where you can choose the options for a new trail. The first section is General details, as shown in the image above.

CloudTrail will automatically create a path structure in your bucket with prefixes for regions and dates, but you can also add your own prefix. This is useful if you wish to log multiple trails to the same S3 bucket.

In this section, you can also turn on log-file validation and Simple Notification System (SNS) notifications.

Trails created via the console are automatically set to be multi-region.

Specifying events

Clicking Next will take you to the Choose log events page. Here you can specify the type of events you want this trail to monitor. There are three options:

  • Management Events – these are events that occur to your cloud resources. Examples include users creating S3 buckets, a lambda function creating an IAM user, and someone launching an EC2 instance.

  • Data Events – these are events that occur within specific resources. Only certain services are available as sources for this event type. As an example, for the S3 service, data events would be object-level API activity.

For Management events, you can choose to record either Read or Write events, or both. You can also choose to exclude certain services.

Clicking on Next will take you to the final page, where you can review your settings for the trail and confirm them by selecting Create trail.

Retrieving log files

Once you have a trail up and running, you can retrieve your log files by navigating to the S3 bucket set as that trail’s log location. Inside the log bucket, the logs use the following file structure:

AWSLogs/<AccountNumber>/CloudTrail/<Region>/<Year>/<Month>/<Day>/<LogFiles>

Interpreting events

CloudTrail events can be viewed in the Event history section of the CloudTrail console or within log files retrieved from S3 (in addition to standard CLI, API, and SDK methods). Identifying pertinent information in an event is useful in incident response and investigations to determine user activity.

Event logs are simply JSON-formatted data containing information about a certain instance of user activity. Fields can differ across CloudTrail events, especially within the requestParameters array, because this contains action-specific request parameters. However, there are some core fields present in almost every CloudTrail event that you should recognize and use to extract useful information:

  • userIdentity: this field contains information on the principal making the API call. This can include:

    • type: usually an IAMUser or AssumedRole

    • arn: the ARN of the principal, which is a globally unique identifier for the principal

    • accountId: the account the principal originates from

  • eventTime: when the action occurred

  • eventSource: usually which API the event was generated from, for example ec2.amazonaws.com

  • eventName: the API call made, such as StartLogging for CloudTrail

  • sourceIpAddress: the source IPv4 address of the request to the API

  • userAgent: the agent used to make the request, such as a specific browser, or the AWS CLI

  • requestParameters: provided parameters, specific to the API call. For example, the ID of the EC2 instance to stop

This api call is requesting “StopInstances”

Creating a new trail Created a new trail in the eu-west-1 region. Caledl it metrolio-s3-trail. Set the log location to be the existing S3 bucket called metrolio-log-bucket-s3-actions-8bb83f2a. Encrypt the trail using the metrolio-log-key-daca2753 and enable log file validation.

On the next page, Deselected management events and selected data events. Chose the data event type in S3 and in the log selector template drop down, I selected Log writeOnly events and call the event selectir s3-write-selector

This is the S3 buckets storing the log files from the management trails. The file extension for these logs are json.gz

You'll need to give your new trail a name. For Storage location, you can either choose to create a new S3 bucket that CloudTrail will set up for you or use an existing S3 bucket. If you choose an existing bucket, you'll need to ensure it has a .

You can also enable log-file encryption using AWS’s Key Management Service (KMS). CloudTrail can create a key automatically, or you can specify an existing KMS key that will require a .

– these are events where CloudTrail has determined unusual write API activity for management events.

You can choose a trail to log one, all, or a combination of these options. A comparison of management and data events is available on the

For Data events, you'll need to select the AWS service that will act as the source of these events. You will have various options for each service to refine the exact kinds of events you want to capture. This set of rules for what to capture is known as an . You can name your event selector and have multiple selectors for one trail.

You can see a truncated example of this below from the :

suitable bucket policy
valid key policy for CloudTrail to use
Insight Events
AWS Support page
event selector
AWS CloudTrail user guide