Generating Temporary Credentials from SSO Credentials File
AWS persistence technique
Overview
This is a really neat post detailing how threat actors can gain credentials from an AWS SSO credentials file.
AWS SSO files
To authenticate via SSO (AWS Identity Center) on the command line, a few steps are required:
This will redirect you to the AWS Console to authenticate
aws configure sso
SSO session name (Recommended): my-sso-connection
SSO start URL [None]: <AWS access portal URL>
SSO region [None]: <region-of-aws-identity-center>
SSO registration scopes [sso:account:access]: <hit-enter>
Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open, open the following URL:
https://oidc.us-east-1.amazonaws.com/authorize?response_type=code&client_id=IgPwONL[SNIP]Then you'll be prompted to choose the account to access (assuming you can access more than one)
Then you'll choose the permission set (assuming you have access to more than one) or if not, it'll default you to the only permission set you have access to
Then this info will be added to
~/.aws/config
And two files will be added to
~/.aws/sso/cacheThe one we want contains this info
Getting STS Credentials
We can't directly use the credentials found in the file above but we can leverage the refresh token to generate some new ones from the AWS STS service as long as the token is still valid.
Grab the info from
~/.aws/configand~/.aws/sso/cache/<file>.jsonand add to the command below:
We can setup those new credentials with
aws --profile billing-sso configureThe credentials will last as long as is configured in AWS Identity Center under "User interactive sessions" e.g., (15 min - 90 days).
Last updated
Was this helpful?