Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Rule] AWS EC2 Instance Interaction with IAM Service #3920

Merged
merged 3 commits into from
Jul 31, 2024

Conversation

imays11
Copy link
Contributor

@imays11 imays11 commented Jul 24, 2024

Issue link(s):

Summary - What I changed

Identifies when an EC2 instance interacts with the AWS IAM service via an assumed role. This is uncommon behavior and could indicate an attacker using compromised creadentials to further exploit an environment. For example, an assumed role could be used to create new users for persistence or add permissions for privilege escalation. An EC2 instance assumes a role using their EC2 id as the session name. This rule looks for the pattern "i-" which is the beginning pattern for assumed role sessions started by an EC2 instance.

--

I chose to use the user.id field over the aws.cloudtrail.user_identity.arn because this field is able to be ingested via telemtry as PII has been stripped but the session name necessary to identify the identity as an EC2 instance is still included

Screenshot 2024-07-24 at 5 29 28 AM

@imays11 imays11 added Integration: AWS AWS related rules Domain: Cloud Rule: New Proposal for new rule labels Jul 24, 2024
@imays11 imays11 self-assigned this Jul 24, 2024
@protectionsmachine
Copy link
Collaborator

Rule: New - Guidelines

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

Documentation and Context

  • Detailed description of the rule.
  • List any new fields required in ECS/data sources.
  • Link related issues or PRs.
  • Include references.

Rule Metadata Checks

  • creation_date matches the date of creation PR initially merged.
  • min_stack_version should support the widest stack versions.
  • name and description should be descriptive and not include typos.
  • query should be inclusive, not overly exclusive, considering performance for diverse environments. Non ecs fields should be added to non-ecs-schema.json if not available in an integration.
  • min_stack_comments and min_stack_version should be included if the rule is only compatible starting from a specific stack version.
  • index pattern should be neither too specific nor too vague, ensuring it accurately matches the relevant data stream (e.g., use logs-endpoint.process-* for process data).
  • integration should align with the index. If the integration is newly introduced, ensure the manifest, schemas, and new_rule.yaml template are updated.
  • setup should include the necessary steps to configure the integration.
  • note should include any additional information (e.g. Triage and analysis investigation guides, timeline templates).
  • tags should be relevant to the threat and align/added to the EXPECTED_RULE_TAGS in the definitions.py file.
  • threat, techniques, and subtechniques should map to ATT&CK always if possible.

New BBR Rules

  • building_block_type should be included if the rule is a building block and the rule should be located in the rules_building_block folder.
  • bypass_bbr_timing should be included if adding custom lookback timing to the rule.

Testing and Validation

  • Provide evidence of testing and detecting the expected threat.
  • Check for existence of coverage to prevent duplication.

type = "eql"

query = '''
any where event.dataset == "aws.cloudtrail"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imays11 is there any indication in the data that the source of this API request is from an EC2 instance? Would be nice to have entity store to add this context :)

Maybe the source IP is in a common EC2 CIDR or the ARN of the source indicates EC2?

Copy link
Contributor Author

@imays11 imays11 Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@terrancedejesus Yes, the indicator that this is an EC2 instance is the instance id attached to the end of the user.id field and aws.cloudtrail.user_identity.arn which starts with i- You can see that detection method described here by the AWS CIRT team

…_service.toml

Co-authored-by: Terrance DeJesus <99630311 [email protected]>
@terrancedejesus terrancedejesus merged commit a28af59 into main Jul 31, 2024
9 checks passed
@terrancedejesus terrancedejesus deleted the aws_iam_createUser_or_loginprofile_by_ec2 branch July 31, 2024 19:44
protectionsmachine pushed a commit that referenced this pull request Jul 31, 2024
* [New Rule] AWS EC2 Instance Interaction with IAM Service

* Update rules/integrations/aws/persistence_ec2_instance_request_to_iam_service.toml

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

---------

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

(cherry picked from commit a28af59)
protectionsmachine pushed a commit that referenced this pull request Jul 31, 2024
* [New Rule] AWS EC2 Instance Interaction with IAM Service

* Update rules/integrations/aws/persistence_ec2_instance_request_to_iam_service.toml

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

---------

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

(cherry picked from commit a28af59)
protectionsmachine pushed a commit that referenced this pull request Jul 31, 2024
* [New Rule] AWS EC2 Instance Interaction with IAM Service

* Update rules/integrations/aws/persistence_ec2_instance_request_to_iam_service.toml

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

---------

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

(cherry picked from commit a28af59)
protectionsmachine pushed a commit that referenced this pull request Jul 31, 2024
* [New Rule] AWS EC2 Instance Interaction with IAM Service

* Update rules/integrations/aws/persistence_ec2_instance_request_to_iam_service.toml

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

---------

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

(cherry picked from commit a28af59)
protectionsmachine pushed a commit that referenced this pull request Jul 31, 2024
* [New Rule] AWS EC2 Instance Interaction with IAM Service

* Update rules/integrations/aws/persistence_ec2_instance_request_to_iam_service.toml

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

---------

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

(cherry picked from commit a28af59)
protectionsmachine pushed a commit that referenced this pull request Jul 31, 2024
* [New Rule] AWS EC2 Instance Interaction with IAM Service

* Update rules/integrations/aws/persistence_ec2_instance_request_to_iam_service.toml

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

---------

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

(cherry picked from commit a28af59)
zsohamwag pushed a commit to zsohamwag/zsoham-detection-rules that referenced this pull request Sep 13, 2024
* [New Rule] AWS EC2 Instance Interaction with IAM Service

* Update rules/integrations/aws/persistence_ec2_instance_request_to_iam_service.toml

Co-authored-by: Terrance DeJesus <99630311 [email protected]>

---------

Co-authored-by: Terrance DeJesus <99630311 [email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants