AWS Secrets Manager Batch Retrieve Secrets


Description

An attacker attempted to retrieve a high number of Secrets Manager secrets by batch, through secretsmanager:BatchGetSecretValue (released Novemeber 2023). An attacker may attempt to retrieve a high number of secrets by batch, to avoid detection and generate fewer calls. Note that the batch size is limited to 20 secrets.

Query · python

from panther_aws_helpers import aws_rule_context


def rule(event):
    if event.get("eventName") == "BatchGetSecretValue":
        return True
    return False


def title(event):
    user = event.udm("actor_user")
    return (
        f"[{user}] attempted to batch retrieve a large number of secrets from AWS Secrets Manager"
    )


def alert_context(event):
    return aws_rule_context(event)

Analyst notes

https://aws.amazon.com/blogs/security/how-to-use-the-batchgetsecretsvalue-api-to-improve-your-client-side-applications-with-aws-secrets-manager/

Raw source AWS Secrets Manager Batch Retrieve Secrets · Panther Python
Esc
Published by panther-labs/panther-analysis ↗, licensed under Apache 2.0 ↗. Reproduced here unmodified.
AnalysisType: rule
Filename: aws_secretsmanager_retrieve_secrets_batch.py
RuleID: "AWS.SecretsManager.BatchRetrieveSecrets"
DisplayName: "AWS Secrets Manager Batch Retrieve Secrets"
Enabled: true
LogTypes:
  - AWS.CloudTrail
Tags:
  - AWS
  - Credential Access
  - Stratus Red Team
Status: Experimental
Reports:
  MITRE ATT&CK:
    - TA0006:T1552 # Credentials from Password Stores 
  Stratus Red Team:
    - aws.credential-access.secretsmanager-batch-retrieve-secrets
Severity: Info
Description: >
  An attacker attempted to retrieve a high number of Secrets Manager secrets by batch, through secretsmanager:BatchGetSecretValue (released Novemeber 2023). 
  An attacker may attempt to retrieve a high number of secrets by batch, to avoid detection and generate fewer calls. Note that the batch size is limited to 20 secrets.
Runbook: https://aws.amazon.com/blogs/security/how-to-use-the-batchgetsecretsvalue-api-to-improve-your-client-side-applications-with-aws-secrets-manager/
Reference: https://stratus-red-team.cloud/attack-techniques/AWS/aws.credential-access.secretsmanager-batch-retrieve-secrets/
Threshold: 5
DedupPeriodMinutes: 1440
SummaryAttributes:
  - eventName
  - userAgent
  - sourceIpAddress
  - recipientAccountId
  - p_any_aws_arns
Tests:
  - Name: BatchGetSecretValue
    ExpectedResult: true
    Log: {
      "eventSource": "secretsmanager.amazonaws.com",
      "eventName": "BatchGetSecretValue",
      "requestParameters": {
        "filters": [
          {
            "key": "tag-key",
            "values": [
              "StratusRedTeam"
            ]
          }
        ]
      },
      "responseElements": null,
      "readOnly": true,
      "eventType": "AwsApiCall",
      "managementEvent": true,
      "recipientAccountId": "012345678901"
    }

# ------ paired body: aws_secretsmanager_retrieve_secrets_batch.py ------

from panther_aws_helpers import aws_rule_context


def rule(event):
    if event.get("eventName") == "BatchGetSecretValue":
        return True
    return False


def title(event):
    user = event.udm("actor_user")
    return (
        f"[{user}] attempted to batch retrieve a large number of secrets from AWS Secrets Manager"
    )


def alert_context(event):
    return aws_rule_context(event)

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.