-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AWS: Dump secrets through Secret Manager's new BatchGetSecretValue (#434
- Loading branch information
1 parent
39e6b46
commit 790feb6
Showing
9 changed files
with
361 additions
and
41 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
...k-techniques/AWS/aws.credential-access.secretsmanager-batch-retrieve-secrets.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
title: Retrieve a High Number of Secrets Manager secrets (Batch) | ||
--- | ||
|
||
# Retrieve a High Number of Secrets Manager secrets (Batch) | ||
|
||
|
||
<span class="smallcaps w3-badge w3-blue w3-round w3-text-white" title="This attack technique can be detonated multiple times">idempotent</span> | ||
|
||
Platform: AWS | ||
|
||
## MITRE ATT&CK Tactics | ||
|
||
|
||
- Credential Access | ||
|
||
## Description | ||
|
||
|
||
Retrieves a high number of Secrets Manager secrets by batch, through <code>secretsmanager:BatchGetSecretValue</code> (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. | ||
|
||
|
||
<span style="font-variant: small-caps;">Warm-up</span>: | ||
|
||
- Create multiple secrets in Secrets Manager. | ||
|
||
<span style="font-variant: small-caps;">Detonation</span>: | ||
|
||
- Dump all secrets by batch of 10, using <code>secretsmanager:BatchGetSecretValue</code>. | ||
|
||
References: | ||
|
||
- https://aws.amazon.com/blogs/security/how-to-use-the-batchgetsecretsvalue-api-to-improve-your-client-side-applications-with-aws-secrets-manager/ | ||
|
||
|
||
## Instructions | ||
|
||
```bash title="Detonate with Stratus Red Team" | ||
stratus detonate aws.credential-access.secretsmanager-batch-retrieve-secrets | ||
``` | ||
## Detection | ||
|
||
|
||
Identify principals that attempt to retrieve secrets by batch, through CloudTrail's <code>BatchGetSecretValue</code> event. Sample event: | ||
|
||
```json | ||
{ | ||
"eventSource": "secretsmanager.amazonaws.com", | ||
"eventName": "BatchGetSecretValue", | ||
"requestParameters": { | ||
"filters": [ | ||
{ | ||
"key": "tag-key", | ||
"values": [ | ||
"StratusRedTeam" | ||
] | ||
} | ||
] | ||
}, | ||
"responseElements": null, | ||
"readOnly": true, | ||
"eventType": "AwsApiCall", | ||
"managementEvent": true, | ||
"recipientAccountId": "012345678901" | ||
} | ||
``` | ||
|
||
Although <code>BatchGetSecretValue</code> requires a list of secret IDs or a filter, an attacker may use a catch-all filter to retrieve all secrets by batch: | ||
|
||
```json hl_lines="6-11" | ||
{ | ||
"eventSource": "secretsmanager.amazonaws.com", | ||
"eventName": "BatchGetSecretValue", | ||
"requestParameters": { | ||
"filters": [ | ||
{ | ||
"key": "tag-key", | ||
"values": [ | ||
"!tagKeyThatWillNeverExist" | ||
] | ||
} | ||
] | ||
}, | ||
"responseElements": null, | ||
"readOnly": true, | ||
"eventType": "AwsApiCall", | ||
"managementEvent": true, | ||
"recipientAccountId": "012345678901" | ||
} | ||
``` | ||
|
||
The following may be use to tune the detection, or validate findings: | ||
|
||
- Principals who do not usually call GetBatchSecretValue | ||
- Attempts to call GetBatchSecretValue resulting in access denied errors | ||
- Principals calling GetBatchSecretValue in several regions in a short period of time | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.