|
| 1 | +--- |
| 2 | +title: Generate temporary AWS credentials using GetFederationToken |
| 3 | +--- |
| 4 | + |
| 5 | +# Generate temporary AWS credentials using GetFederationToken |
| 6 | + |
| 7 | + |
| 8 | + <span class="smallcaps w3-badge w3-blue w3-round w3-text-white" title="This attack technique can be detonated multiple times">idempotent</span> |
| 9 | + |
| 10 | +Platform: AWS |
| 11 | + |
| 12 | +## MITRE ATT&CK Tactics |
| 13 | + |
| 14 | + |
| 15 | +- Persistence |
| 16 | + |
| 17 | +## Description |
| 18 | + |
| 19 | + |
| 20 | +Establishes persistence by generating new AWS temporary credentials through <code>sts:GetFederationToken</code>. The resulting credentials remain functional even if the original access keys are disabled. |
| 21 | + |
| 22 | +<span style="font-variant: small-caps;">Warm-up</span>: |
| 23 | + |
| 24 | +- Create an IAM user and generate a pair of access keys. |
| 25 | + |
| 26 | +<span style="font-variant: small-caps;">Detonation</span>: |
| 27 | + |
| 28 | +- Use the access keys from the IAM user to request temporary security credentials via <code>sts:GetFederationToken</code>. |
| 29 | +- Call <code>sts:GetCallerIdentity</code> using these new credentials. |
| 30 | + |
| 31 | +References: |
| 32 | + |
| 33 | +- https://docs.aws.amazon.com/STS/latest/APIReference/API_GetFederationToken.html |
| 34 | +- https://www.crowdstrike.com/en-us/blog/how-adversaries-persist-with-aws-user-federation/ |
| 35 | +- https://reinforce.awsevents.com/content/dam/reinforce/2024/slides/TDR432_New-tactics-and-techniques-for-proactive-threat-detection.pdf |
| 36 | +- https://fwdcloudsec.org/assets/presentations/2024/europe/sebastian-walla-cloud-conscious-tactics-techniques-and-procedures-an-overview.pdf |
| 37 | + |
| 38 | + |
| 39 | +## Instructions |
| 40 | + |
| 41 | +```bash title="Detonate with Stratus Red Team" |
| 42 | +stratus detonate aws.persistence.sts-federation-token |
| 43 | +``` |
| 44 | +## Detection |
| 45 | + |
| 46 | + |
| 47 | +Through CloudTrail's <code>GetFederationToken</code> event. |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +## Detonation logs <span class="smallcaps w3-badge w3-light-green w3-round w3-text-sand">new!</span> |
| 52 | + |
| 53 | +The following CloudTrail events are generated when this technique is detonated[^1]: |
| 54 | + |
| 55 | + |
| 56 | +- `sts:GetCallerIdentity` |
| 57 | + |
| 58 | +- `sts:GetFederationToken` |
| 59 | + |
| 60 | + |
| 61 | +??? "View raw detonation logs" |
| 62 | + |
| 63 | + ```json hl_lines="6 51" |
| 64 | + |
| 65 | + [ |
| 66 | + { |
| 67 | + "awsRegion": "ap-isob-east-1r", |
| 68 | + "eventCategory": "Management", |
| 69 | + "eventID": "6e882b9d-2af8-4c67-b91f-aeac6a0e5e70", |
| 70 | + "eventName": "GetFederationToken", |
| 71 | + "eventSource": "sts.amazonaws.com", |
| 72 | + "eventTime": "2024-11-30T08:43:17Z", |
| 73 | + "eventType": "AwsApiCall", |
| 74 | + "eventVersion": "1.08", |
| 75 | + "managementEvent": true, |
| 76 | + "readOnly": false, |
| 77 | + "recipientAccountId": "742491224508", |
| 78 | + "requestID": "e2de7fd1-2a86-4837-b15a-96fff1388061", |
| 79 | + "requestParameters": { |
| 80 | + "name": "stratus_red_team", |
| 81 | + "policy": "{\n\t\t\"Version\": \"2012-10-17\",\n\t\t\"Statement\": [\n\t\t\t{\n\t\t\t\t\"Effect\": \"Allow\",\n\t\t\t\t\"Action\": \"*\",\n\t\t\t\t\"Resource\": \"*\"\n\t\t\t}\n\t\t]\n\t}" |
| 82 | + }, |
| 83 | + "responseElements": { |
| 84 | + "credentials": { |
| 85 | + "accessKeyId": "ASIASTJKC5GCM7ZE6LUP", |
| 86 | + "expiration": "Nov 30, 2024, 8:43:17 PM", |
| 87 | + "sessionToken": "IQoJb3JpZ2luX2VjEOH//////////wEaCXVzLWVhc3QtMSJIMEYCIQDzpomGZAmkp4RIzBo4RqVJGEmUNjyA7lHyt1aKfFh8IwIhANX6aS3XpNU319gOolVjEBkNLRmu9dyO8FqoDW5y+HL4KqICCIr//////////wEQABoMMzQ1NTk0NjA3OTQ5IgykqzjqIZ5pQXZgeDEq9gGg9Law7M5zzj/fSvNlo2pgdgHCmA6UW8IevbwXiKbLO5y0dg/sdhsaEUaOvl6i2Fu+xF2p3dvI8SuCJSTH5PEC2ZRgX1TPhzh+0xN7CsCQG2diBitgDQSs+E3P9ED4xDVuTCE9H8IIS/2BuksBI9bQ3z2itKRkVmkC+xpsfyFc98vX0ZLSUKOIpx+iaDNrhiW85Cyt6ezNEyLfX3bukmmIdVIZQ+Tb4tYLvIRKIyp6OFiA3BL48K7nfIAd1EzDhGnlvkZN/70hDxYt8hTKehNXDs2FVKY5u96z0zhsnNGcuhHHa7OEOKg5lLL5QuEzjx6JA+e9qaQwpaCrugY6mAFp1LZ4E15PVqImPSC/wtr+rEU4Dnp+1/6+PNkbxvxYXfqZOfJxRkZtgWtmV7iWapGzA/pVedD4vuHci4Kq2NUTuyA8L7BeKSaEq0FqFi1yrfCYjYsGI3ncxMQQddgiXVXeoWY4c4auGvAHgiJI/PDQPsaa3Sle/gGnok53u8NfNYoBRtASGaJJtGS0ylDxsQVe9InwBxoJnQ==" |
| 88 | + }, |
| 89 | + "federatedUser": { |
| 90 | + "arn": "arn:aws:sts::742491224508:federated-user/stratus_red_team", |
| 91 | + "federatedUserId": "742491224508:stratus_red_team" |
| 92 | + }, |
| 93 | + "packedPolicySize": 4 |
| 94 | + }, |
| 95 | + "sourceIPAddress": "255.090.254.5", |
| 96 | + "tlsDetails": { |
| 97 | + "cipherSuite": "TLS_AES_128_GCM_SHA256", |
| 98 | + "clientProvidedHostHeader": "sts.ap-isob-east-1r.amazonaws.com", |
| 99 | + "tlsVersion": "TLSv1.3" |
| 100 | + }, |
| 101 | + "userAgent": "aws-sdk-go-v2/1.32.3 os/linux lang/go#1.23.1 md/GOOS#linux md/GOARCH#amd64 exec-env/grimoire_095724e3-1fa0-4e3e-b68a-e8581d194380 api/sts#1.26.2", |
| 102 | + "userIdentity": { |
| 103 | + "accessKeyId": "AKIA6V1GNZTT65XQH36M", |
| 104 | + "accountId": "742491224508", |
| 105 | + "arn": "arn:aws:iam::742491224508:user/stratus-red-team-user-federation-user", |
| 106 | + "principalId": "AIDAN7SEM6PEVTNQR8M4", |
| 107 | + "type": "IAMUser", |
| 108 | + "userName": "stratus-red-team-user-federation-user" |
| 109 | + } |
| 110 | + }, |
| 111 | + { |
| 112 | + "awsRegion": "ap-isob-east-1r", |
| 113 | + "eventCategory": "Management", |
| 114 | + "eventID": "91529247-c4c4-4793-afc8-d70bbcfe9d19", |
| 115 | + "eventName": "GetCallerIdentity", |
| 116 | + "eventSource": "sts.amazonaws.com", |
| 117 | + "eventTime": "2024-11-30T08:43:18Z", |
| 118 | + "eventType": "AwsApiCall", |
| 119 | + "eventVersion": "1.08", |
| 120 | + "managementEvent": true, |
| 121 | + "readOnly": true, |
| 122 | + "recipientAccountId": "742491224508", |
| 123 | + "requestID": "037be419-9e9f-42e0-a38f-2a5d2ae1ce65", |
| 124 | + "requestParameters": null, |
| 125 | + "responseElements": null, |
| 126 | + "sourceIPAddress": "255.090.254.5", |
| 127 | + "tlsDetails": { |
| 128 | + "cipherSuite": "TLS_AES_128_GCM_SHA256", |
| 129 | + "clientProvidedHostHeader": "sts.ap-isob-east-1r.amazonaws.com", |
| 130 | + "tlsVersion": "TLSv1.3" |
| 131 | + }, |
| 132 | + "userAgent": "aws-sdk-go-v2/1.32.3 os/linux lang/go#1.23.1 md/GOOS#linux md/GOARCH#amd64 exec-env/grimoire_095724e3-1fa0-4e3e-b68a-e8581d194380 api/sts#1.26.2", |
| 133 | + "userIdentity": { |
| 134 | + "accessKeyId": "ASIASTJKC5GCM7ZE6LUP", |
| 135 | + "accountId": "742491224508", |
| 136 | + "arn": "arn:aws:sts::742491224508:federated-user/stratus_red_team", |
| 137 | + "principalId": "742491224508:stratus_red_team", |
| 138 | + "sessionContext": { |
| 139 | + "attributes": { |
| 140 | + "creationDate": "2024-11-30T08:43:17Z", |
| 141 | + "mfaAuthenticated": "false" |
| 142 | + }, |
| 143 | + "sessionIssuer": { |
| 144 | + "accountId": "742491224508", |
| 145 | + "arn": "arn:aws:iam::742491224508:user/stratus-red-team-user-federation-user", |
| 146 | + "principalId": "AIDAN7SEM6PEVTNQR8M4", |
| 147 | + "type": "IAMUser", |
| 148 | + "userName": "stratus-red-team-user-federation-user" |
| 149 | + }, |
| 150 | + "webIdFederationData": {} |
| 151 | + }, |
| 152 | + "type": "FederatedUser" |
| 153 | + } |
| 154 | + } |
| 155 | + ] |
| 156 | + ``` |
| 157 | + |
| 158 | +[^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). |
0 commit comments