nldcsc-elastic-rules 0.0.8__py3-none-any.whl → 0.0.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nldcsc_elastic_rules/__init__.py +1 -1
- nldcsc_elastic_rules/rules/{linux → cross-platform}/command_and_control_curl_wget_spawn_via_nodejs_parent.toml +32 -11
- nldcsc_elastic_rules/rules/cross-platform/command_and_control_genai_process_suspicious_tld_connection.toml +134 -0
- nldcsc_elastic_rules/rules/cross-platform/command_and_control_genai_process_unusual_domain.toml +128 -0
- nldcsc_elastic_rules/rules/cross-platform/credential_access_genai_process_sensitive_file_access.toml +154 -0
- nldcsc_elastic_rules/rules/cross-platform/credential_access_gitleaks_execution.toml +114 -0
- nldcsc_elastic_rules/rules/cross-platform/credential_access_multi_could_secrets_via_api.toml +198 -0
- nldcsc_elastic_rules/rules/cross-platform/credential_access_trufflehog_execution.toml +24 -5
- nldcsc_elastic_rules/rules/cross-platform/defense_evasion_genai_config_modification.toml +120 -0
- nldcsc_elastic_rules/rules/cross-platform/defense_evasion_genai_process_compiling_executables.toml +158 -0
- nldcsc_elastic_rules/rules/cross-platform/defense_evasion_genai_process_encoding_prior_to_network_activity.toml +172 -0
- nldcsc_elastic_rules/rules/cross-platform/defense_evasion_potential_http_downgrade_attack.toml +98 -0
- nldcsc_elastic_rules/rules/cross-platform/discovery_web_server_local_file_inclusion_activity.toml +172 -0
- nldcsc_elastic_rules/rules/cross-platform/discovery_web_server_remote_file_inclusion_activity.toml +133 -0
- nldcsc_elastic_rules/rules/cross-platform/execution_aws_ec2_lolbin_via_ssm.toml +250 -0
- nldcsc_elastic_rules/rules/{linux/persistence_nodejs_pre_or_post_install_script_execution.toml → cross-platform/execution_nodejs_pre_or_post_install_script_execution.toml} +40 -24
- nldcsc_elastic_rules/rules/cross-platform/execution_privileged_container_creation_with_host_reference.toml +146 -0
- nldcsc_elastic_rules/rules/cross-platform/execution_register_github_actions_runner.toml +126 -0
- nldcsc_elastic_rules/rules/cross-platform/execution_via_github_actions_runner.toml +130 -0
- nldcsc_elastic_rules/rules/cross-platform/execution_via_github_runner_with_runner_tracking_id_tampering_via_env_vars.toml +163 -0
- nldcsc_elastic_rules/rules/cross-platform/initial_access_execution_susp_react_serv_child.toml +130 -0
- nldcsc_elastic_rules/rules/cross-platform/initial_access_file_upload_followed_by_get_request.toml +145 -0
- nldcsc_elastic_rules/rules/cross-platform/multiple_alerts_elastic_defend_netsecurity_by_host.toml +4 -1
- nldcsc_elastic_rules/rules/cross-platform/persistence_credential_access_modify_auth_module_or_config.toml +3 -4
- nldcsc_elastic_rules/rules/cross-platform/persistence_web_server_potential_command_injection.toml +23 -25
- nldcsc_elastic_rules/rules/cross-platform/reconnaissance_web_server_discovery_or_fuzzing_activity.toml +13 -14
- nldcsc_elastic_rules/rules/cross-platform/reconnaissance_web_server_unusual_spike_in_error_logs.toml +8 -5
- nldcsc_elastic_rules/rules/cross-platform/reconnaissance_web_server_unusual_spike_in_error_response_codes.toml +12 -12
- nldcsc_elastic_rules/rules/cross-platform/reconnaissance_web_server_unusual_user_agents.toml +37 -43
- nldcsc_elastic_rules/rules/integrations/aws/defense_evasion_rds_instance_restored.toml +137 -45
- nldcsc_elastic_rules/rules/integrations/aws/discovery_iam_principal_enumeration_via_update_assume_role_policy.toml +152 -0
- nldcsc_elastic_rules/rules/integrations/aws/discovery_multiple_discovery_api_calls_via_cli.toml +242 -0
- nldcsc_elastic_rules/rules/integrations/aws/exfiltration_rds_snapshot_export.toml +141 -33
- nldcsc_elastic_rules/rules/integrations/aws/exfiltration_rds_snapshot_shared_with_another_account.toml +108 -30
- nldcsc_elastic_rules/rules/integrations/aws/exfiltration_s3_bucket_policy_added_for_external_account_access.toml +2 -1
- nldcsc_elastic_rules/rules/integrations/aws/exfiltration_s3_bucket_replicated_to_external_account.toml +114 -27
- nldcsc_elastic_rules/rules/integrations/aws/impact_efs_filesystem_deleted.toml +174 -0
- nldcsc_elastic_rules/rules/integrations/aws/impact_kms_cmk_disabled_or_scheduled_for_deletion.toml +111 -33
- nldcsc_elastic_rules/rules/integrations/aws/impact_rds_instance_cluster_deletion.toml +129 -43
- nldcsc_elastic_rules/rules/integrations/aws/impact_rds_instance_cluster_deletion_protection_disabled.toml +89 -27
- nldcsc_elastic_rules/rules/integrations/aws/impact_rds_snapshot_deleted.toml +127 -37
- nldcsc_elastic_rules/rules/integrations/aws/impact_s3_object_encryption_with_external_key.toml +160 -43
- nldcsc_elastic_rules/rules/integrations/aws/initial_access_iam_session_token_used_from_multiple_addresses.toml +20 -10
- nldcsc_elastic_rules/rules/integrations/aws/ml_cloudtrail_error_message_spike.toml +35 -1
- nldcsc_elastic_rules/rules/integrations/aws/ml_cloudtrail_rare_error_code.toml +59 -1
- nldcsc_elastic_rules/rules/integrations/aws/ml_cloudtrail_rare_method_by_city.toml +19 -1
- nldcsc_elastic_rules/rules/integrations/aws/ml_cloudtrail_rare_method_by_country.toml +19 -1
- nldcsc_elastic_rules/rules/integrations/aws/ml_cloudtrail_rare_method_by_user.toml +58 -1
- nldcsc_elastic_rules/rules/integrations/aws/persistence_rds_db_instance_password_modified.toml +109 -35
- nldcsc_elastic_rules/rules/integrations/aws/persistence_rds_instance_made_public.toml +103 -22
- nldcsc_elastic_rules/rules/integrations/aws/persistence_redshift_instance_creation.toml +3 -3
- nldcsc_elastic_rules/rules/integrations/aws/privilege_escalation_sts_assume_root_from_rare_user_and_member_account.toml +126 -69
- nldcsc_elastic_rules/rules/integrations/azure/credential_access_azure_entra_susp_device_code_signin.toml +134 -0
- nldcsc_elastic_rules/rules/integrations/azure/credential_access_entra_id_excessive_account_lockouts.toml +2 -2
- nldcsc_elastic_rules/rules/integrations/azure/ml_azure_event_failures.toml +124 -0
- nldcsc_elastic_rules/rules/integrations/azure/ml_azure_rare_event_failures.toml +148 -0
- nldcsc_elastic_rules/rules/integrations/azure/ml_azure_rare_method_by_city.toml +109 -0
- nldcsc_elastic_rules/rules/integrations/azure/ml_azure_rare_method_by_country.toml +108 -0
- nldcsc_elastic_rules/rules/integrations/azure/ml_azure_rare_method_by_user.toml +147 -0
- nldcsc_elastic_rules/rules/integrations/fim/persistence_suspicious_file_modifications.toml +9 -1
- nldcsc_elastic_rules/rules/integrations/gcp/ml_gcp_error_message_spike.toml +95 -0
- nldcsc_elastic_rules/rules/integrations/gcp/ml_gcp_rare_error_code.toml +118 -0
- nldcsc_elastic_rules/rules/integrations/gcp/ml_gcp_rare_method_by_city.toml +79 -0
- nldcsc_elastic_rules/rules/integrations/gcp/ml_gcp_rare_method_by_country.toml +79 -0
- nldcsc_elastic_rules/rules/integrations/gcp/ml_gcp_rare_method_by_user.toml +117 -0
- nldcsc_elastic_rules/rules/integrations/github/initial_access_github_register_self_hosted_runner.toml +92 -0
- nldcsc_elastic_rules/rules/integrations/o365/collection_onedrive_excessive_file_downloads.toml +24 -14
- nldcsc_elastic_rules/rules/linux/defense_evasion_file_deletion_via_shred.toml +12 -5
- nldcsc_elastic_rules/rules/linux/execution_suspicious_pod_or_container_creation_command_execution.toml +150 -0
- nldcsc_elastic_rules/rules/linux/persistence_at_job_creation.toml +4 -4
- nldcsc_elastic_rules/rules/linux/persistence_pluggable_authentication_module_creation.toml +12 -7
- nldcsc_elastic_rules/rules/linux/persistence_pth_file_creation.toml +6 -1
- nldcsc_elastic_rules/rules/linux/persistence_site_and_user_customize_file_creation.toml +6 -1
- nldcsc_elastic_rules/rules/linux/persistence_web_server_unusual_command_execution.toml +155 -0
- nldcsc_elastic_rules/rules/ml/ml_high_count_events_for_a_host_name.toml +58 -1
- nldcsc_elastic_rules/rules/ml/ml_high_count_network_denies.toml +71 -1
- nldcsc_elastic_rules/rules/ml/ml_high_count_network_events.toml +53 -1
- nldcsc_elastic_rules/rules/ml/ml_linux_anomalous_network_activity.toml +56 -1
- nldcsc_elastic_rules/rules/ml/ml_linux_anomalous_network_port_activity.toml +40 -1
- nldcsc_elastic_rules/rules/ml/ml_low_count_events_for_a_host_name.toml +27 -1
- nldcsc_elastic_rules/rules/ml/ml_packetbeat_rare_server_domain.toml +63 -1
- nldcsc_elastic_rules/rules/ml/ml_rare_destination_country.toml +68 -1
- nldcsc_elastic_rules/rules/ml/ml_spike_in_traffic_to_a_country.toml +53 -1
- nldcsc_elastic_rules/rules/ml/ml_windows_anomalous_network_activity.toml +56 -1
- nldcsc_elastic_rules/rules/network/initial_access_react_server_components_rce_attempt.toml +123 -0
- nldcsc_elastic_rules/rules/promotions/external_alerts.toml +2 -2
- nldcsc_elastic_rules/rules/windows/command_and_control_common_webservices.toml +4 -3
- nldcsc_elastic_rules/rules/windows/credential_access_rare_webdav_destination.toml +3 -4
- nldcsc_elastic_rules/rules/windows/defense_evasion_masquerading_as_svchost.toml +11 -8
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation.toml +25 -2
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation_backtick.toml +2 -3
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation_backtick_var.toml +2 -3
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation_char_arrays.toml +2 -3
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation_concat_dynamic.toml +2 -3
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation_high_number_proportion.toml +2 -3
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation_iex_env_vars_reconstruction.toml +2 -3
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation_iex_string_reconstruction.toml +2 -3
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation_index_reversal.toml +2 -3
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation_reverse_keyword.toml +2 -3
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation_string_concat.toml +2 -3
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation_string_format.toml +2 -3
- nldcsc_elastic_rules/rules/windows/defense_evasion_posh_obfuscation_whitespace_special_proportion.toml +2 -3
- nldcsc_elastic_rules/rules/windows/defense_evasion_wsl_filesystem.toml +13 -10
- nldcsc_elastic_rules/rules/windows/execution_posh_hacktool_functions.toml +3 -2
- nldcsc_elastic_rules/rules/windows/execution_suspicious_powershell_imgload.toml +7 -2
- nldcsc_elastic_rules/rules/windows/execution_windows_powershell_susp_args.toml +9 -2
- nldcsc_elastic_rules/rules/windows/impact_mod_critical_os_files.toml +16 -6
- nldcsc_elastic_rules/rules/windows/lateral_movement_credential_access_kerberos_correlation.toml +7 -2
- nldcsc_elastic_rules/rules/windows/lateral_movement_scheduled_task_target.toml +2 -2
- nldcsc_elastic_rules/rules/windows/persistence_browser_extension_install.toml +19 -2
- nldcsc_elastic_rules/rules/windows/persistence_msi_installer_task_startup.toml +50 -13
- nldcsc_elastic_rules/rules/windows/persistence_via_application_shimming.toml +12 -2
- nldcsc_elastic_rules/rules/windows/privilege_escalation_tokenmanip_sedebugpriv_enabled.toml +24 -18
- nldcsc_elastic_rules/rules/windows/privilege_escalation_unusual_printspooler_childprocess.toml +14 -2
- nldcsc_elastic_rules/rules/windows/privilege_escalation_via_ppid_spoofing.toml +3 -2
- {nldcsc_elastic_rules-0.0.8.dist-info → nldcsc_elastic_rules-0.0.16.dist-info}/METADATA +1 -1
- {nldcsc_elastic_rules-0.0.8.dist-info → nldcsc_elastic_rules-0.0.16.dist-info}/RECORD +119 -87
- nldcsc_elastic_rules/rules/integrations/aws/credential_access_aws_iam_assume_role_brute_force.toml +0 -105
- nldcsc_elastic_rules/rules/integrations/aws/discovery_ec2_multi_region_describe_instances.toml +0 -135
- nldcsc_elastic_rules/rules/integrations/aws/discovery_ec2_multiple_discovery_api_calls_via_cli.toml +0 -155
- nldcsc_elastic_rules/rules/integrations/aws/impact_efs_filesystem_or_mount_deleted.toml +0 -95
- {nldcsc_elastic_rules-0.0.8.dist-info → nldcsc_elastic_rules-0.0.16.dist-info}/WHEEL +0 -0
- {nldcsc_elastic_rules-0.0.8.dist-info → nldcsc_elastic_rules-0.0.16.dist-info}/top_level.txt +0 -0
|
@@ -2,24 +2,130 @@
|
|
|
2
2
|
creation_date = "2021/06/29"
|
|
3
3
|
integration = ["aws"]
|
|
4
4
|
maturity = "production"
|
|
5
|
-
updated_date = "2025/01
|
|
5
|
+
updated_date = "2025/12/01"
|
|
6
6
|
|
|
7
7
|
[rule]
|
|
8
8
|
author = ["Austin Songer", "Elastic"]
|
|
9
9
|
description = """
|
|
10
|
-
|
|
10
|
+
Identifies the restoration of an AWS RDS database instance from a snapshot or S3 backup. Adversaries with access to
|
|
11
|
+
valid credentials may restore copies of existing databases to bypass logging and monitoring controls or to exfiltrate
|
|
12
|
+
sensitive data from a duplicated environment. This rule detects successful restoration operations using
|
|
13
|
+
"RestoreDBInstanceFromDBSnapshot" or "RestoreDBInstanceFromS3", which may indicate unauthorized data access or
|
|
14
|
+
post-compromise defense evasion.
|
|
11
15
|
"""
|
|
12
16
|
false_positives = [
|
|
13
17
|
"""
|
|
14
|
-
Restoring DB
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
Restoring an RDS DB instance may be performed legitimately during troubleshooting, development refresh processes,
|
|
19
|
+
migrations, or disaster-recovery drills. Validate the user identity, source IP, automation context, and whether the
|
|
20
|
+
restoration aligns with a known maintenance or testing workflow before treating the event as suspicious. Expected
|
|
21
|
+
behavior can be exempted through rule exceptions.
|
|
17
22
|
""",
|
|
18
23
|
]
|
|
19
24
|
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
|
|
20
|
-
language = "
|
|
25
|
+
language = "kuery"
|
|
21
26
|
license = "Elastic License v2"
|
|
22
27
|
name = "AWS RDS DB Instance Restored"
|
|
28
|
+
note = """## Triage and analysis
|
|
29
|
+
|
|
30
|
+
> **Disclaimer**:
|
|
31
|
+
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance.
|
|
32
|
+
> While every effort has been made to ensure its quality, validate and adapt it to suit your operational needs.
|
|
33
|
+
|
|
34
|
+
### Investigating AWS RDS DB Instance Restored
|
|
35
|
+
|
|
36
|
+
Restoring an RDS DB instance from a snapshot or from S3 is a powerful operation that recreates a full database environment. While legitimate for recovery, migrations, or cloning, adversaries may use restore actions to access historical data, duplicate sensitive environments, evade guardrails, or prepare for data exfiltration.
|
|
37
|
+
|
|
38
|
+
This rule detects successful invocation of `RestoreDBInstanceFromDBSnapshot` and `RestoreDBInstanceFromS3`, both of which may indicate attempts to rehydrate old datasets, bypass deletion protection, or establish a shadow environment for further malicious actions.
|
|
39
|
+
|
|
40
|
+
#### Possible investigation steps
|
|
41
|
+
|
|
42
|
+
- **Identify the actor and execution context**
|
|
43
|
+
- Review `aws.cloudtrail.user_identity.arn`, `aws.cloudtrail.user_identity.type`, and `aws.cloudtrail.user_identity.access_key_id`.
|
|
44
|
+
- Check `user.name`, `source.ip`, and `user_agent.original` to determine how the restore was executed (console, CLI, automation, SDK).
|
|
45
|
+
|
|
46
|
+
- **Understand what was restored and why**
|
|
47
|
+
- Inspect `aws.cloudtrail.request_parameters` to identify:
|
|
48
|
+
- Snapshot identifier or S3 location used as the restore source.
|
|
49
|
+
- The new DB instance identifier and configuration parameters.
|
|
50
|
+
- Determine:
|
|
51
|
+
- Whether the snapshot/backup used for the restore contains sensitive or high-value data.
|
|
52
|
+
- Whether this restore created a publicly accessible instance, changed security groups, or used unusual storage/instance classes.
|
|
53
|
+
|
|
54
|
+
- **Reconstruct the activity flow**
|
|
55
|
+
- Use `@timestamp` to correlate the restore event with:
|
|
56
|
+
- Snapshot creation, copy, or export events.
|
|
57
|
+
- IAM policy changes or privilege escalations.
|
|
58
|
+
- Deletion or modification of the original database.
|
|
59
|
+
- Other RDS lifecycle actions such as `ModifyDBInstance`, `DeleteDBInstance`, or backup configuration changes.
|
|
60
|
+
- Look for signs of attacker staging:
|
|
61
|
+
- Prior enumeration activity (`DescribeDBSnapshots`, `DescribeDBInstances`).
|
|
62
|
+
- Recent logins from unusual IPs or federated sessions without MFA.
|
|
63
|
+
|
|
64
|
+
- **Correlate with broader behavior**
|
|
65
|
+
- Pivot in CloudTrail on:
|
|
66
|
+
- The same snapshot identifier.
|
|
67
|
+
- The same actor or access key ID.
|
|
68
|
+
- The newly created DB instance identifier.
|
|
69
|
+
- Examine:
|
|
70
|
+
- Whether the restored DB was modified immediately after (e.g., security groups opened, deletion protection disabled).
|
|
71
|
+
- Whether there were large-volume read operations or export actions following the restore.
|
|
72
|
+
- Whether the restore is part of a pattern of parallel suspicious activity (snapshot copying, S3 backups, cross-account actions).
|
|
73
|
+
|
|
74
|
+
- **Validate intent with owners**
|
|
75
|
+
- Confirm with the application/database/platform teams:
|
|
76
|
+
- Whether the restore was requested or part of an authorized operational workflow.
|
|
77
|
+
- Whether this restore corresponds to migration, testing, DR drill, or another planned activity.
|
|
78
|
+
- Whether the restored environment should exist (and for how long).
|
|
79
|
+
|
|
80
|
+
### False positive analysis
|
|
81
|
+
|
|
82
|
+
- **Legitimate maintenance and DR workflows**
|
|
83
|
+
- Many teams restore databases for patch testing, DR validation, schema testing, or migration.
|
|
84
|
+
- **Automated restore workflows**
|
|
85
|
+
- CI/CD pipelines or internal automation may restore DBs to generate staging or dev environments.
|
|
86
|
+
- **Third-party tooling**
|
|
87
|
+
- Backup/DR solutions, migration tools, or observability platforms may restore DB instances for operational reasons. Tune based on `user_agent.original` or known service roles.
|
|
88
|
+
|
|
89
|
+
### Response and remediation
|
|
90
|
+
|
|
91
|
+
- **Contain the restored environment**
|
|
92
|
+
- If unauthorized:
|
|
93
|
+
- Apply restrictive security groups to block access.
|
|
94
|
+
- Disable public accessibility if enabled.
|
|
95
|
+
- Evaluate whether deletion protection or backup retention is misconfigured.
|
|
96
|
+
|
|
97
|
+
- **Assess data exposure and intent**
|
|
98
|
+
- Work with data owners to evaluate:
|
|
99
|
+
- The sensitivity of the restored environment.
|
|
100
|
+
- Whether any reads, dumps, or exports occurred post-restore.
|
|
101
|
+
- Whether the restore enabled the attacker to access older or deleted data.
|
|
102
|
+
|
|
103
|
+
- **Investigate scope and related activity**
|
|
104
|
+
- Review CloudTrail for:
|
|
105
|
+
- Additional restores, exports, or copies.
|
|
106
|
+
- IAM changes allowing expanded privileges.
|
|
107
|
+
- Unusual authentication events or federated sessions without MFA.
|
|
108
|
+
- Related destructive actions (snapshot deletion, backup disabled, instance deletion).
|
|
109
|
+
|
|
110
|
+
- **Hardening and preventive controls**
|
|
111
|
+
- Enforce least privilege for `rds:RestoreDBInstanceFromDBSnapshot` and `rds:RestoreDBInstanceFromS3`.
|
|
112
|
+
- Use IAM conditions to restrict restore actions by network, principal, or region.
|
|
113
|
+
- Add AWS Config and Security Hub controls for monitoring:
|
|
114
|
+
- Unapproved restores.
|
|
115
|
+
- Public or misconfigured restored instances.
|
|
116
|
+
- Consider SCPs that prevent RDS restores in production accounts except through controlled roles.
|
|
117
|
+
|
|
118
|
+
- **Post-incident improvements**
|
|
119
|
+
- Rotate credentials for affected IAM users/roles.
|
|
120
|
+
- Update change management processes to ensure restore actions are tracked and approved.
|
|
121
|
+
- Adjust rule exceptions sparingly and ensure high-risk restores continue to generate alerts.
|
|
122
|
+
|
|
123
|
+
### Additional information
|
|
124
|
+
|
|
125
|
+
- **[AWS IR Playbooks](https://github.com/aws-samples/aws-incident-response-playbooks/blob/c151b0dc091755fffd4d662a8f29e2f6794da52c/playbooks/)**
|
|
126
|
+
- **[AWS Customer Playbook Framework](https://github.com/aws-samples/aws-customer-playbook-framework/tree/a8c7b313636b406a375952ac00b2d68e89a991f2/docs)**
|
|
127
|
+
- **Security Best Practices:** [AWS Knowledge Center – Security Best Practices](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/).
|
|
128
|
+
"""
|
|
23
129
|
references = [
|
|
24
130
|
"https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBInstanceFromDBSnapshot.html",
|
|
25
131
|
"https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBInstanceFromS3.html",
|
|
@@ -39,49 +145,15 @@ tags = [
|
|
|
39
145
|
"Resources: Investigation Guide",
|
|
40
146
|
]
|
|
41
147
|
timestamp_override = "event.ingested"
|
|
42
|
-
type = "
|
|
148
|
+
type = "query"
|
|
43
149
|
|
|
44
150
|
query = '''
|
|
45
|
-
|
|
46
|
-
and event.provider
|
|
47
|
-
and event.action
|
|
48
|
-
and event.outcome
|
|
151
|
+
event.dataset: "aws.cloudtrail"
|
|
152
|
+
and event.provider: "rds.amazonaws.com"
|
|
153
|
+
and event.action: ("RestoreDBInstanceFromDBSnapshot" or "RestoreDBInstanceFromS3")
|
|
154
|
+
and event.outcome: "success"
|
|
49
155
|
'''
|
|
50
|
-
note = """## Triage and analysis
|
|
51
|
-
|
|
52
|
-
> **Disclaimer**:
|
|
53
|
-
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
|
|
54
|
-
|
|
55
|
-
### Investigating AWS RDS DB Instance Restored
|
|
56
|
-
|
|
57
|
-
Amazon RDS (Relational Database Service) allows users to set up, operate, and scale databases in the cloud. Adversaries may exploit RDS by restoring DB instances from snapshots or S3 to access sensitive data or bypass security controls. The detection rule identifies successful restoration attempts, signaling potential unauthorized access or data exfiltration activities, by monitoring specific API operations and outcomes.
|
|
58
|
-
|
|
59
|
-
### Possible investigation steps
|
|
60
156
|
|
|
61
|
-
- Review the CloudTrail logs to identify the user or role associated with the successful `RestoreDBInstanceFromDBSnapshot` or `RestoreDBInstanceFromS3` API call by examining the `user.identity` field.
|
|
62
|
-
- Check the source IP address and location from which the API call was made using the `sourceIPAddress` field to determine if it aligns with expected or known locations.
|
|
63
|
-
- Investigate the timing of the restoration event by looking at the `@timestamp` field to see if it coincides with any other suspicious activities or anomalies in the environment.
|
|
64
|
-
- Examine the specific DB instance details restored, such as the DB instance identifier, to assess the sensitivity of the data involved and potential impact.
|
|
65
|
-
- Verify if there are any associated alerts or logs indicating unauthorized access or data exfiltration attempts around the same time frame.
|
|
66
|
-
- Contact the user or team responsible for the credentials used, if legitimate, to confirm whether the restoration was authorized and intended.
|
|
67
|
-
|
|
68
|
-
### False positive analysis
|
|
69
|
-
|
|
70
|
-
- Routine database maintenance or testing activities may trigger the rule. Organizations should identify and document regular restoration activities performed by authorized personnel and exclude these from alerts.
|
|
71
|
-
- Automated backup and restore processes used for disaster recovery or data migration can result in false positives. Users should configure exceptions for known automated processes by filtering based on specific user accounts or roles.
|
|
72
|
-
- Development and staging environments often involve frequent restoration of databases for testing purposes. Exclude these environments by identifying and filtering out specific instance identifiers or tags associated with non-production environments.
|
|
73
|
-
- Scheduled tasks or scripts that restore databases as part of regular operations can be mistaken for unauthorized activity. Ensure these tasks are well-documented and create exceptions based on the source IP or IAM role used for these operations.
|
|
74
|
-
- Third-party services or integrations that require database restoration for functionality may trigger alerts. Verify these services and exclude their associated actions by identifying their unique user agents or API keys.
|
|
75
|
-
|
|
76
|
-
### Response and remediation
|
|
77
|
-
|
|
78
|
-
- Immediately isolate the restored RDS instance to prevent unauthorized access. This can be done by modifying the security group rules to restrict inbound and outbound traffic.
|
|
79
|
-
- Conduct a thorough review of CloudTrail logs to identify the source of the compromised credentials and any other suspicious activities associated with the same user or account.
|
|
80
|
-
- Revoke the compromised credentials and issue new credentials for the affected user or service account. Ensure that multi-factor authentication (MFA) is enabled for all accounts.
|
|
81
|
-
- Notify the security team and relevant stakeholders about the incident, providing details of the unauthorized restoration and any potential data exposure.
|
|
82
|
-
- Perform a security assessment of the restored RDS instance to identify any unauthorized changes or data exfiltration. This includes checking for unusual queries or data exports.
|
|
83
|
-
- Implement additional monitoring and alerting for similar API operations to detect future unauthorized restoration attempts promptly.
|
|
84
|
-
- Review and update IAM policies to ensure that only authorized users have the necessary permissions to restore RDS instances, reducing the risk of future incidents."""
|
|
85
157
|
|
|
86
158
|
[[rule.threat]]
|
|
87
159
|
framework = "MITRE ATT&CK"
|
|
@@ -93,14 +165,34 @@ reference = "https://attack.mitre.org/techniques/T1578/"
|
|
|
93
165
|
id = "T1578.002"
|
|
94
166
|
name = "Create Cloud Instance"
|
|
95
167
|
reference = "https://attack.mitre.org/techniques/T1578/002/"
|
|
168
|
+
|
|
96
169
|
[[rule.threat.technique.subtechnique]]
|
|
97
170
|
id = "T1578.004"
|
|
98
171
|
name = "Revert Cloud Instance"
|
|
99
172
|
reference = "https://attack.mitre.org/techniques/T1578/004/"
|
|
100
173
|
|
|
101
174
|
|
|
175
|
+
|
|
102
176
|
[rule.threat.tactic]
|
|
103
177
|
id = "TA0005"
|
|
104
178
|
name = "Defense Evasion"
|
|
105
179
|
reference = "https://attack.mitre.org/tactics/TA0005/"
|
|
106
180
|
|
|
181
|
+
[rule.investigation_fields]
|
|
182
|
+
field_names = [
|
|
183
|
+
"@timestamp",
|
|
184
|
+
"user.name",
|
|
185
|
+
"user_agent.original",
|
|
186
|
+
"source.ip",
|
|
187
|
+
"aws.cloudtrail.user_identity.arn",
|
|
188
|
+
"aws.cloudtrail.user_identity.type",
|
|
189
|
+
"aws.cloudtrail.user_identity.access_key_id",
|
|
190
|
+
"target.entity.id",
|
|
191
|
+
"event.action",
|
|
192
|
+
"event.outcome",
|
|
193
|
+
"cloud.account.id",
|
|
194
|
+
"cloud.region",
|
|
195
|
+
"aws.cloudtrail.request_parameters",
|
|
196
|
+
"aws.cloudtrail.response_elements",
|
|
197
|
+
]
|
|
198
|
+
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
creation_date = "2020/07/16"
|
|
3
|
+
integration = ["aws"]
|
|
4
|
+
maturity = "production"
|
|
5
|
+
updated_date = "2025/11/25"
|
|
6
|
+
|
|
7
|
+
[rule]
|
|
8
|
+
author = ["Elastic"]
|
|
9
|
+
description = """
|
|
10
|
+
Detects repeated failed attempts to update an IAM role’s trust policy in an AWS account, consistent with role and user
|
|
11
|
+
enumeration techniques. In this technique, an attacker who controls credentials in the current account repeatedly calls
|
|
12
|
+
UpdateAssumeRolePolicy on a single role, cycling through guessed cross-account role or user ARNs as the principal. When
|
|
13
|
+
those principals are invalid, IAM returns MalformedPolicyDocumentException, producing a burst of failed
|
|
14
|
+
UpdateAssumeRolePolicy events. This rule alerts on that brute-force pattern originating from this account, which may
|
|
15
|
+
indicate that the account is being used as attack infrastructure or that offensive tooling (such as Pacu) is running
|
|
16
|
+
here. Note: this rule does not detect other accounts enumerating roles, because those API calls are logged in the
|
|
17
|
+
caller’s account, not the target account.
|
|
18
|
+
"""
|
|
19
|
+
from = "now-6m"
|
|
20
|
+
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
|
|
21
|
+
language = "kuery"
|
|
22
|
+
license = "Elastic License v2"
|
|
23
|
+
name = "AWS IAM Principal Enumeration via UpdateAssumeRolePolicy"
|
|
24
|
+
note = """## Triage and analysis
|
|
25
|
+
|
|
26
|
+
> **Disclaimer**:
|
|
27
|
+
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
|
|
28
|
+
|
|
29
|
+
### Investigating AWS IAM Principal Enumeration via UpdateAssumeRolePolicy
|
|
30
|
+
|
|
31
|
+
This rule detects bursts of failed attempts to update an IAM role’s trust policy — typically resulting in `MalformedPolicyDocumentException` errors — which can indicate enumeration of IAM principals.
|
|
32
|
+
Adversaries who have obtained valid AWS credentials may attempt to identify roles or accounts that can be assumed by repeatedly modifying a role’s trust relationship using guessed `Principal` ARNs.
|
|
33
|
+
When these principals are invalid, IAM rejects the request, creating a recognizable sequence of failed `UpdateAssumeRolePolicy` events.
|
|
34
|
+
|
|
35
|
+
Because this is a threshold rule, it triggers when the number of failures exceeds a defined count within a short period. This pattern suggests brute-force-style enumeration rather than normal misconfiguration.
|
|
36
|
+
|
|
37
|
+
#### Possible investigation steps
|
|
38
|
+
|
|
39
|
+
- **Validate the context of the threshold trigger**
|
|
40
|
+
- Review the `@timestamp` range for when the burst occurred and the number of failed attempts in the threshold window.
|
|
41
|
+
- Identify whether all failures targeted the same `RoleName` or multiple roles — targeting a single role is often indicative of brute-force enumeration.
|
|
42
|
+
- Confirm the source identity and IP address (`aws.cloudtrail.user_identity.arn`, `source.ip`, `user_agent.original`) to determine whether these calls originated from a known automation process or an unexpected host.
|
|
43
|
+
|
|
44
|
+
- **Correlate with other IAM activity**
|
|
45
|
+
- Look for any subsequent successful `UpdateAssumeRolePolicy` or `AssumeRole` calls, which may indicate the attacker eventually discovered a valid principal.
|
|
46
|
+
- Search for reconnaissance-related API calls (`ListRoles`, `ListUsers`, `GetCallerIdentity`) before the threshold event — these often precede enumeration bursts.
|
|
47
|
+
- Investigate whether other suspicious role- or identity-related actions occurred near the same timeframe, such as `CreateRole`, `PutRolePolicy`, or `AttachRolePolicy`.
|
|
48
|
+
|
|
49
|
+
- **Identify infrastructure patterns**
|
|
50
|
+
- Examine the `user_agent.original` field — the presence of automation frameworks or penetration tools (e.g., “Boto3”, “Pacu”) may signal offensive tooling.
|
|
51
|
+
- Review the `source.ip` or `cloud.account.id` fields to see whether this account may be acting as attacker-controlled infrastructure attempting to enumerate roles in other environments.
|
|
52
|
+
|
|
53
|
+
- **Validate authorization**
|
|
54
|
+
- Confirm with your DevOps or Cloud IAM teams whether any expected testing, migration, or cross-account role configuration changes were planned for this time period.
|
|
55
|
+
- If the identity performing these actions does not typically manage IAM roles or trust relationships, escalate for investigation as a possible credential compromise.
|
|
56
|
+
|
|
57
|
+
### False positive analysis
|
|
58
|
+
|
|
59
|
+
- **Legitimate automation retries**
|
|
60
|
+
- Continuous integration or configuration management systems may retry failed IAM API calls during deployment rollouts.
|
|
61
|
+
If the same IAM role was being updated as part of a known change, validate the timing and source identity before closing as benign.
|
|
62
|
+
- **Misconfigured scripts or infrastructure drift**
|
|
63
|
+
- Scripts that deploy trust policies using outdated or invalid ARNs can cause repetitive failures that mimic brute-force patterns.
|
|
64
|
+
Review the `RoleName` and `Principal` ARNs included in the failed requests to confirm if they correspond to known but outdated configurations.
|
|
65
|
+
|
|
66
|
+
### Response and remediation
|
|
67
|
+
|
|
68
|
+
- **Immediate review and containment**
|
|
69
|
+
- Investigate whether the source account is being used for offensive operations or compromised automation.
|
|
70
|
+
- Disable or suspend the IAM user or access key responsible for the enumeration burst.
|
|
71
|
+
- If activity originated from a workload or CI/CD system, audit its access keys and environment variables for compromise.
|
|
72
|
+
|
|
73
|
+
- **Investigation and scoping**
|
|
74
|
+
- Review CloudTrail logs for other IAM or STS actions from the same source in the preceding and following 24 hours.
|
|
75
|
+
- Check for any successful privilege changes (`PutRolePolicy`, `AttachRolePolicy`, or `AssumeRole`) by the same identity.
|
|
76
|
+
- Determine if other roles in the same account experienced similar failed updates or bursts.
|
|
77
|
+
|
|
78
|
+
- **Recovery and hardening**
|
|
79
|
+
- Rotate credentials for any identities involved.
|
|
80
|
+
- Limit permissions to modify trust policies (`iam:UpdateAssumeRolePolicy`) to a small set of administrative roles.
|
|
81
|
+
- Enable AWS Config rule `iam-role-trust-policy-check` to detect overly permissive or unusual trust relationships.
|
|
82
|
+
- Use AWS GuardDuty or Security Hub to monitor for subsequent privilege escalation or reconnaissance findings.
|
|
83
|
+
- Review the event against AWS Incident Response Playbook guidance (containment > investigation > recovery > hardening).
|
|
84
|
+
|
|
85
|
+
### Additional information
|
|
86
|
+
- **[AWS IR Playbooks](https://github.com/aws-samples/aws-incident-response-playbooks/blob/c151b0dc091755fffd4d662a8f29e2f6794da52c/playbooks/)**
|
|
87
|
+
- **[AWS Customer Playbook Framework](https://github.com/aws-samples/aws-customer-playbook-framework/tree/a8c7b313636b406a375952ac00b2d68e89a991f2/docs)**
|
|
88
|
+
- **Security Best Practices:** [AWS Knowledge Center – Security Best Practices](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/)
|
|
89
|
+
"""
|
|
90
|
+
references = [
|
|
91
|
+
"https://www.praetorian.com/blog/aws-iam-assume-role-vulnerabilities",
|
|
92
|
+
"https://rhinosecuritylabs.com/aws/assume-worst-aws-assume-role-enumeration/",
|
|
93
|
+
]
|
|
94
|
+
risk_score = 47
|
|
95
|
+
rule_id = "ea248a02-bc47-4043-8e94-2885b19b2636"
|
|
96
|
+
severity = "medium"
|
|
97
|
+
tags = [
|
|
98
|
+
"Domain: Cloud",
|
|
99
|
+
"Data Source: AWS",
|
|
100
|
+
"Data Source: Amazon Web Services",
|
|
101
|
+
"Data Source: AWS IAM",
|
|
102
|
+
"Use Case: Identity and Access Audit",
|
|
103
|
+
"Resources: Investigation Guide",
|
|
104
|
+
"Tactic: Discovery",
|
|
105
|
+
"Tactic: Credential Access",
|
|
106
|
+
]
|
|
107
|
+
timestamp_override = "event.ingested"
|
|
108
|
+
type = "threshold"
|
|
109
|
+
|
|
110
|
+
query = '''
|
|
111
|
+
event.dataset: "aws.cloudtrail"
|
|
112
|
+
and event.provider: "iam.amazonaws.com"
|
|
113
|
+
and event.action: "UpdateAssumeRolePolicy"
|
|
114
|
+
and aws.cloudtrail.error_code: "MalformedPolicyDocumentException"
|
|
115
|
+
and event.outcome: "failure"
|
|
116
|
+
'''
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
[[rule.threat]]
|
|
120
|
+
framework = "MITRE ATT&CK"
|
|
121
|
+
[[rule.threat.technique]]
|
|
122
|
+
id = "T1087"
|
|
123
|
+
name = "Account Discovery"
|
|
124
|
+
reference = "https://attack.mitre.org/techniques/T1087/"
|
|
125
|
+
[[rule.threat.technique.subtechnique]]
|
|
126
|
+
id = "T1087.004"
|
|
127
|
+
name = "Cloud Account"
|
|
128
|
+
reference = "https://attack.mitre.org/techniques/T1087/004/"
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
[rule.threat.tactic]
|
|
133
|
+
id = "TA0007"
|
|
134
|
+
name = "Discovery"
|
|
135
|
+
reference = "https://attack.mitre.org/tactics/TA0007/"
|
|
136
|
+
[[rule.threat]]
|
|
137
|
+
framework = "MITRE ATT&CK"
|
|
138
|
+
[[rule.threat.technique]]
|
|
139
|
+
id = "T1110"
|
|
140
|
+
name = "Brute Force"
|
|
141
|
+
reference = "https://attack.mitre.org/techniques/T1110/"
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
[rule.threat.tactic]
|
|
145
|
+
id = "TA0006"
|
|
146
|
+
name = "Credential Access"
|
|
147
|
+
reference = "https://attack.mitre.org/tactics/TA0006/"
|
|
148
|
+
|
|
149
|
+
[rule.threshold]
|
|
150
|
+
field = ["cloud.account.id", "user.name", "source.ip"]
|
|
151
|
+
value = 25
|
|
152
|
+
|
nldcsc_elastic_rules/rules/integrations/aws/discovery_multiple_discovery_api_calls_via_cli.toml
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
creation_date = "2024/11/04"
|
|
3
|
+
integration = ["aws"]
|
|
4
|
+
maturity = "production"
|
|
5
|
+
updated_date = "2025/12/04"
|
|
6
|
+
|
|
7
|
+
[rule]
|
|
8
|
+
author = ["Elastic"]
|
|
9
|
+
description = """
|
|
10
|
+
Detects when a single AWS resource is running multiple read-only, discovery API calls in a 10-second window. This
|
|
11
|
+
behavior could indicate an actor attempting to discover the AWS infrastructure using compromised credentials or a
|
|
12
|
+
compromised instance. Adversaries may use this information to identify potential targets for further exploitation or to
|
|
13
|
+
gain a better understanding of the target's infrastructure.
|
|
14
|
+
"""
|
|
15
|
+
false_positives = [
|
|
16
|
+
"""
|
|
17
|
+
Administrators or automated systems may legitimately perform multiple `Describe`, `List`, `Get` and `Generate` API calls in a short
|
|
18
|
+
time frame. Verify the user identity and the purpose of the API calls to determine if the behavior is expected.
|
|
19
|
+
""",
|
|
20
|
+
]
|
|
21
|
+
from = "now-6m"
|
|
22
|
+
language = "esql"
|
|
23
|
+
license = "Elastic License v2"
|
|
24
|
+
name = "AWS Discovery API Calls via CLI from a Single Resource"
|
|
25
|
+
note = """## Triage and analysis
|
|
26
|
+
|
|
27
|
+
> **Disclaimer**:
|
|
28
|
+
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
|
|
29
|
+
|
|
30
|
+
### Investigating AWS Discovery API Calls via CLI from a Single Resource
|
|
31
|
+
|
|
32
|
+
This rule detects when a single AWS identity executes more than five unique discovery-related API calls (`Describe*`, `List*`, `Get*`, or `Generate*`) within a 10-second window using the AWS CLI.
|
|
33
|
+
High volumes of diverse “read-only” API calls in such a short period can indicate scripted reconnaissance, often an early phase of compromise after credential exposure or access to a compromised EC2 instance.
|
|
34
|
+
|
|
35
|
+
#### Possible Investigation Steps
|
|
36
|
+
|
|
37
|
+
**Identify the actor and session context**
|
|
38
|
+
- **Actor ARN (`aws.cloudtrail.user_identity.arn`)**: Determine which IAM user, role, or service principal performed the actions.
|
|
39
|
+
- Check whether this identity normally performs enumeration activity or belongs to automation infrastructure.
|
|
40
|
+
- **Identity type (`Esql.aws_cloudtrail_user_identity_arn_type`)**: Validate if the caller is a human IAM user, assumed role, or federated identity. Unusual types (e.g., temporary credentials from an unfamiliar role) may indicate lateral movement.
|
|
41
|
+
- **Access key (`Esql.aws_cloudtrail_user_identity_access_key_id_values`)** – Identify which specific access key or temporary credential was used.
|
|
42
|
+
- If multiple suspicious keys are found, use AWS IAM console or `aws iam list-access-keys` to determine when they were last used or rotated.
|
|
43
|
+
- **Account (`Esql.cloud_account_id_values`)** – Confirm which AWS account was affected and whether it matches the intended operational context (e.g., production vs. sandbox).
|
|
44
|
+
|
|
45
|
+
**Assess the API call pattern and intent**
|
|
46
|
+
- **Distinct action count (`Esql.event_action_count_distinct`)**: Note how many unique API calls occurred within each 10-second window. Counts far above normal operational baselines may indicate scripted reconnaissance.
|
|
47
|
+
- **API actions (`Esql.event_action_values`)**: Review which discovery APIs were invoked.
|
|
48
|
+
- Focus on services such as EC2 (`DescribeInstances`), IAM (`ListRoles`, `ListAccessKeys`), S3 (`ListBuckets`), and KMS (`ListKeys`), which adversaries frequently query to map assets.
|
|
49
|
+
- **Service providers (`Esql.event_provider_values`)**: Identify which AWS services were targeted.
|
|
50
|
+
- Multi-service enumeration (IAM + EC2 + S3) suggests broad discovery rather than a specific diagnostic task.
|
|
51
|
+
- **Time window (`Esql.time_window_date_trunc`)**: Verify whether activity occurred during normal maintenance windows or outside expected hours.
|
|
52
|
+
|
|
53
|
+
**Analyze the source and origin**
|
|
54
|
+
- **Source IP (`Esql.source_ip_values`)**: Check the originating IPs to determine whether the calls came from a known internal host, an EC2 instance, or an unfamiliar external network.
|
|
55
|
+
- Compare with known corporate CIDR ranges, VPC flow logs, or guardrail baselines.
|
|
56
|
+
- **Source organization (`Esql.source_as_organization_name_values`)**: Review the associated ASN or organization.
|
|
57
|
+
- If the ASN belongs to a commercial ISP or VPN service, investigate possible credential compromise or remote attacker usage.
|
|
58
|
+
|
|
59
|
+
**Correlate with additional events**
|
|
60
|
+
- Search CloudTrail for the same `aws.cloudtrail.user_identity.arn` or `aws_cloudtrail_user_identity_access_key_id_values` within ±30 minutes.
|
|
61
|
+
- Look for follow-on actions such as `GetCallerIdentity`, `AssumeRole`, `CreateAccessKey`, or data access (`GetObject`, `CopySnapshot`).
|
|
62
|
+
- Correlate this enumeration with authentication anomalies or privilege-related findings.
|
|
63
|
+
- Cross-reference `Esql.cloud_account_id_values` with other alerts for lateral or privilege escalation patterns.
|
|
64
|
+
|
|
65
|
+
### False positive analysis
|
|
66
|
+
|
|
67
|
+
Legitimate, high-frequency API activity may originate from:
|
|
68
|
+
- **Inventory or compliance automation**: Scripts or tools such as AWS Config, Cloud Custodian, or custom CMDB collection performing periodic Describe/List calls.
|
|
69
|
+
- **Operational monitoring systems**: DevOps pipelines, Terraform, or deployment verifiers enumerating resources.
|
|
70
|
+
- **Security tooling**: Security scanners performing asset discovery across services.
|
|
71
|
+
|
|
72
|
+
Validate by confirming:
|
|
73
|
+
- Whether the `aws.cloudtrail.user_identity.arn` corresponds to a documented automation or monitoring identity.
|
|
74
|
+
- That the observed `Esql.event_action_values` match known inventory or cost-reporting workflows.
|
|
75
|
+
- Timing alignment with approved maintenance schedules.
|
|
76
|
+
|
|
77
|
+
### Response and remediation
|
|
78
|
+
|
|
79
|
+
If the activity is unexpected or originates from unrecognized credentials, follow AWS’s incident-handling guidance:
|
|
80
|
+
|
|
81
|
+
**1. Contain**
|
|
82
|
+
- Temporarily disable or rotate the access key (`Esql.aws_cloudtrail_user_identity_access_key_id_values`) using IAM.
|
|
83
|
+
- Restrict outbound connectivity for the instance or resource from which the API calls originated.
|
|
84
|
+
|
|
85
|
+
**2. Investigate**
|
|
86
|
+
- Retrieve full CloudTrail logs for the actor and `Esql.time_window_date_trunc` interval.
|
|
87
|
+
- Identify any subsequent write or privilege-modification actions.
|
|
88
|
+
- Review associated IAM policies for excessive permissions.
|
|
89
|
+
|
|
90
|
+
**3. Recover and Harden**
|
|
91
|
+
- Rotate credentials, enforce MFA on human users, and tighten IAM role trust policies.
|
|
92
|
+
- Implement AWS Config rules or SCPs to monitor and restrict large-scale enumeration.
|
|
93
|
+
|
|
94
|
+
**4. Post-Incident Actions**
|
|
95
|
+
- Document the finding and response in your organization’s IR management system.
|
|
96
|
+
- Update detection logic or allow-lists for known benign automation.
|
|
97
|
+
- Validate recovery by confirming no new suspicious discovery bursts occur.
|
|
98
|
+
|
|
99
|
+
### Additional information
|
|
100
|
+
|
|
101
|
+
- **AWS Documentation**
|
|
102
|
+
- [CloudTrail Event Reference](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference.html)
|
|
103
|
+
- [AWS Security Incident Response Guide](https://docs.aws.amazon.com/whitepapers/latest/aws-security-incident-response-guide/aws-security-incident-response-guide.pdf)
|
|
104
|
+
- **AWS Playbook Resources**
|
|
105
|
+
- [AWS Incident Response Playbooks](https://github.com/aws-samples/aws-incident-response-playbooks/tree/c151b0dc091755fffd4d662a8f29e2f6794da52c/playbooks)
|
|
106
|
+
- [AWS Customer Playbook Framework](https://github.com/aws-samples/aws-customer-playbook-framework)
|
|
107
|
+
|
|
108
|
+
"""
|
|
109
|
+
references = ["https://stratus-red-team.cloud/attack-techniques/AWS/aws.discovery.ec2-enumerate-from-instance/"]
|
|
110
|
+
risk_score = 21
|
|
111
|
+
rule_id = "74f45152-9aee-11ef-b0a5-f661ea17fbcd"
|
|
112
|
+
severity = "low"
|
|
113
|
+
tags = [
|
|
114
|
+
"Domain: Cloud",
|
|
115
|
+
"Data Source: AWS",
|
|
116
|
+
"Data Source: AWS EC2",
|
|
117
|
+
"Data Source: AWS IAM",
|
|
118
|
+
"Data Source: AWS S3",
|
|
119
|
+
"Data Source: AWS Cloudtrail",
|
|
120
|
+
"Data Source: AWS RDS",
|
|
121
|
+
"Data Source: AWS Lambda",
|
|
122
|
+
"Data Source: AWS STS",
|
|
123
|
+
"Data Source: AWS KMS",
|
|
124
|
+
"Data Source: AWS SES",
|
|
125
|
+
"Data Source: AWS Cloudfront",
|
|
126
|
+
"Data Source: AWS DynamoDB",
|
|
127
|
+
"Data Source: AWS Elastic Load Balancing",
|
|
128
|
+
"Use Case: Threat Detection",
|
|
129
|
+
"Tactic: Discovery",
|
|
130
|
+
"Resources: Investigation Guide",
|
|
131
|
+
]
|
|
132
|
+
timestamp_override = "event.ingested"
|
|
133
|
+
type = "esql"
|
|
134
|
+
|
|
135
|
+
query = '''
|
|
136
|
+
from logs-aws.cloudtrail-* metadata _id, _version, _index
|
|
137
|
+
// create time window buckets of 10 seconds
|
|
138
|
+
| eval Esql.time_window_date_trunc = date_trunc(10 seconds, @timestamp)
|
|
139
|
+
|
|
140
|
+
| where
|
|
141
|
+
event.dataset == "aws.cloudtrail"
|
|
142
|
+
// filter on CloudTrail audit logs for IAM, EC2, S3, etc.
|
|
143
|
+
and event.provider in (
|
|
144
|
+
"iam.amazonaws.com",
|
|
145
|
+
"ec2.amazonaws.com",
|
|
146
|
+
"s3.amazonaws.com",
|
|
147
|
+
"rds.amazonaws.com",
|
|
148
|
+
"lambda.amazonaws.com",
|
|
149
|
+
"dynamodb.amazonaws.com",
|
|
150
|
+
"kms.amazonaws.com",
|
|
151
|
+
"cloudfront.amazonaws.com",
|
|
152
|
+
"elasticloadbalancing.amazonaws.com",
|
|
153
|
+
"cloudtrail.amazonaws.com",
|
|
154
|
+
"sts.amazonaws.com",
|
|
155
|
+
"ses.amazonaws.com"
|
|
156
|
+
)
|
|
157
|
+
// ignore AWS service actions
|
|
158
|
+
and aws.cloudtrail.user_identity.type != "AWSService"
|
|
159
|
+
// filter for aws-cli specifically
|
|
160
|
+
and user_agent.name == "aws-cli"
|
|
161
|
+
// exclude DescribeCapacityReservations events related to AWS Config
|
|
162
|
+
and event.action != "DescribeCapacityReservations"
|
|
163
|
+
|
|
164
|
+
// filter for Describe, Get, List, and Generate API calls
|
|
165
|
+
| where true in (
|
|
166
|
+
starts_with(event.action, "Describe"),
|
|
167
|
+
starts_with(event.action, "Get"),
|
|
168
|
+
starts_with(event.action, "List"),
|
|
169
|
+
starts_with(event.action, "Generate")
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
// extract owner, identity type, and actor from the ARN
|
|
173
|
+
| dissect aws.cloudtrail.user_identity.arn "%{}::%{Esql_priv.aws_cloudtrail_user_identity_arn_owner}:%{Esql.aws_cloudtrail_user_identity_arn_type}/%{Esql.aws_cloudtrail_user_identity_arn_roles}"
|
|
174
|
+
|
|
175
|
+
| where starts_with(Esql.aws_cloudtrail_user_identity_arn_roles, "AWSServiceRoleForConfig") != true
|
|
176
|
+
|
|
177
|
+
// keep relevant fields (preserving ECS fields and computed time window)
|
|
178
|
+
| keep
|
|
179
|
+
@timestamp,
|
|
180
|
+
Esql.time_window_date_trunc,
|
|
181
|
+
event.action,
|
|
182
|
+
aws.cloudtrail.user_identity.arn,
|
|
183
|
+
aws.cloudtrail.user_identity.type,
|
|
184
|
+
aws.cloudtrail.user_identity.access_key_id,
|
|
185
|
+
source.ip,
|
|
186
|
+
cloud.account.id,
|
|
187
|
+
event.provider,
|
|
188
|
+
user_agent.name,
|
|
189
|
+
source.as.organization.name,
|
|
190
|
+
cloud.region,
|
|
191
|
+
data_stream.namespace
|
|
192
|
+
|
|
193
|
+
// count the number of unique API calls per time window and actor
|
|
194
|
+
| stats
|
|
195
|
+
Esql.event_action_count_distinct = count_distinct(event.action),
|
|
196
|
+
Esql.event_action_values = VALUES(event.action),
|
|
197
|
+
Esql.event_timestamp_values = VALUES(@timestamp),
|
|
198
|
+
Esql.aws_cloudtrail_user_identity_type_values = VALUES(aws.cloudtrail.user_identity.type),
|
|
199
|
+
Esql.aws_cloudtrail_user_identity_access_key_id_values = VALUES(aws.cloudtrail.user_identity.access_key_id),
|
|
200
|
+
Esql.source_ip_values = VALUES(source.ip),
|
|
201
|
+
Esql.cloud_account_id_values = VALUES(cloud.account.id),
|
|
202
|
+
Esql.event_provider_values = VALUES(event.provider),
|
|
203
|
+
Esql.user_agent_name_values = VALUES(user_agent.name),
|
|
204
|
+
Esql.source_as_organization_name_values = VALUES(source.as.organization.name),
|
|
205
|
+
Esql.cloud_region_values = VALUES(cloud.region),
|
|
206
|
+
Esql.data_stream_namespace_values = VALUES(data_stream.namespace)
|
|
207
|
+
by Esql.time_window_date_trunc, aws.cloudtrail.user_identity.arn
|
|
208
|
+
|
|
209
|
+
// filter for more than 5 unique API calls per 10s window
|
|
210
|
+
| where Esql.event_action_count_distinct > 5
|
|
211
|
+
'''
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
[[rule.threat]]
|
|
215
|
+
framework = "MITRE ATT&CK"
|
|
216
|
+
[[rule.threat.technique]]
|
|
217
|
+
id = "T1580"
|
|
218
|
+
name = "Cloud Infrastructure Discovery"
|
|
219
|
+
reference = "https://attack.mitre.org/techniques/T1580/"
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
[rule.threat.tactic]
|
|
223
|
+
id = "TA0007"
|
|
224
|
+
name = "Discovery"
|
|
225
|
+
reference = "https://attack.mitre.org/tactics/TA0007/"
|
|
226
|
+
|
|
227
|
+
[rule.investigation_fields]
|
|
228
|
+
field_names = [
|
|
229
|
+
"Esql.event_action_count_distinct",
|
|
230
|
+
"Esql.time_window_date_trunc",
|
|
231
|
+
"aws.cloudtrail.user_identity.arn",
|
|
232
|
+
"Esql.aws_cloudtrail_user_identity_type_values",
|
|
233
|
+
"Esql.aws_cloudtrail_user_identity_access_key_id_values",
|
|
234
|
+
"Esql.source_ip_values",
|
|
235
|
+
"Esql.source_as_organization_name_values",
|
|
236
|
+
"Esql.event_provider_values",
|
|
237
|
+
"Esql.event_action_values",
|
|
238
|
+
"Esql.cloud_account_id_values",
|
|
239
|
+
"Esql.cloud_region_values",
|
|
240
|
+
"Esql.data_stream_namespace_values"
|
|
241
|
+
]
|
|
242
|
+
|