Skip to content

[Rule Tuning] AWS IAM Assume Role Policy Update #4799

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

Merged
merged 6 commits into from
Jun 17, 2025

Conversation

imays11
Copy link
Contributor

@imays11 imays11 commented Jun 13, 2025

Pull Request

Issue link(s):

Summary - What I changed

Roles are identities in AWS that are granted a set of permissions and can then be assumed by various users across many different sessions. Each of these sessions is given a session name which is attached to the end of the role's aws.cloudtrail.user_identity.arn. This means that each time a Role is assumed, there is a unique aws.cloudtrail.user_identity.arn created.

This rule is meant to capture new instances of the Role updating role policies. Right now it's analyzing each session used with the Role, resulting in false positives. To capture the role itself we can use the user.name field. cloud.account.id has been added to the new_terms fields to account for organizations with multiple AWS account ids, which may reuse certain user.names across accounts.

  • changed time window to have only 1 minute lookback
  • changed the new terms field to look at combination of cloud.account.id, user.name, and roleName. (This is to account for the problem with using aws.cloudtrail.user_identity.arn for AssumedRoles.)
  • added investigation fields
  • updated mitre techniques

This will improve performance and detection accuracy especially in environments where there are many users assuming the same role and updating it's trust policy as a part of normal operations.

How To Test

You can use this script to test this rule against both IAM user and Assumed Role Identity types.

For manual testing use an existing user or role to update a new policy (to trigger new_terms combination)

aws iam update-assume-role-policy \
    --role-name Test-Role \
    --policy-document file://Test-Role-Trust-Policy.json
Screenshot 2025-06-13 at 12 55 32 AM

- changed time window to have only 1 minute lookback
- changed the new terms field to look at combination of cloud.account.id, user.name, and roleName. This is to account for the problem with using user_identity.arn for AssumedRoles. Roles are identities in AWS that are granted a set of permissions and can then be assumed by various users across many different sessions. Each of these sessions is designated a session name which is attached to the `user_identity.arn`. This means that each time a Role is assumed, there is a unique user_identity.arn created. This rule is meant to capture unique instances of the Role itself which is captured separate from the individual session names in the `user.name` field. `cloud.account.id` has been added to the new_terms fields to account for organizations with multiple AWS account ids, which may reuse certain user.names across accounts.

This may improve performance especially in environments where there are many users assuming the same role and updating it's trust policy as a part of normal operations.
Copy link
Contributor

Rule: Tuning - Guidelines

These guidelines serve as a reminder set of considerations when tuning an existing rule.

Documentation and Context

  • Detailed description of the suggested changes.
  • Provide example JSON data or screenshots.
  • Provide evidence of reducing benign events mistakenly identified as threats (False Positives).
  • Provide evidence of enhancing detection of true threats that were previously missed (False Negatives).
  • Provide evidence of optimizing resource consumption and execution time of detection rules (Performance).
  • Provide evidence of specific environment factors influencing customized rule tuning (Contextual Tuning).
  • Provide evidence of improvements made by modifying sensitivity by changing alert triggering thresholds (Threshold Adjustments).
  • Provide evidence of refining rules to better detect deviations from typical behavior (Behavioral Tuning).
  • Provide evidence of improvements of adjusting rules based on time-based patterns (Temporal Tuning).
  • Provide reasoning of adjusting priority or severity levels of alerts (Severity Tuning).
  • Provide evidence of improving quality integrity of our data used by detection rules (Data Quality).
  • Ensure the tuning includes necessary updates to the release documentation and versioning.

Rule Metadata Checks

  • updated_date matches the date of tuning PR 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. Review to ensure the original intent of the rule is maintained.

Testing and Validation

  • Validate that the tuned rule's performance is satisfactory and does not negatively impact the stack.
  • Ensure that the tuned rule has a low false positive rate.

Copy link
Contributor

@Aegrah Aegrah left a comment

Choose a reason for hiding this comment

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

LGTM!

@terrancedejesus
Copy link
Contributor

@imays11 - It looks like the session ID persists in user.name if it's an assumed role, from what I can tell. Does user.id make more sense? It captures the principal ID and the name of the principal, but does not include the session ID. Regarding cloud.account.id, this is valid if we are concerned with isolating these signals to a single tenant if multi-tenancy is setup. If not, I don't think it would be worth the extra performance.

@imays11
Copy link
Contributor Author

imays11 commented Jun 16, 2025

@terrancedejesus If you look below, session names are persisted in user.id but only the role name itself persists in user.name. If you also look at that session.id field at the end of the image, you can see that it also only shows the role name but this field is only included for AssumedRoles.
Screenshot 2025-06-16 at 11 53 37 AM

Regarding cloud.account.id, this is valid if we are concerned with isolating these signals to a single tenant if multi-tenancy is setup.

Yes we want to isolate this to each individual user, for organizations ingesting cloudtrail logs for multiple accounts we need to distinguish between the same user names across accounts so that's why I included the cloud.account.id

""",
]
from = "now-9m"
from = "now-6m"
interval = "5m"
Copy link
Contributor

Choose a reason for hiding this comment

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

IINM the default is 5m, so you probably dont need to add this.

Copy link
Contributor Author

@imays11 imays11 Jun 17, 2025

Choose a reason for hiding this comment

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

Yes you're correct it's the default right now, I only include it for transparency and just in case the default changes for some reason I want the lookback window to remain 1 m additional

@imays11 imays11 merged commit 133a079 into main Jun 17, 2025
11 checks passed
@imays11 imays11 deleted the tune_new_aws_update_role_policy branch June 17, 2025 19:03
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