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

This commit is contained in:
Translator
2026-07-09 16:57:48 +00:00
parent f928324593
commit a4814970ef
@@ -4,27 +4,27 @@
## 基本信息
Azure Storage Accounts 是 Microsoft Azure 中的基础服务,提供可扩展、安全且高可用的云端 **多种数据类型的 storage**,包括 blobsbinary large objects、files、queues 和 tables。它们作为容器,将这些不同的 storage services 组合在一个单一命名空间下,便于管理。
Azure Storage Accounts 是 Microsoft Azure 中的基础服务,提供可扩展、安全且高可用的云端 **storage for various data types**,包括 blobs (binary large objects)、files、queues 和 tables。它们作为容器,将这些不同的 storage services 组合在单一 namespace 下,便于管理。
**主要配置选项**
- 每个 storage account 在整个 Azure 中必须有唯一名称
- 每个 storage account 部署在一个 **region** 或 Azure extended zone 中
- 每个 storage account 在整个 Azure 中必须有一个 **uniq name**
- 每个 storage account 部署在一个 **region** 或 Azure extended zone 中
- 可以选择 storage account 的 **premium** 版本以获得更好的性能
- 可以在 **4 种冗余类型** 中选择,以防护机架、磁盘和 datacenter **故障**
- 可以在 **4 种冗余类型**进行选择,以防护 rack、drive 和 datacenter **failures**
**安全配置选项**
- **Require secure transfer for REST API operations**:要求任何与 storage 的通信都使用 TLS
- **Allows enabling anonymous access on individual containers**:如果不允许,将来就无法启用匿名访问
- **Require secure transfer for REST API operations**:要求与 storage 的任何通信都使用 TLS
- **Allows enabling anonymous access on individual containers**:如果不启用,未来也无法再开启匿名访问
- **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 选项**
- **Allow cross-tenant replication**
- **Access tier**Hot经常访问的数据)、Cool 和 Cold(很少访问的数据)
- **Access tier**Hot频繁访问的数据)、Cool 和 Cold(很少访问的数据)
**网络选项**
@@ -32,24 +32,24 @@ Azure Storage Accounts 是 Microsoft Azure 中的基础服务,提供可扩展
- 允许来自所有网络
- 允许来自选定的 virtual networks 和 IP addresses
- 禁用 public access 并使用 private access
- **Private endpoints**:允许从 virtual network 到 storage account 的 private 连接
- **Private endpoints**:允许从 virtual network 到 storage account 的 private connection
**数据保护选项**
- **Point-in-time restore for containers**:允许将 containers 恢复到较早状态
-要启用 versioning、change feed 和 blob soft delete。
- **Enable soft delete for blobs**:为删除的 blobs(即使被覆盖)设置按天计算的保留期
- **Enable soft delete for containers**:为删除的 containers 设置按天计算的保留期
- **Enable soft delete for file shares**:为删除的 file shared 设置按天计算的保留期
- 它要启用 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 的先前版本
- **Enable blob change feed**记录 blobs 的创建、修改和删除变更日志
- **Enable version-level immutability support**:允许在 account-level 设置基于时间的保留策略,并将其应用于所有 blob versions。
- **Enable blob change feed**保留对 blobs 的创建、修改和删除变更日志
- **Enable version-level immutability support**:允许在 account-level 设置基于时间的 retention policy,并将其应用于所有 blob versions。
- Version-level immutability support 和 point-in-time restore for containers 不能同时启用。
**加密配置选项**
- **Encryption type**:可以使用 Microsoft-managed keys (MMK) 或 Customer-managed keys (CMK)
- **Enable infrastructure encryption**:允许对数据进行双重加密,以“提高安全性
- **Enable infrastructure encryption**:允许对数据进行双重加密,“for more security
### Storage endpoints
@@ -66,17 +66,17 @@ Azure Storage Accounts 是 Microsoft Azure 中的基础服务,提供可扩展
如果启用了 "Allow Blob public access"(默认禁用),在创建 container 时可以:
- 提供对 blobs 的 **public access 读取**(你需要知道名称)。
- **列出 container blobs** 并 **读取** 它们。
- 赋予 **public access to read blobs**(你需要知道名称)。
- **List container blobs** 并读取它们。
- 设为完全 **private**
<figure><img src="https://lh7-rt.googleusercontent.com/slidesz/AGV_vUfoetUnYBPWQpRrWNnnlbqWpl8Rdoaeg5uBrCVlvcNDlnKwQHjZe8nUb2SfPspBgbu-lCZLmUei-hFi_Jl2eKbaxUtBGTjdUSDmkrcwr90VZkmuMjk9tyh92p75btfyzGiUTa0-=s2048?key=m8TV59TrCFPlkiNnmhYx3aZt" alt=""><figcaption></figcaption></figure>
### 静态 website (`$web`) 暴露 & 泄露的 secrets
### Static website (`$web`) exposure & leaked secrets
- **Static websites** 从特殊的 `$web` container 提供服务,使用按 region 区分的 endpoint,例如 `https://<account>.z13.web.core.windows.net/`
- `$web` container 可能通过 blob API 返回 `publicAccess: null`,但文件仍可通过 static site endpoint 访问,因此把 config/IaC artifacts 放在那里可能会泄露 secrets
- 快速审计流程:
- **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
az storage blob service-properties show --account-name <acc-name> --auth-mode login
@@ -87,21 +87,21 @@ az storage blob list --container-name '$web' --account-name <acc-name> --auth-mo
# Pull suspicious files directly (e.g., IaC tfvars containing secrets/SAS)
az storage blob download -c '$web' --name iac/terraform.tfvars --file /dev/stdout --account-name <acc-name> --auth-mode login
```
### 审计匿名 blob 暴露
### 审计 anonymous blob 暴露
- **定位可能暴露数据的 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 暴露**
- **Locate storage accounts** that can expose data: `az storage account list | jq -r '.[] | select(.properties.allowBlobPublicAccess==true) | .name'`. If `allowBlobPublicAccess` is `false` you cannot turn containers public.
- **Inspect risky accounts** to confirm the flag and other weak settings: `az storage account show --name <acc> --query '{allow:properties.allowBlobPublicAccess, minTls:properties.minimumTlsVersion}'`.
- **Enumerate container-level exposure** where the flag is enabled:
```bash
az storage container list --account-name <acc> \
--query '[].{name:name, access:properties.publicAccess}'
```
- `"Blob"`: 匿名读取仅在 **已知 blob 名称** 时允许(不能列出)。
- `"Blob"`: 匿名读取仅在 **已知 blob 名称** 时允许(不允许列表)。
- `"Container"`: 匿名 **列出 + 读取** 每个 blob。
- `null`: private; 需要 authentication
- **在没有 credentials 的情况下证明访问**
- 如果 `publicAccess``Container`,匿名 listing 可用:`curl "https://<acc>.blob.core.windows.net/<container>?restype=container&comp=list"`.
- 对于 `Blob``Container`,当名称已知时,匿名 blob download 可用:
- `null`: 私有;需要认证
- **在没有凭据的情况下证明访问**
- 如果 `publicAccess``Container`,匿名列表可用:`curl "https://<acc>.blob.core.windows.net/<container>?restype=container&comp=list"`
- 对于 `Blob``Container`,当已知名称时,匿名 blob 下载可用:
```bash
az storage blob download -c <container> -n <blob> --account-name <acc> --file /dev/stdout
# or via raw HTTP
@@ -109,31 +109,31 @@ curl "https://<acc>.blob.core.windows.net/<container>/<blob>"
```
### Connect to Storage
如果你发现任何可以连接的 **storage**,可以使用工具 [**Microsoft Azure Storage Explorer**](https://azure.microsoft.com/es-es/products/storage/storage-explorer/) 来完成。
If you find any **storage** you can connect to you could use the tool [**Microsoft Azure Storage Explorer**](https://azure.microsoft.com/es-es/products/storage/storage-explorer/) to do so.
## Access to Storage <a href="#about-blob-storage" id="about-blob-storage"></a>
### RBAC
可以使用带有 **RBAC roles** 的 Entra ID principals 来访问 storage accounts,这是推荐方式。
可以使用 Entra ID principals 配合 **RBAC roles** 访问 storage accounts,这是推荐方式。
### Access Keys
storage accounts 有 access keys,可用于访问它。这会提供对 storage account 的**完整访问权限。**
storage accounts 有可用于访问的 access keys。这会提供对 storage account 的 f**ull access.**
<figure><img src="../../../images/image (5).png" alt=""><figcaption></figcaption></figure>
### **Shared Keys & Lite Shared Keys**
可以通过 [**generate Shared Keys**](https://learn.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key) 使用 access keys 签名,借助 signed URL 授权访问某些资源。
可以通过使用 access keys 签名生成 [**Shared Keys**](https://learn.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key),借助 signed URL 授权访问某些资源。
> [!NOTE]
> 注意,`CanonicalizedResource` 部分表示 storage services resource (URI)。如果 URL 中任何部分经过了编码,那么它也应该在 `CanonicalizedResource` 中进行编码。
> 注意,`CanonicalizedResource` 部分表示 storage services resource (URI)。如果 URL 中任何部分编码,那么它也应该在 `CanonicalizedResource` 中编码。
> [!NOTE]
> 会被 `az` cli 默认用于认证请求。要让它使用 Entra ID principal credentials,请指定参数 `--auth-mode login`。
> 是 **`az` cli 默认用于** 认证请求的方式。要让它使用 Entra ID principal credentials,请指定参数 `--auth-mode login`。
- 可以通过签名以下信息生成一个用于 blob、queue 和 file services 的 **shared key**
- 可以通过以下信息签名,生成一个用于 blob、queue 和 file services 的 **shared key**
```bash
StringToSign = VERB + "\n" +
Content-Encoding + "\n" +
@@ -150,7 +150,7 @@ Range + "\n" +
CanonicalizedHeaders +
CanonicalizedResource;
```
- 可以通过签名以下信息来**table services** 生成一个 **shared key**
- 可以通过签名以下信息来生成一个 **shared key for table services**
```bash
StringToSign = VERB + "\n" +
Content-MD5 + "\n" +
@@ -158,7 +158,7 @@ Content-Type + "\n" +
Date + "\n" +
CanonicalizedResource;
```
- 可以为 blob、queue 和 file services 生成一个 **lite shared key**用于签名以下信息:
- 可以为 blob、queue 和 file services 生成一个 **lite shared key**,签名以下信息:
```bash
StringToSign = VERB + "\n" +
Content-MD5 + "\n" +
@@ -167,7 +167,7 @@ Date + "\n" +
CanonicalizedHeaders +
CanonicalizedResource;
```
- 可以生成一个用于 table services 签名的 **lite shared key**,签名以下信息
- 可以通过签名以下信息来生成一个 **lite shared key for table services**
```bash
StringToSign = Date + "\n"
CanonicalizedResource
@@ -186,20 +186,20 @@ Content-Length: 0
```
### **Shared Access Signature** (SAS)
Shared Access Signatures (SAS) 是安全、限时的 URL,用于在不暴露账户 access keys 的情况下,**授予访问 Azure Storage account 中资源的特定权限**。虽然 access keys 提供对所有资源的完管理访问权限,但 SAS 通过指定权限(如 read 或 write)并定义过期时间实现细粒度控制。
Shared Access Signatures (SAS) 是安全、限时的 URL,用于**授予访问 Azure Storage account 中资源的特定权限**,而不会暴露 account 的 access keys。虽然 access keys 提供对所有资源的完管理访问权限,但 SAS 通过指定权限(如 read 或 write)并定义过期时间实现细粒度控制。
#### SAS Types
- **User delegation SAS**: 这是 **Entra ID principal** 创建的,它会签名 SAS,并将权限从用户委派给 SAS。它只能用于 **blob data lake storage** ([docs](https://learn.microsoft.com/en-us/rest/api/storageservices/create-user-delegation-sas))。可以 **revoke** 所有生成的 user delegated SAS。
- 即使可以生成比用户实际拥有的权限“更多”的 delegation SAS 也是如此。不过,如果 principal 没有这些权限,它也不会生效no privesc)。
- **Service SAS**: 这是使用 storage account 的某个 **access keys** 签名的。它可用于授予对单个 storage service 中特定资源的访问权限。如果 key 被轮换SAS 将停止工作。
- **Account SAS**: 它也使用 storage account 的某个 **access keys** 签名。它授予 storage account servicesBlob、Queue、Table、File)的资源访问权限,并且可以包含 service-level operations
- **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))。可以**revoke** 所有生成的 user delegated SAS。
- 即使可以生成权限“更多”的 delegation SAS,也仍然如此。然而,如果 principal 本身没有这些权限,它也不会工作no privesc)。
- **Service SAS**: 这是使用 storage account 的某个 **access key** 签名的。它可用于授予对单个 storage service 中特定资源的访问权限。如果 key 被续订SAS 将停止工作。
- **Account SAS**: 这同样是用 storage account 的某个 **access key** 签名。它授予 storage account 各项 servicesBlob、Queue、Table、File的资源访问权限,并且可以包含 service-level 操作
**access key** 签名的 SAS URL 如下
一个**access key** 签名的 SAS URL 看起来像这样
- `https://<container_name>.blob.core.windows.net/newcontainer?sp=r&st=2021-09-26T18:15:21Z&se=2021-10-27T02:14:21Z&spr=https&sv=2021-07-08&sr=c&sig=7S%2BZySOgy4aA3Dk0V1cJyTSIf1cW%2Fu3WFkhHV32%2B4PE%3D`
**user delegation** 签名的 SAS URL 如下
一个以 **user delegation** 方式签名的 SAS URL 看起来像这样
- `https://<container_name>.blob.core.windows.net/testing-container?sp=r&st=2024-11-22T15:07:40Z&se=2024-11-22T23:07:40Z&skoid=d77c71a1-96e7-483d-bd51-bd753aa66e62&sktid=fdd066e1-ee37-49bc-b08f-d0e152119b04&skt=2024-11-22T15:07:40Z&ske=2024-11-22T23:07:40Z&sks=b&skv=2022-11-02&spr=https&sv=2022-11-02&sr=c&sig=7s5dJyeE6klUNRulUj9TNL0tMj2K7mtxyRc97xbYDqs%3D`
@@ -211,21 +211,21 @@ Shared Access Signatures (SAS) 是安全、限时的 URL,用于在不暴露账
#### SAS permissions
生成 SAS 时,需要指定它应授予的权限。根据生成 SAS 的对象不同,可包含不同的权限。例如:
生成 SAS 时,需要指定它应授予的权限。根据生成 SAS 的对象不同,可包含的权限也不同。例如:
- (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),可直接对 Blob Storage 进行安全文件传输和管理,而无需自定义解决方案或第三方产品。
Azure Blob Storage 现在支持 SSH File Transfer Protocol (SFTP),可直接对 Blob Storage 进行安全文件传输和管理,而无需自定义方案或第三方产品。
### Key Features
- Protocol Support: SFTP 适用于配置了 hierarchical namespace (HNS) 的 Blob Storage accounts。这会将 blobs 组织 directories 和 subdirectories,便于导航。
- Security: SFTP 使用 local user identities 进行 authentication,并且不与 RBAC 或 ABAC 集成。每个 local user 可以通过以下方式进行 authentication
- Protocol Support: SFTP 适用于配置了 hierarchical namespace (HNS) 的 Blob Storage accounts。这会将 blobs 组织 directories 和 subdirectories,便于导航。
- Security: SFTP 可以使用 local user identities,也支持基于 Microsoft Entra ID 的访问,并结合 Azure RBAC 进行授权。这意味着可以使用常见的 Blob Storage data-plane roles 来授予访问权限,而不必创建本地 SFTP users。Local users 可以通过以下方式认证
- Azure-generated passwords
- Public-private SSH key pairs
- Granular Permissions: Read、Write、Delete 和 List 等 permissions 可以分配给 local users,最多可覆盖 100 个 containers。
- Granular Permissions: 可以为 local users 分配 Read、Write、Delete 和 List 等权限,最多可作用于 100 个 containers。
- Networking Considerations: SFTP connections 通过 port 22 建立。Azure 支持 firewall、private endpoints 或 virtual networks 等网络配置来保护 SFTP traffic。
### Setup Requirements
@@ -234,20 +234,20 @@ Azure Blob Storage 现在支持 SSH File Transfer Protocol (SFTP),可直接对
- 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 的起始位置。
- 对于 local-user access,创建具有适当权限的 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` | 读取文件内容。 |
| **Write** | `w` | 上传文件并创建目录。 |
| **List** | `l` | 列出目录内容。 |
| **Delete** | `d` | 删除文件或目录。 |
| **Create** | `c` | 创建文件或目录。 |
| **Modify Ownership** | `o` | 更改所有者用户或组。 |
| **Modify Permissions** | `p` | 更改文件或目录上的 ACLs。 |
## Enumeration
@@ -442,35 +442,36 @@ New-AzStorageBlobSASToken `
{{#endtab }}
{{#endtabs }}
### 文件共享
### File Shares
{{#ref}}
az-file-shares.md
{{#endref}}
## 权限提升
## Privilege Escalation
{{#ref}}
../az-privilege-escalation/az-storage-privesc.md
{{#endref}}
## 后渗透
## Post Exploitation
{{#ref}}
../az-post-exploitation/az-blob-storage-post-exploitation.md
{{#endref}}
## 持久化
## Persistence
{{#ref}}
../az-persistence/az-storage-persistence.md
{{#endref}}
## 参考资料
## 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.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)