Az - AI Foundry, AI Hubs, Azure OpenAI & AI Search
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
为什么这些服务重要
Azure AI Foundry 是用于构建 GenAI 应用的总体平台。hub 会聚合 AI projects、Azure ML workspaces、compute、data stores、registries、prompt flow 资产,以及与下游服务(例如 Azure OpenAI 和 Azure AI Search)的连接。每个组件通常会暴露:
- 长期有效的 API keys (OpenAI, Search, data connectors),这些 keys 常常会被复制到 Azure Key Vault 或 workspace connection 对象中。
- Managed Identities (MI),用于控制部署、vector indexing 作业、model evaluation pipelines,以及 Git/GitHub Enterprise 操作。
- 跨服务链接(storage accounts、container registries、Application Insights、Log Analytics),这些链接继承 hub/project 的权限。
- 多租户连接器(Hugging Face、Azure Data Lake、Event Hubs),可能会 leak 上游凭据或 tokens。
因此,单个 hub/project 的妥协可能意味着对下游 managed identities、compute clusters、online endpoints,以及任何被 prompt flows 引用的 search indexes 或 OpenAI 部署的控制权。
核心组件与安全面
- AI Hub (
Microsoft.MachineLearningServices/hubs):顶层对象,定义 region、managed network、system datastores、默认 Key Vault、Container Registry、Log Analytics,以及 hub 级别的 identities。被攻破的 hub 允许攻击者注入新的 projects、registries 或 user-assigned identities。 - AI Projects (
Microsoft.MachineLearningServices/workspaces):托管 prompt flows、data assets、environments、component pipelines,以及 online/batch endpoints。Projects 继承 hub 资源,也可以用自己的 storage、kv 和 MI 覆盖。每个 workspace 在/connections和/datastores下存储 secrets。 - Managed Compute & Endpoints:包括 managed online endpoints、batch endpoints、serverless endpoints、AKS/ACI 部署,以及按需推理服务器。运行时内从 Azure Instance Metadata Service (IMDS) 获取的 tokens 通常带有 workspace/project 的 MI 角色分配(常见为
Contributor或Owner)。 - AI Registries & Model Catalog:允许按 region 共享 models、environments、components、data 和 evaluation 结果。Registries 可以自动同步到 GitHub/Azure DevOps,意味着 PATs 可能被嵌入在连接定义中。
- Azure OpenAI (
Microsoft.CognitiveServices/accountswithkind=OpenAI):提供 GPT 系列模型。访问受角色分配 + admin/query keys 控制。许多 Foundry prompt flows 会将生成的 keys 作为 secrets 或环境变量保留,compute jobs 可以访问它们。 - Azure AI Search (
Microsoft.Search/searchServices):向量/索引存储通常通过 project connection 连接,其 admin key 存储在连接中。索引数据可能包含敏感的 embeddings、检索到的文档或原始训练语料。
与安全相关的架构
Managed Identities & Role Assignments
- AI hubs/projects 可以启用 system-assigned 或 user-assigned identities。这些 identities 通常在 storage accounts、key vaults、container registries、Azure OpenAI 资源、Azure AI Search 服务、Event Hubs、Cosmos DB 或自定义 API 上具有角色。
- Online endpoints 继承 project MI,或者可以为每次部署使用专用的 user-assigned MI。
- Prompt Flow connections 和 Automated Agents 可以通过
DefaultAzureCredential请求 tokens;从 compute 捕获 metadata endpoint 能得到用于横向移动的 tokens。
网络边界
- Hubs/projects 支持
publicNetworkAccess、private endpoints、Managed VNet 和 **managedOutbound** 规则。错误配置的allowInternetOutbound` 或开放的 scoring endpoints 允许直接外传数据。 - Azure OpenAI 和 AI Search 支持 firewall rules、Private Endpoint Connections (PEC)、shared private link resources 和
trustedClientCertificates。当启用 public access 时,这些服务接受任何知道 key 的源 IP 的请求。
数据与 secret 存储
- 默认的 hub/project 部署会在隐藏的 managed resource group 中创建 storage account、Azure Container Registry、Key Vault、Application Insights 和 Log Analytics(模式:
mlw-<workspace>-rg)。 - Workspace datastores 引用 blob/data lake 容器,可能会嵌入 SAS tokens、service principal secrets 或 storage access keys。
- Workspace connections(用于 Azure OpenAI、AI Search、Cognitive Services、Git、Hugging Face 等)会将凭据保存在 workspace Key Vault 中,并在管理平面列出 connection 时公开这些凭据(值为 base64 编码的 JSON)。
- AI Search admin keys 提供对 indexes、skillsets、data sources 的完全读/写访问,并可检索用于 RAG 系统的文档。
监控与供应链
- AI Foundry 支持与 GitHub/Azure DevOps 的代码和 prompt flow 资产集成。OAuth tokens 或 PATs 存放在 Key Vault + connection metadata 中。
- Model Catalog 可能会镜像 Hugging Face 的 artifacts。如果
trust_remote_code=true,在部署期间会执行任意 Python 代码。 - Data/feature pipelines 会记录到 Application Insights 或 Log Analytics,暴露 connection strings。
使用 az 进行枚举
# Install the Azure ML / AI CLI extension (if missing)
az extension add --name ml
# Enumerate AI Hubs (workspaces with kind=hub) and inspect properties
az ml workspace list --filtered-kinds hub --resource-group <RG> --query "[].{name:name, location:location, rg:resourceGroup}" -o table
az resource show --name <HUB> --resource-group <RG> \
--resource-type Microsoft.MachineLearningServices/workspaces \
--query "{location:location, publicNetworkAccess:properties.publicNetworkAccess, identity:identity, managedResourceGroup:properties.managedResourceGroup}" -o jsonc
# Enumerate AI Projects (kind=project) under a hub or RG
az resource list --resource-type Microsoft.MachineLearningServices/workspaces --query "[].{name:name, rg:resourceGroup, location:location}" -o table
az ml workspace list --filtered-kinds project --resource-group <RG> \
--query "[?contains(properties.hubArmId, '/workspaces/<HUB>')].{name:name, rg:resourceGroup, location:location}"
# Show workspace level settings (managed identity, storage, key vault, container registry)
az ml workspace show --name <WS> --resource-group <RG> \
--query "{managedNetwork:properties.managedNetwork, storageAccount:properties.storageAccount, containerRegistry:properties.containerRegistry, keyVault:properties.keyVault, identity:identity}"
# List workspace connections (OpenAI, AI Search, Git, data sources)
az ml connection list --workspace-name <WS> --resource-group <RG> --populate-secrets -o table
az ml connection show --workspace-name <WS> --resource-group <RG> --name <CONNECTION>
# For REST (returns base64 encoded secrets)
az rest --method GET \
--url "https://management.azure.com/subscriptions/<SUB>/resourceGroups/<RG>/providers/Microsoft.MachineLearningServices/workspaces/<WS>/connections/<CONN>?api-version=2024-04-01"
# Enumerate datastores and extract credentials/SAS
az ml datastore list --workspace-name <WS> --resource-group <RG>
az ml datastore show --name <DATASTORE> --workspace-name <WS> --resource-group <RG>
# List managed online/batch endpoints and deployments (capture identity per deployment)
az ml online-endpoint list --workspace-name <WS> --resource-group <RG>
az ml online-endpoint show --name <ENDPOINT> --workspace-name <WS> --resource-group <RG>
az ml online-deployment show --name <DEPLOYMENT> --endpoint-name <ENDPOINT> --workspace-name <WS> --resource-group <RG> \
--query "{identity:identity, environment:properties.environmentId, codeConfiguration:properties.codeConfiguration}"
# Discover prompt flows, components, environments, data assets
az ml component list --workspace-name <WS> --resource-group <RG>
az ml data list --workspace-name <WS> --resource-group <RG> --type uri_folder
az ml environment list --workspace-name <WS> --resource-group <RG>
az ml job list --workspace-name <WS> --resource-group <RG> --type pipeline
# List hub/project managed identities and their role assignments
az identity list --resource-group <RG>
az role assignment list --assignee <MI-PRINCIPAL-ID> --all
# Azure OpenAI resources (filter kind==OpenAI)
az resource list --resource-type Microsoft.CognitiveServices/accounts \
--query "[?kind=='OpenAI'].{name:name, rg:resourceGroup, location:location}" -o table
az cognitiveservices account list --resource-group <RG> \
--query "[?kind=='OpenAI'].{name:name, location:location}" -o table
az cognitiveservices account show --name <AOAI-NAME> --resource-group <RG>
az cognitiveservices account keys list --name <AOAI-NAME> --resource-group <RG>
az cognitiveservices account deployment list --name <AOAI-NAME> --resource-group <RG>
az cognitiveservices account network-rule list --name <AOAI-NAME> --resource-group <RG>
# Azure AI Search services
az search service list --resource-group <RG>
az search service show --name <SEARCH-NAME> --resource-group <RG> \
--query "{sku:sku.name, publicNetworkAccess:properties.publicNetworkAccess, privateEndpoints:properties.privateEndpointConnections}"
az search admin-key show --service-name <SEARCH-NAME> --resource-group <RG>
az search query-key list --service-name <SEARCH-NAME> --resource-group <RG>
az search shared-private-link-resource list --service-name <SEARCH-NAME> --resource-group <RG>
# AI Search data-plane (requires admin key in header)
az rest --method GET \
--url "https://<SEARCH-NAME>.search.windows.net/indexes?api-version=2024-07-01" \
--headers "api-key=<ADMIN-KEY>"
az rest --method GET \
--url "https://<SEARCH-NAME>.search.windows.net/datasources?api-version=2024-07-01" \
--headers "api-key=<ADMIN-KEY>"
az rest --method GET \
--url "https://<SEARCH-NAME>.search.windows.net/indexers?api-version=2024-07-01" \
--headers "api-key=<ADMIN-KEY>"
# Linkage between workspaces and search / openAI (REST helper)
az rest --method GET \
--url "https://management.azure.com/subscriptions/<SUB>/resourceGroups/<RG>/providers/Microsoft.MachineLearningServices/workspaces/<WS>/connections?api-version=2024-04-01" \
--query "value[?properties.target=='AzureAiSearch' || properties.target=='AzureOpenAI']"
评估期间应注意什么
- Identity scope: 项目经常复用一个强大的 user-assigned identity,并附加到多个服务。捕获任何 managed compute 的 IMDS tokens 会继承这些权限。
- Connection objects: Base64 payload 包含 secret 以及元数据(endpoint URL,API version)。许多团队把 OpenAI + Search admin keys 留在这里,而不是频繁轮换。
- Git & external source connectors: PATs 或 OAuth refresh tokens 可能允许对定义 pipelines/prompt flows 的代码进行 push 访问。
- Datastores & data assets: 会提供有效期数月的 SAS tokens;data assets 可能指向客户 PII、embeddings 或训练语料。
- Managed Network overrides:
allowInternetOutbound=true或publicNetworkAccess=Enabled会使从 jobs/endpoints exfiltrate secrets 变得非常容易。 - Hub-managed resource group: 包含 storage account (
<workspace>storage)、container registry、KV 和 Log Analytics。访问该 RG 通常意味着完全接管,即使 portal 隐藏了它。
References
- Azure AI Foundry architecture
- Azure Machine Learning CLI v2
- Azure OpenAI security controls
- Azure AI Search security
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
HackTricks Cloud

