Translated ['', 'src/pentesting-cloud/azure-security/az-services/az-stor

This commit is contained in:
Translator
2026-07-09 16:58:07 +00:00
parent 36a43c245f
commit 387422eb8a
@@ -2,54 +2,54 @@
{{#include ../../../banners/hacktricks-training.md}}
## Basic Information
## 基本情報
Azure Storage Accounts はMicrosoft Azure の基サービスで、blobs (binary large objects)、files、queues、tables を含む、さまざまな data types 向けにスケーラブルで secure、かつ highly available な cloud **storage** を提供します。これらは、異なる storage services を 1 つの namespace にまとめ、管理を容易にする container として機能します。
Azure Storage Accounts は Microsoft Azure の基サービスで、**さまざまなデータ型のためのスケーラブルで安全、高可用な cloud ストレージ** を提供します。これには blobs (binary large objects)、files、queues、tables が含まれます。これらはコンテナとして機能し、異なる storage services を単一の namespace の下にまとめ、管理しやすくします。
**Main configuration options**:
**主な設定オプション**:
- すべての storage account は、Azure 全体で一意の **uniq name** を持つ必要があります。
- すべての storage account は、Azure 全体で **一意の名前** である必要があります。
- すべての storage account は **region** または Azure extended zone にデプロイされます
- より良い performance のために storage account の **premium** version を選択できます
- rack、drive、datacenter の **failures** に対する保護のため、**4 types of redundancy** から選択できます。
- より高いパフォーマンスのために storage account の **premium** を選択できます
- rack、drive、datacenter の **failure** に対して保護するため、**4種類の redundancy** から選択できます。
**Security configuration options**:
**セキュリティ設定オプション**:
- **Require secure transfer for REST API operations**: storage との通信で TLS を必須にする
- **Allows enabling anonymous access on individual containers**: これを有効にしないと、将来 anonymous access を有効できません
- **Enable storage account key access**: これを有効にしないと、Shared Keys でのアクセスは forbidden になります
- **Allows enabling anonymous access on individual containers**: 無効の場合、将来的に anonymous access を有効できなくなります
- **Enable storage account key access**: 無効の場合、Shared Keys を使ったアクセスは禁止されます
- **Minimum TLS version**
- **Permitted scope for copy operations**: 任意の storage account から、同じ Entra tenant の任意の storage account から、または同じ virtual network 内の private endpoints を持つ storage account からのコピーを許可します。
- **Permitted scope for copy operations**: 任意の storage account から、同じ Entra tenant の任意の storage account から、または同じ virtual network 内の private endpoints を持つ storage account からのコピーを許可する
**Blob Storage options**:
**Blob Storage オプション**:
- **Allow cross-tenant replication**
- **Access tier**: Hot (頻繁にアクセスされる data)、Cool、Cold (まれにアクセスされ data)
- **Access tier**: Hot (頻繁にアクセスされる data)、Cool、Cold (ほとんどアクセスされない data)
**Networking options**:
**ネットワーク設定オプション**:
- **Network access**:
- すべての networks から許可
- 選択された virtual networks と IP addresses から許可
- public access を無効にして private access を使用
- **Private endpoints**: virtual network から storage account への private connection を許可します
- 選択た virtual networks と IP addresses から許可
- public access を無効化し private access を使用
- **Private endpoints**: virtual network から storage account への private 接続を許可します
**Data protection options**:
**Data protection オプション**:
- **Point-in-time restore for containers**: containers を以前の state に restore できます
- これには versioning、change feed、blob soft delete 有効にする必要があります。
- **Enable soft delete for blobs**: deleted blobs (上書きされたものも含む) に対して、日数単位の retention period を有効にします
- **Enable soft delete for containers**: deleted containers に対して、日数単位の retention period を有効にします
- **Enable soft delete for file shares**: deleted file shared に対して、日数単位の retention period を有効にします
- **Enable versioning for blobs**: blobs の previous versions を保持します
- **Enable blob change feed**: blobs への create、modification、delete の変更ログを保持します
- **Enable version-level immutability support**: account-level で time-based retention policy を設定でき、それがすべての blob versions に適用されます。
- Version-level immutability support と point-in-time restore for containers は同時に有効できません。
- **Point-in-time restore for containers**: containers を以前の状態に復元できます
- これには versioning、change feed、blob soft delete 有効化が必要です。
- **Enable soft delete for blobs**: 削除された blobs上書きされたものも含むに対して、日数単位の retention period を有効にします
- **Enable soft delete for containers**: 削除された containers に対して、日数単位の retention period を有効にします
- **Enable soft delete for file shares**: 削除された file shared に対して、日数単位の retention period を有効にします
- **Enable versioning for blobs**: blobs の以前の versions を保持します
- **Enable blob change feed**: blobs に対する作成、変更、削除の変更ログを保持します
- **Enable version-level immutability support**: account-level で time-based retention policy を設定でき、すべての blob versions に適用されます。
- version-level immutability support と point-in-time restore for containers は同時に有効できません。
**Encryption configuration options**:
**Encryption 設定オプション**:
- **Encryption type**: Microsoft-managed keys (MMK) または Customer-managed keys (CMK) を使用できます
- **Enable infrastructure encryption**: data を "for more security" のために二重に encrypt できます
- **Enable infrastructure encryption**: data を "for more security" のために二重に暗号化できます
### Storage endpoints
@@ -66,16 +66,16 @@ Azure Storage Accounts は、Microsoft Azure の基盤サービスで、blobs (b
If "Allow Blob public access" is **enabled** (disabled by default), when creating a container it's possible to:
- **public access** を与えて blobs を read できるようにする (name を知っている必要があります)
- container blobs を **List** して、**read** する
- **blobs を読むための public access** を付与する(name を知っている必要があります
- **container blobs を一覧表示** して **読む**
- 完全に **private** にする
<figure><img src="https://lh7-rt.googleusercontent.com/slidesz/AGV_vUfoetUnYBPWQpRrWNnnlbqWpl8Rdoaeg5uBrCVlvcNDlnKwQHjZe8nUb2SfPspBgbu-lCZLmUei-hFi_Jl2eKbaxUtBGTjdUSDmkrcwr90VZkmuMjk9tyh92p75btfyzGiUTa0-=s2048?key=m8TV59TrCFPlkiNnmhYx3aZt" alt=""><figcaption></figcaption></figure>
### Static website (`$web`) exposure & leaked secrets
- **Static websites** は、`https://<account>.z13.web.core.windows.net/` のような region-specific endpoint 経由で特別な `$web` container から配信されます。
- `$web` container は blob API で `publicAccess: null` を返すことがありますが、ファイルは static site endpoint 経由で引き続き到達可能なため、そこに config/IaC artifacts を置くと secrets が leak する可能性があります。
- **Static websites** are served from the special `$web` container over a region-specific endpoint such as `https://<account>.z13.web.core.windows.net/`.
- The `$web` container may report `publicAccess: null` via the blob API, but files are still reachable through the static site endpoint, so dropping config/IaC artifacts there can leak secrets.
- Quick audit workflow:
```bash
# Identify storage accounts with static website hosting enabled
@@ -89,51 +89,51 @@ az storage blob download -c '$web' --name iac/terraform.tfvars --file /dev/stdou
```
### 匿名 blob exposure の監査
- データを expose できる **storage accounts を特定**します: `az storage account list | jq -r '.[] | select(.properties.allowBlobPublicAccess==true) | .name'`. `allowBlobPublicAccess``false` の場合、containers を public にできません。
- **リスクのある accounts を確認**して、flag と他の弱い設定を確かめます: `az storage account show --name <acc> --query '{allow:properties.allowBlobPublicAccess, minTls:properties.minimumTlsVersion}'`.
- flag が有効な場合の **container-level exposure を列挙**します:
- データを公開しう**storage accounts を特定** する: `az storage account list | jq -r '.[] | select(.properties.allowBlobPublicAccess==true) | .name'``allowBlobPublicAccess``false` の場合、containers を public にできません。
- **リスクのある accounts を確認** して、フラグと他の弱い設定を検証する: `az storage account show --name <acc> --query '{allow:properties.allowBlobPublicAccess, minTls:properties.minimumTlsVersion}'`.
- フラグが有効な場合の **container-level exposure を列挙** する:
```bash
az storage container list --account-name <acc> \
--query '[].{name:name, access:properties.publicAccess}'
```
- `"Blob"`: 匿名 read は **blob name が分かっている場合のみ** 許可される(listing は不可)。
- `"Container"`: 匿名ですべての blob の **list + read** が可能
- `null`: private; authentication required.
- **credentials なしで access を prove**:
- `"Blob"`: 匿名 read は **blob 名が既知の場合のみ** 許可される(listing は不可)。
- `"Container"`: すべての blob の匿名 **list + read**
- `null`: private; authentication が必要。
- 認証情報なしで **access を証明**する:
- `publicAccess``Container` の場合、匿名 listing が動作する: `curl "https://<acc>.blob.core.windows.net/<container>?restype=container&comp=list"`.
- `Blob``Container` の両方で、name が分かっていれば匿名 blob download が動作する:
- `Blob``Container` の両方で、name が既知なら匿名 blob download が動作する:
```bash
az storage blob download -c <container> -n <blob> --account-name <acc> --file /dev/stdout
# or via raw HTTP
curl "https://<acc>.blob.core.windows.net/<container>/<blob>"
```
### Storage への接続
### Storageへの接続
接続できる **storage** 見つかった場合、[**Microsoft Azure Storage Explorer**](https://azure.microsoft.com/es-es/products/storage/storage-explorer/) ツールを使って接続できます。
接続可能な **storage** 見つた場合、ツール [**Microsoft Azure Storage Explorer**](https://azure.microsoft.com/es-es/products/storage/storage-explorer/) を使って接続できます。
## Storage へのアクセス <a href="#about-blob-storage" id="about-blob-storage"></a>
## Storageへのアクセス <a href="#about-blob-storage" id="about-blob-storage"></a>
### RBAC
**RBAC roles** を使って Entra ID principals から storage accounts にアクセスすることが可能で、これが推奨方法です。
**RBAC roles** を使って Entra ID principals storage accounts にアクセスすることが可能で、これが推奨される方法です。
### Access Keys
storage accounts には access keys があり、それを使ってアクセスできます。これにより storage account への**完全なアクセス**が可能になります。
storage accounts には access keys があり、それを使ってアクセスできます。これにより **storage account へのフルアクセス** が可能になります。
<figure><img src="../../../images/image (5).png" alt=""><figcaption></figcaption></figure>
### **Shared Keys & Lite Shared Keys**
[**Shared Keys を生成する**](https://learn.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key)ことが可能で、access keys で署名されたものを使って、signed URL 経由で特定の resources へのアクセスを認可できます。
[**Shared Keys を生成する**](https://learn.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key) ことが可能で、access keys で署名されており、signed URL を通じて特定の resources へのアクセスを認可ます。
> [!NOTE]
> `CanonicalizedResource` 部分は storage services resource (URI) を表します。URL のどこかがエンコードされている場合は、`CanonicalizedResource` 内でも同にエンコードされている必要があります。
> `CanonicalizedResource` 部分は storage services resource (URI) を表します。URL のどこかがエンコードされている場合は、`CanonicalizedResource` 内でも同じようにエンコードされている必要があります。
> [!NOTE]
> これは requests 認証に **`az` cli デフォルト使用** されます。Entra ID principal credentials を使わせるには、`--auth-mode login` パラメータを指定します。
> これは requests 認証するために **`az` cli によってデフォルト使用されます**。Entra ID principal credentials を使わせるには、param `--auth-mode login` を指定します。
- 以下の情報に署名することで、**blob, queue and file services 用の shared key** を生成できます:
- の情報に署名することで、**blob, queue and file services 用の shared key** を生成することが可能です:
```bash
StringToSign = VERB + "\n" +
Content-Encoding + "\n" +
@@ -150,7 +150,7 @@ Range + "\n" +
CanonicalizedHeaders +
CanonicalizedResource;
```
- 次の情報に署名することで、**table services** 用の **shared key** を生成できます:
- 次の情報に署名することで、**table services 用の共有キー**を生成することが可能です:
```bash
StringToSign = VERB + "\n" +
Content-MD5 + "\n" +
@@ -158,7 +158,7 @@ Content-Type + "\n" +
Date + "\n" +
CanonicalizedResource;
```
- 次の情報に署名して、**blobqueuefile services 用の lite shared key** を生成することが可能です:
- 次の情報に署名することで、**blob, queue, file services 用の lite shared key** を生成することが可能です:
```bash
StringToSign = VERB + "\n" +
Content-MD5 + "\n" +
@@ -172,7 +172,7 @@ CanonicalizedResource;
StringToSign = Date + "\n"
CanonicalizedResource
```
その後、key を使用するには、Authorization header で次の syntax に従って行うことができます:
その後、キーを使うには、Authorization header で次の構文に従って指定できます:
```bash
Authorization="[SharedKey|SharedKeyLite] <AccountName>:<Signature>"
#e.g.
@@ -186,14 +186,14 @@ Content-Length: 0
```
### **Shared Access Signature** (SAS)
Shared Access Signatures (SAS) は、Azure Storage account 内の resource アクセスするための **特定の権限を付与する**、安全で時間制限付きの URL です。account の access keys を露出させずに利用できます。access keys はすべての resource への完全な管理アクセスを提供しますが、SAS は read や write などの権限を指定し、有効期限を設定することで、きめ細かい制御が可能です。
Shared Access Signatures (SAS) は、Azure Storage アカウント内の resource へのアクセスに対して**特定の permissions を付与する**、安全で time-limited な URLs です。アカウントの access keys を公開せずに済みます。access keys はすべての resources へのフル管理アクセスを提供しますが、SAS は permissionsread や write など)を細かく指定し、expiration time を定義することで granular control を可能にします。
#### SAS Types
- **User delegation SAS**: これは **Entra ID principal** から作成され、SAS に署名し、user から SAS へ権限を委任します。**blob and data lake storage** でのみ使用できます ([docs](https://learn.microsoft.com/en-us/rest/api/storageservices/create-user-delegation-sas))。生成された user delegated SAS はすべて **revoke** 可能です。
- user にある権限よりも「多い」権限で delegation SAS を生成することは可能です。ただし、その principal がその権限を持っていなければ動作しません(privesc なし)。
- **User delegation SAS**: これは **Entra ID principal** から作成され、SAS に署名し、user から SAS へ permissions を委任します。**blob and data lake storage** でのみ使用できます ([docs](https://learn.microsoft.com/en-us/rest/api/storageservices/create-user-delegation-sas))。生成された user delegated SAS はすべて **revoke**きます。
- ユーザーが持つ permissions よりも「多い」 permissions を持つ delegation SAS を生成することは可能です。しかし、principal がそれらを持っていなければ機能しません(privesc なし)。
- **Service SAS**: これは storage account の **access keys** のいずれかを使って署名されます。単一の storage service 内の特定 resource へのアクセスを付与するために使用できます。key が renewed されると、SAS は動作しなくなります。
- **Account SAS**: これも storage account の **access keys** のいずれかで署名されます。storage account services 全体Blob, Queue, Table, File resource へのアクセスを付与でき、service-level operations を含めることができます。
- **Account SAS**: これも storage account の **access keys** のいずれかで署名されます。storage account servicesBlobQueueTableFileをまたいで resources へのアクセスを付与でき、service-level operations を含められます。
**access key** で署名された SAS URL は次のようになります:
@@ -211,43 +211,43 @@ Shared Access Signatures (SAS) は、Azure Storage account 内の resource に
#### SAS permissions
SAS を生成する際には、付与すべき permissions を指定する必要があります。SAS を生成する対象の objet によって、含められる permissions は異なります。たとえば:
SAS を生成するときは、付与すべき permissions を指定する必要があります。SAS を生成する対象の object に応じて、含められる permissions は異なります。たとえば:
- (a)dd, (c)reate, (d)elete, (e)xecute, (f)ilter_by_tags, (i)set_immutability_policy, (l)ist, (m)ove, (r)ead, (t)ag, (w)rite, (x)delete_previous_version, (y)permanent_delete
## SFTP Support for Azure Blob Storage
Azure Blob Storage は現在、SSH File Transfer Protocol (SFTP) をサポートしており、カスタムソリューションや third-party products を必要とせずに、Blob Storage へ直接、安全な file transfer と管理を可能にします。
Azure Blob Storage は現在、SSH File Transfer Protocol (SFTP) をサポートしており、custom solutions や third-party products を必要とせずに、Blob Storage へ直接 secure file transfer と管理を可能にします。
### Key Features
- Protocol Support: SFTP はhierarchical namespace (HNS) 構成された Blob Storage accounts で動作します。これにより blobs directories と subdirectories に整理され、移動が সহজになります。
- Security: SFTP は認証に local user identities を使用し、RBAC や ABAC とは統合されません。各 local user は次の方法で認証できます:
- Protocol Support: SFTP は hierarchical namespace (HNS) 構成た Blob Storage accounts で動作します。これにより blobs directories と subdirectories に整理、移動しやすくなります。
- Security: SFTP は local user identities を使用できますが、authorization のために Azure RBAC を伴う Microsoft Entra ID-based access もサポートします。つまり、local SFTP users を作成する代わりに、通常の Blob Storage data-plane roles で access を付与できます。Local users以下で authenticate できます:
- Azure-generated passwords
- Public-private SSH key pairs
- Granular Permissions: Read, Write, Delete, List などの permissions を最大 100 containers まで local users に割り当てられます。
- Networking Considerations: SFTP connections は port 22 を通じて行われます。Azure は SFTP traffic を保護するために、firewalls、private endpoints、virtual networks などの network configurations をサポートします。
- Granular Permissions: Read, Write, Delete, List などの permissions を local users に対して最大 100 containers まで割り当てられます。
- Networking Considerations: SFTP connections は port 22 経由で行われます。Azure は SFTP traffic を保護するために、firewalls、private endpoints、virtual networks などの network configurations をサポートします。
### Setup Requirements
- Hierarchical Namespace: storage account 作成する際に HNS を有効にする必要があります。
- Supported Encryption: Microsoft Security Development Lifecycle (SDL) 承認の cryptographic algorithms(例: rsa-sha2-256, ecdsa-sha2-nistp256)が必要です。
- Hierarchical Namespace: storage account 作成に HNS を有効にする必要があります。
- Supported Encryption: Microsoft Security Development Lifecycle (SDL) 承認済みの cryptographic algorithms(例: rsa-sha2-256, ecdsa-sha2-nistp256)が必要です。
- SFTP Configuration:
- storage account で SFTP を有効します。
- 適切な permissions を持つ local user identities を作成します。
- users 用に home directories を構成し、container 内での開始位置を定義します。
- storage account で SFTP を有効します。
- local-user access の場合、適切な permissions を持つ local user identities を作成します。
- local users の場合、home directories を設定して container 内での開始位置を定義します。
### Permissions
| Permission | Symbol | Description |
| ---------------------- | ------ | ------------------------------------ |
| **Read** | `r` | Read file content. |
| **Write** | `w` | Upload files and create directories. |
| **List** | `l` | List contents of directories. |
| **Delete** | `d` | Delete files or directories. |
| **Create** | `c` | Create files or directories. |
| **Modify Ownership** | `o` | Change the owning user or group. |
| **Modify Permissions** | `p` | Change ACLs on files or directories. |
| **Read** | `r` | ファイル内容を read します。 |
| **Write** | `w` | files を upload し、directories を create します。 |
| **List** | `l` | directories の内容を list します。 |
| **Delete** | `d` | files directories を delete します。 |
| **Create** | `c` | files directories を create します。 |
| **Modify Ownership** | `o` | owning user または group を変更します。 |
| **Modify Permissions** | `p` | files directories の ACLs を変更します。 |
## Enumeration
@@ -469,8 +469,9 @@ az-file-shares.md
## References
- [https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction)
- [https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview](https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview)
- [https://learn.microsoft.microsoft.com/en-us/azure/storage/common/storage-sas-overview](https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview)
- [https://learn.microsoft.com/en-us/azure/storage/blobs/secure-file-transfer-protocol-support](https://learn.microsoft.com/en-us/azure/storage/blobs/secure-file-transfer-protocol-support)
- [https://learn.microsoft.com/en-us/azure/storage/blobs/secure-file-transfer-protocol-support-entra-id-based-access](https://learn.microsoft.com/en-us/azure/storage/blobs/secure-file-transfer-protocol-support-entra-id-based-access)
- [Holiday Hack Challenge 2025 Spare Key (Azure static website SAS leak)](https://0xdf.gitlab.io/holidayhack2025/act1/spare-key)
- [Holiday Hack Challenge 2025: Blob Storage (Storage Secrets)](https://0xdf.gitlab.io/holidayhack2025/act1/blob-storage)
- [https://learn.microsoft.com/en-us/cli/azure/storage/account](https://learn.microsoft.com/en-us/cli/azure/storage/account)