Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,105 @@
creation_date = "2024/04/11"
integration = ["aws"]
maturity = "production"
updated_date = "2025/02/03"
updated_date = "2025/11/07"

[rule]
author = ["Elastic"]
description = """
This rule attempts to identify rapid secret retrieval attempts from AWS SecretsManager. Adversaries may attempt to
retrieve secrets from the Secrets Manager programmatically using the `GetSecretValue` or `BatchGetSecretValue` API
actions.
Identifies rapid secret retrieval activity from AWS Secrets Manager using the GetSecretValue or BatchGetSecretValue API
actions. Adversaries who compromise an IAM user, instance role, or temporary credentials may attempt to enumerate or
exfiltrate secrets in bulk to escalate privileges, move laterally, or gain persistence. This rule detects 20 or more
unique secret retrievals by the same user identity within a short time window, which may indicate credential compromise
or automated secret harvesting.
"""
false_positives = [
"""
Verify whether the user identity, user agent, and/or hostname should be using GetSecretString or BatchGetSecretValue
Verify whether the user identity, user agent, and/or hostname should be using GetSecretValue or BatchGetSecretValue
APIs for the specified SecretId. If known behavior is causing false positives, it can be exempted from the rule.
""",
]
from = "now-9m"
from = "now-6m"
index = ["filebeat-*", "logs-aws.cloudtrail*"]
language = "kuery"
license = "Elastic License v2"
name = "Rapid Secret Retrieval Attempts from AWS SecretsManager"
name = "AWS Secrets Manager Rapid Secrets Retrieval"
note = """## Triage and analysis

### Investigating Rapid Secret Retrieval Attempts from AWS SecretsManager
> **Disclaimer**:
> 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, validate and adapt it for your operational needs.

AWS Secrets Manager is a service that enables the replacement of hardcoded credentials in code, including passwords, with an API call to Secrets Manager to retrieve the secret programmatically.
### Investigating AWS Secrets Manager Rapid Secrets Retrieval

This rule looks for the rapid retrieval of credentials using `GetSecretValue` or `BatchGetSecretValue` actions in Secrets Manager programmatically. This is a [Threshold](https://www.elastic.co/guide/en/security/current/rules-ui-create.html#create-threshold-rule) rule indicating 20 or more successful attempts to retrieve a secret value from Secrets Manager by the same user identity within a short timespan.
AWS Secrets Manager stores sensitive credentials such as database passwords, API keys, OAuth tokens, and service
configuration values. In credential compromise scenarios, attackers frequently attempt to retrieve as many secrets as
possible in a short timeframe to escalate privileges or move laterally across the environment.

This threshold rule triggers when a single user identity successfully retrieves 20 or more unique secrets using
`GetSecretValue` or `BatchGetSecretValue` within a short timespan. Retrieval of many different secrets in rapid succession is highly unusual and strongly associated with reconnaissance, secret harvesting, or compromised automation.

Note: `BatchGetSecretValue` API calls the `GetSecretValue` API for each secret value; this alert only captures the `GetSecretValue` calls rather than the `BatchGetSecretValue` call itself.

#### Possible investigation steps

- Identify the account and its role in the environment, and inspect the related policy.
- Identify the applications that should use this account.
- Investigate other alerts associated with the user account during the past 48 hours.
- Investigate abnormal values in the `user_agent.original` field by comparing them with the intended and authorized usage and historical data. Suspicious user agent values include non-SDK, AWS CLI, custom user agents, etc.
- Assess whether this behavior is prevalent in the environment by looking for similar occurrences involving other users.
- Contact the account owner and confirm whether they are aware of this activity.
- Considering the source IP address and geolocation of the user who issued the command:
- Do they look normal for the calling user?
- If the source is an EC2 IP address, is it associated with an EC2 instance in one of your accounts or is the source IP from an EC2 instance that's not under your control?
- If it is an authorized EC2 instance, is the activity associated with normal behavior for the instance role or roles? Are there any other alerts or signs of suspicious activity involving this instance?
- Review IAM permission policies for the user identity and specific secrets accessed.
- Examine the request parameters. These might indicate the source of the program or the nature of its tasks.
- If you suspect the account has been compromised, scope potentially compromised assets by tracking servers, services, and data accessed by the account in the last 24 hours.
- **Identify the user or role**
- Review `aws.cloudtrail.user_identity.arn`, `user.name`, and `aws.cloudtrail.user_identity.type`.
- Determine whether the identity normally accesses Secrets Manager or is tied to a known automation workload.

- **Analyze the set of secrets retrieved**
- Expand the alert in Timeline and review `aws.cloudtrail.request_parameters` for all `SecretId` values in the grouped threshold event.
- Identify whether the accessed secrets include:
- Privileged database credentials
- IAM user or service account credentials
- Production application secrets
- Rarely accessed or high-sensitivity secrets

- **Assess the runtime context**
- Investigate `source.ip`, `source.geo.location`, and `user_agent.original`.
- Validate whether the calls originated from known internal automation (e.g., ECS task, Lambda runtime, EC2 instance profile)
or from an unexpected IP or user agent.

- **Correlate with other activity from the same identity**
- Look for related reconnaissance or credential-access events:
- `ListSecrets`, `DescribeSecret`
- IAM enumeration (`ListUsers`, `GetCallerIdentity`)
- Role-chaining or unusual `AssumeRole` flows
- Check for subsequent use of exposed credentials (RDS login attempts, API activity, abnormal resource access).

- **Determine whether unusual automation or deployment activity is occurring**
- Confirm with application owners whether a new deployment, config reload, or migration might explain the multi-secret access.

### False positive analysis

- False positives may occur due to the intended usage of the service. Tuning is needed in order to have higher confidence. Consider adding exceptions — preferably with a combination of user agent and IP address conditions.
- Legitimate application initialization or rollouts may retrieve many secrets once on startup.
- CI/CD pipelines or configuration management tools may enumerate secrets as part of environment bootstrapping.

To reduce noise, consider exceptions based on:
- Known service roles
- Expected source IP ranges
- Specific application identities tied to secret orchestration

### Response and remediation

- Initiate the incident response process based on the outcome of the triage.
- Disable or limit the account during the investigation and response.
- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
- Identify the account role in the cloud environment.
- Assess the criticality of affected services and servers.
- Work with your IT team to identify and minimize the impact on users.
- Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
- Identify any regulatory or legal ramifications related to this activity.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Rotate secrets or delete API keys as needed to revoke the attacker's access to the environment. Work with your IT teams to minimize the impact on business operations during these actions.
- Check if unauthorized new users were created, remove unauthorized new accounts, and request password resets for other IAM users.
- Consider enabling multi-factor authentication for users.
- Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
- Implement security best practices [outlined](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/) by AWS.
- Take the actions needed to return affected systems, data, or services to their normal operational levels.
- Identify the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
- **Containment**
- Immediately revoke or disable the IAM user, role session, or instance profile if compromise is suspected.
- Quarantine EC2/ECS/Lambda resources originating suspicious calls.

- **Investigation**
- Identify all secrets accessed in the grouped alert and determine where those credentials are used.
- Review CloudTrail for any suspicious follow-on activity using the retrieved secrets.
- Assess whether additional identities or workloads show similar enumeration behavior.

- **Recovery and hardening**
- Rotate all accessed secrets and update dependent systems.
- Rotate IAM access keys or temporary credentials for the impacted identity.
- Restrict permissions to Secrets Manager following least privilege.
- Review automation and application behavior to ensure secrets are accessed only when required.
"""
references = [
"https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html",
"https://detectioninthe.cloud/ttps/credential_access/access_secret_in_secrets_manager/",
"https://cloud.hacktricks.xyz/pentesting-cloud/aws-security/aws-services/aws-secrets-manager-enum",
"https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_BatchGetSecretValue.html",
]
risk_score = 47
rule_id = "185c782e-f86a-11ee-9d9f-f661ea17fbce"
Expand All @@ -90,9 +117,14 @@ timestamp_override = "event.ingested"
type = "threshold"

query = '''
event.dataset:aws.cloudtrail and event.provider:secretsmanager.amazonaws.com and
event.action: (GetSecretValue or BatchGetSecretValue) and event.outcome:success and
not user_agent.name: ("Chrome" or "Firefox" or "Safari" or "Edge" or "Brave" or "Opera")
event.dataset: "aws.cloudtrail"
and event.provider: "secretsmanager.amazonaws.com"
and event.action: "GetSecretValue"
and event.outcome: "success"
and not (
user_agent.name: ("Chrome" or "Firefox" or "Safari" or "Edge" or "Brave" or "Opera")
or source.address: ("kafka.amazonaws.com" or "apidestinations.events.amazonaws.com")
)
'''


Expand All @@ -116,5 +148,9 @@ reference = "https://attack.mitre.org/tactics/TA0006/"

[rule.threshold]
field = ["user.id"]
value = 1
[[rule.threshold.cardinality]]
field = "aws.cloudtrail.request_parameters"
value = 20


Loading