elastic / detection-rules

https://www.elastic.co/guide/en/security/current/detection-engine-overview.html
Other
1.92k stars 492 forks source link

[New Rule] AWS CLI Command with Custom Endpoint URL #4002

Closed terrancedejesus closed 1 month ago

terrancedejesus commented 1 month ago

Pull Request

Issue link(s): https://github.com/elastic/ia-trade-team/issues/272

Summary - What I changed

Added a new linux detection rule for AWS CLI command execution where arguments include --endpoint-url. This is a new terms rule to only alert if the user on that endpoint has not been seen using this CLI command and specific argument in the last 10 days.

This stems from Sysdig research on adversary SCARLETEEL where a compromised EC2 instance with AWS cli installed was used to configure authentication to an external AWS environment or environment with applicable protocols for S3. Afterwards AWS CLI commands were executed for data exfiltration and tool installation however, pointed towards the remote site with the use of --endpoint-url.

If --endpoint-url is not used, the AWS CLI will attempt to interact with default AWS services and endpoint's based on either the compromised environment or default public AWS addresses. It is uncommon to leverage an external endpoint that is not default to AWS or custom to the target environment.

An ES|QL query was not used because of the truncated results it presents:

from logs-endpoint.events.process-*
| where @timestamp > now() - 10 days
| where event.category == "process" and process.name == "aws" and process.command_line RLIKE ".*--endpoint-url.*"
| eval date = DATE_FORMAT("yyyy-MM-dd", @timestamp)
| stats day_count = count_distinct(date) by user.name
| where day_count == 1

NOTE - The reason a Linux-based rule for Elastic Defend was created was due to no visibility from CloudTrail logs as AWS will only log the SOAP API calls for services like IAM and S3. As a result, there were no logs available for this from the AWS integration.

How To Test

NOTE - Global telemetry was checked for event.category: "process" and process.name: "aws" and process.args: "--endpoint-url" with no matches in the last 6 months for both SIEM and EDR.

Screenshot 2024-08-21 at 12 00 51 PM

Checklist

Contributor checklist

protectionsmachine commented 1 month ago

Rule: New - Guidelines

These guidelines serve as a reminder set of considerations when proposing a new rule.

Documentation and Context

Rule Metadata Checks

New BBR Rules

Testing and Validation