Skip to content

Conversation

@chemamartinez
Copy link
Contributor

@chemamartinez chemamartinez commented Oct 8, 2025

Proposed commit message

For CloudTrail events, it has been updated how IAM users are handled.

In particular, for the user identity IAMUser type, the user.name and user.id are
populated with the user fields that made the action/request.

For the user identity AssumedRole type, AWS SIEM rules need roles to be treated as IAMUsers in order to work fine. So the role identifies inside sessionIssuer populate user.* fields. Then, the session name is being mapped as user.changes.name as it can be interpreted as the name the user is taking for that particular session, and it's the closest approach in ECS.

References:

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

Related issues

@chemamartinez chemamartinez self-assigned this Oct 8, 2025
@chemamartinez chemamartinez added enhancement New feature or request Integration:aws AWS Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] labels Oct 8, 2025
@chemamartinez chemamartinez marked this pull request as ready for review October 8, 2025 08:48
@chemamartinez chemamartinez requested review from a team as code owners October 8, 2025 08:48
@elasticmachine
Copy link

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@elastic-vault-github-plugin-prod

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@chemamartinez chemamartinez force-pushed the 25241-aws_cloudtrail-normalize-user-fields branch from 6b2aa19 to 6f4b104 Compare October 21, 2025 15:56
@chemamartinez chemamartinez requested a review from imays11 October 21, 2025 16:01
"private-ec2-instance-role"
"PRINCIPALID",
"private-ec2-instance-role",
"i-03cd6b2a7eb4bf3ae"
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems more odd, since this is a session now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From this same conversation, the goal is to consider the session name as temporary user name, that's why it is being mapped as user.changes.name and therefore included into related.users.

]
},
"related": {
"entity": [],
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, I'd add the "identityStoreArn\":\"arn:aws:identitystore::redacted:identitystore/redacted\" value here

ignore_failure: true
ignore_missing: true
override: true
if: ctx.aws?.cloudtrail?.user_identity?.type == 'AssumedRole'
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to prevent proper mapping for FederatedUser type, which also provides the userIdentity.sessionContext.sessionIssuer.userName field that needs to continue to be mapped to user.name field

target_field: user.id
ignore_missing: true
override: true
if: ctx.aws?.cloudtrail?.user_identity?.type == 'AssumedRole'
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, this change should apply to FederateUser type as well

patterns:
- "arn:aws:sts:.*/%{GREEDYDATA:user.changes.name}$"
ignore_missing: true
if: ctx.aws?.cloudtrail?.user_identity?.type == 'AssumedRole' && ctx.aws?.cloudtrail?.user_identity?.arn != null
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use this to also map the user.changes.name value for FederatedUser identity type. Example: aws.cloudtrail.user_identity.arn : "arn:aws:sts::123445667789:federated-user/fed_consoler" . The arn is created a little differently from Assumed Role since it doesn't keep the calling user's name in the arn but fed_consoler is the name change that should be extracted and treated just like we are treated the session.name for AssumedRole identity type.

@chemamartinez chemamartinez requested a review from imays11 October 28, 2025 08:23
@chemamartinez
Copy link
Contributor Author

@imays11 @Mikaayenson I have a question for you, the latest changes to the change request respond to Isai's suggestions to avoid breaking the existing rules, so role names are still mapped as user.name and the only change would be to assign the session name to user.changes.name, which I don't think should be a problem for the rules. Correct me if I'm wrong.

Do you still agree with these changes? I understand that the most painful change for you would be to separate roles and user names into different fields. If so, assigning some-role to user.roles would break the rules, right?

@imays11
Copy link
Contributor

imays11 commented Nov 7, 2025

@chemamartinez

@imays11 @Mikaayenson I have a question for you, the latest changes to the change request respond to Isai's suggestions to avoid breaking the existing rules, so role names are still mapped as user.name and the only change would be to assign the session name to user.changes.name, which I don't think should be a problem for the rules. Correct me if I'm wrong.

Yes I still agree with those changes

Do you still agree with these changes? I understand that the most painful change for you would be to separate roles and user names into different fields. If so, assigning some-role to user.roles would break the rules, right?

Yes that is correct, if the some-role > user.name mapping is removed that would require us to duplicate a set of new terms rules to utilize the new field mapping for roles.

@imays11
Copy link
Contributor

imays11 commented Nov 10, 2025

@chemamartinez
Have you considered using cloud.entity.name as a field that can be used for both IAM Users and Roles?
https://www.elastic.co/docs/reference/ecs/ecs-cloud#ecs-cloud-nestings
https://www.elastic.co/docs/reference/ecs/ecs-entity#field-entity-name

@chemamartinez
Copy link
Contributor Author

Yes I still agree with those changes

In that case, if no more changes are required the PR is ready for review I think.

Yes that is correct, if the some-role > user.name mapping is removed that would require us to duplicate a set of new terms rules to utilize the new field mapping for roles.
Have you considered using cloud.entity.name as a field that can be used for both IAM Users and Roles?

@imays11 aren't these two comments contradictory? If we now map the fields to cloud.entity.name instead of keeping using user.name all rules should be rewritten, isn't it?

@imays11
Copy link
Contributor

imays11 commented Nov 11, 2025

Yes that is correct, if the some-role > user.name mapping is removed that would require us to duplicate a set of new terms rules to utilize the new field mapping for roles.
Have you considered using cloud.entity.name as a field that can be used for both IAM Users and Roles?

@imays11 aren't these two comments contradictory? If we now map the fields to cloud.entity.name instead of keeping using user.name all rules should be rewritten, isn't it?

@chemamartinez
No, as long as both user identity types are under the same field (user.name OR cloud.entity.name), then we can simply do a rule tuning of the existing rules and replace the user.name field to use cloud.entity.name field instead.

The problem comes with keeping IAM Users under user.name but moving Roles to a different field like user.roles. That would require us to create a duplicate set of rules in order to utilize 2 different fields.

I'm fine keeping both under user.name, I only gave the suggestion because I know there was some concern of "long-term semantic weakening of an ECS field definition" by keeping Roles under user.name field.

@chemamartinez
Copy link
Contributor Author

@imays11 thanks for the clarification!

@chemamartinez chemamartinez requested a review from efd6 November 12, 2025 15:14
@efd6
Copy link
Contributor

efd6 commented Nov 12, 2025

Am I correct in understanding that this change is still going to conflate roles with users? If that's the case, I still do not agree, but I am not going to block this.

@kcreddy
Copy link
Contributor

kcreddy commented Nov 13, 2025

@chemamartinez Have you considered using cloud.entity.name as a field that can be used for both IAM Users and Roles? https://www.elastic.co/docs/reference/ecs/ecs-cloud#ecs-cloud-nestings https://www.elastic.co/docs/reference/ecs/ecs-entity#field-entity-name

One problem is that the field entity.name is in Beta and may not be ideal for GA integration. Also, the field is introduced in ECS version 9.1 while aws integration uses 8.11. Changing it to 9.1 might require approvals from all owners of aws integration.

@chemamartinez
Copy link
Contributor Author

Am I correct in understanding that this change is still going to conflate roles with users? If that's the case, I still do not agree, but I am not going to block this.

@efd6 yes, but this is not something in this PR. It is something it was happening before so the SIEM rules work.

@chemamartinez chemamartinez requested a review from a team November 18, 2025 17:02
@elasticmachine
Copy link

💚 Build Succeeded

History

cc @chemamartinez

Copy link
Contributor

@agithomas agithomas left a comment

Choose a reason for hiding this comment

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

LGTM, considering the design approach taken! Code owner approval.

@chemamartinez chemamartinez merged commit 42ef6c9 into elastic:main Dec 17, 2025
8 checks passed
@chemamartinez chemamartinez deleted the 25241-aws_cloudtrail-normalize-user-fields branch December 17, 2025 14:28
@elastic-vault-github-plugin-prod

Package aws - 5.2.0 containing this change is available at https://epr.elastic.co/package/aws/5.2.0/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Integration:aws AWS Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

7 participants