Skip to content

Commit 86c26a0

Browse files
committed
[Fix] Updating the hunting library
1 parent 2ff2965 commit 86c26a0

7 files changed

+14
-7
lines changed

hunting/aws/docs/iam_assume_role_creation_with_attached_policy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ from logs-aws.cloudtrail-*
2626
and aws.cloudtrail.request_parameters RLIKE ".*arn:aws:iam.*"
2727
| dissect aws.cloudtrail.request_parameters "%{}AWS\": \"arn:aws:iam::%{target_account_id}:"
2828
| where cloud.account.id != target_account_id
29+
| keep @timestamp, event.provider, event.action, aws.cloudtrail.request_parameters, target_account_id, cloud.account.id
2930
```
3031

3132
## Notes

hunting/aws/docs/iam_customer_managed_policies_attached_to_existing_roles.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# AWS IAM Customer-Managed Policy Attachment for Privilege Escalation
1+
# AWS IAM Customer-Managed Policy Attachment to Existing Roles
22

33
---
44

@@ -10,7 +10,7 @@
1010
- **UUID:** `418baaf2-9ae1-11ef-be63-f661ea17fbcd`
1111
- **Integration:** [aws.cloudtrail](https://docs.elastic.co/integrations/aws/cloudtrail)
1212
- **Language:** `[ES|QL]`
13-
- **Source File:** [AWS IAM Customer-Managed Policy Attachment for Privilege Escalation](../queries/iam_customer_managed_policies_attached_to_existing_roles.toml)
13+
- **Source File:** [AWS IAM Customer-Managed Policy Attachment to Existing Roles](../queries/iam_customer_managed_policies_attached_to_existing_roles.toml)
1414

1515
## Query
1616

@@ -29,11 +29,11 @@ from logs-aws.cloudtrail*
2929

3030
## Notes
3131

32-
- Review the `target_account_id` field to verify the AWS account in which the role is being modified, especially if this account is outside of your organization’s typical accounts.
33-
- Examine `aws.cloudtrail.request_parameters` for details on the role and attached policy. Customer-managed policies granting overly permissive access, such as `AdministratorAccess`, may signal unauthorized privilege escalation.
34-
- Cross-reference `event.action` values where `AttachRolePolicy` appears to further investigate attached policies that could enable lateral movement or persistence.
35-
- Evaluate `aws.cloudtrail.user_identity.arn` to confirm if the actor attaching the policy has legitimate permissions for this action. Anomalous or unauthorized actors may indicate privilege abuse.
36-
- Look for patterns of multiple `AttachRolePolicy` actions across roles by the same user or entity. High frequency of these actions could suggest an attempt to establish persistent control across roles within your AWS environment.
32+
- Review the `attached_policy_name` and `target_role_name` fields to identify the customer-managed policy and role involved in the attachment.
33+
- Review the permissions of the attached policy to determine the potential impact of the privilege escalation attempt.
34+
- Review all entities that `target_role_name` may be attached to as these entities may have been compromised or misused.
35+
- Consider reviewing the `aws.cloudtrail.user_identity.arn` field to identify the actor responsible for the privilege escalation attempt.
36+
- Review the user agent of the actor to determine the source of the privilege escalation attempt, such as an AWS CLI or SDK.
3737

3838
## MITRE ATT&CK Techniques
3939

hunting/aws/docs/lambda_add_permissions_for_write_actions_to_function.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ from logs-aws.cloudtrail-*
2424
| dissect aws.cloudtrail.request_parameters "{%{?principal_key}=%{principal_id}, %{?function_name_key}=%{function_name}, %{?statement_key}=%{statement_value}, %{?action_key}=lambda:%{action_value}}"
2525
| eval write_action = (starts_with(action_value, "Invoke") or starts_with("Update", action_value) or starts_with("Put", action_value))
2626
| where write_action == true
27+
| keep @timestamp, principal_id, event.provider, event.action, aws.cloudtrail.request_parameters, principal_id, function_name, action_value, statement_value, write_action
2728
```
2829

2930
## Notes

hunting/aws/docs/signin_single_factor_console_login_via_federated_session.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ from logs-aws.cloudtrail-*
2424
and aws.cloudtrail.user_identity.type == "FederatedUser"
2525
| dissect aws.cloudtrail.additional_eventdata "{%{?mobile_version_key}=%{mobile_version}, %{?mfa_used_key}=%{mfa_used}}"
2626
| where mfa_used == "No"
27+
| keep @timestamp, event.provider, event.action, aws.cloudtrail.event_type, aws.cloudtrail.user_identity.type, aws.cloudtrail.additional_eventdata, mobile_version, mfa_used
2728
```
2829

2930
## Notes

hunting/aws/docs/ssm_sendcommand_api_used_by_ec2_instance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ from logs-aws.cloudtrail-*
2222
and aws.cloudtrail.user_identity.type == "AssumedRole"
2323
and event.action == "SendCommand"
2424
and user.id like "*:i-*"
25+
| keep @timestamp, event.provider, event.action, aws.cloudtrail.user_identity.type, user.id, aws.cloudtrail.request_parameters
2526
```
2627

2728
## Notes

hunting/aws/docs/sts_suspicious_federated_temporary_credential_request.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ from logs-aws.cloudtrail-*
2626
| dissect aws.cloudtrail.request_parameters "{%{}policyArns=[%{policies_applied}]"
2727
| eval duration_minutes = to_integer(duration_requested) / 60
2828
| where (duration_minutes > 1440) or (policies_applied RLIKE ".*AdministratorAccess.*")
29+
| keep @timestamp, event.dataset, event.provider, event.action, aws.cloudtrail.request_parameters, user_name, duration_requested, duration_minutes, policies_applied
2930
```
3031

3132
## Notes

hunting/okta/docs/defense_evasion_failed_oauth_access_token_retrieval_via_public_client_app.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ from logs-okta.system*
3333

3434
// filter for scopes that are not implicitly granted
3535
and okta.outcome.reason == "no_matching_scope"
36+
37+
| keep @timestamp, event.action, okta.actor.type, okta.outcome.result, okta.outcome.reason, okta.actor.display_name
3638
```
3739

3840
## Notes

0 commit comments

Comments
 (0)