跳转到正文
报告库
用途分类 / 其他用途

Entra App Registration Skill 安全审计

作者说它能做什么(原文)

Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure re

第三方安全检查结论

先别安装或运行

已检查文件
17
发现的风险
6
会不会运行危险命令?检查是否下载程序后直接运行、让他人远程控制电脑,或藏起要运行的命令。未发现风险
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。发现 1 项风险
中风险

故障排查步骤要求把有效访问令牌粘贴到网页

原文依据:2 处
发现了什么

指南要求复制访问令牌并粘贴到 `jwt.ms`。访问令牌是 Bearer 凭据;把完整令牌交给网页会让该页面及其运行环境接触令牌内容。仅声明该网站“安全”不能消除此数据暴露面。

为什么需要注意

若域名、浏览器扩展、代理、日志或当前会话被入侵,令牌可能在到期前被重放,并按其 `scp` 或 `roles` 权限访问数据。

故障排查文档主动要求复制完整访问令牌并粘贴到外部网页。即使页面属于所述服务且用于解码,浏览器页面及其脚本仍会接触这一 Bearer 凭据;若令牌尚有效,泄露可能允许按其权限调用 API。用户可要求作者提供本地离线解码方法,或至少使用短期、低权限、非生产令牌并在之后撤销会话。

references/troubleshooting.md:175来自说明文档打开原文件
## Token IssuesUnless the the access token is encrypted, you can decode and view its claims securely at https://jwt.ms. **Don't** use any other website to decode an access token. Compare the claims in the token with the app registration's configuration to identify issues.
查看另外 1 个位置
references/troubleshooting.md:181来自说明文档打开原文件
### JWT Token Decoder**Tool:** https://jwt.ms**How to use:**1. Copy your access token2. Paste into jwt.ms3. Review claims:   - `aud` - Audience (should match your API)   - `iss` - Issuer (should be login.microsoftonline.com)   - `scp` - Delegated permissions   - `roles` - Application permissions   - `exp` - Expiration timestamp   - `oid` - User object ID
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。发现 2 项风险
高风险

生成新客户端密钥的命令会删除现有凭据并可能中断服务

原文依据:2 处
发现了什么

指南使用 `az ad app credential reset` 创建密钥,并明确说明重置会删除所有现有凭据。其他应用实例或部署可能仍依赖这些密钥或证书。

为什么需要注意

执行后,依赖旧凭据的生产服务、自动化任务或集成可能立即无法认证;若没有保留恢复方式,还可能造成较长时间中断。

该指南把 `credential reset` 作为创建密钥的方法,并明确警告重置会删除所有现有凭据。若用户对已有生产应用运行任一示例,依赖旧密钥或证书的服务可能立即无法认证。警告降低了误用概率,但没有避免破坏性行为;用户应先盘点依赖,并要求作者提供保留现有凭据的轮换流程。

references/cli-commands.md:134来自说明文档打开原文件
### Create client secret```bash# Create secret with default expirationaz ad app credential reset --id $APP_ID# Create secret with custom expirationaz ad app credential reset --id $APP_ID --years 1# Create secret with specific end dateaz ad app credential reset --id $APP_ID --end-date "2025-12-31"```**Save the output:**```json{  "appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",  "password": "your-secret-value-SAVE-THIS",  "tenant": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}```**⚠️ Important:** Resetting Client credential will delete all existing credentials.**⚠️ Important:** The secret value is only shown once. Store it securely (e.g., Azure Key Vault).
查看另外 1 个位置
references/cli-commands.md:156来自说明文档打开原文件
**⚠️ Important:** Resetting Client credential will delete all existing credentials.**⚠️ Important:** The secret value is only shown once. Store it securely (e.g., Azure Key Vault).
高风险

清理脚本无逐项确认地批量删除匹配的 Entra 应用

原文依据:1 处
发现了什么

脚本取得显示名称匹配 `Test*` 的所有应用 ID,并把每个 ID直接传给 `az ad app delete`,没有显示租户、所有者、依赖关系或逐项确认。

为什么需要注意

名称相似但仍在使用的应用注册及其关联服务主体可能被删除,导致登录、API 权限和服务集成失效。

这是明确标为清理用途的示例,因此删除行为与该小节目的相符;但运行后会枚举所有匹配 `Test*` 的应用并直接逐个删除,没有租户、所有者或逐项确认检查。显示名模式可能意外匹配仍在使用的应用。用户应仅在确认租户和完整候选列表后使用,并要求作者加入预览和显式确认。

references/cli-commands.md:399来自说明文档打开原文件
### Cleanup script```bash#!/bin/bash# Delete all apps matching patternaz ad app list --display-name "Test*" --query "[].appId" -o tsv | while read APP_ID; do  echo "Deleting app: $APP_ID"  az ad app delete --id $APP_IDdone```
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。发现 3 项风险
高风险

Bicep 模板默认注册并非由用户确认控制的重定向地址

原文依据:2 处
发现了什么

模板把 `myapp.azurewebsites.net` 的回调和 SPA 地址设为默认值。OAuth 响应会发送到已注册的重定向 URI;模板没有要求部署前证明用户控制该主机。

为什么需要注意

若用户原样部署且该主机由他人控制或后来被接管,授权码或令牌可能被发送给该主机,从而危及登录会话和获准访问的数据。

若用户不修改默认参数就部署此 IaC,模板会把示例域名同时注册为 Web 和 SPA 重定向地址,并实际传给应用资源。若该域名不受用户控制,认证响应可能被发送到第三方主机。用户应要求作者使用无默认值的必填参数,并在部署前确认每个生产 URI 的所有权。

references/BICEP-EXAMPLE.bicep:18来自说明文档打开原文件
@description('Redirect URIs for web application')param webRedirectUris array = [  'https://localhost:5001/signin-oidc'  'https://myapp.azurewebsites.net/signin-oidc']@description('Redirect URIs for single-page application')param spaRedirectUris array = [  'http://localhost:3000'  'https://myapp.azurewebsites.net']
查看另外 1 个位置
references/BICEP-EXAMPLE.bicep:48来自说明文档打开原文件
  // Web application settings  web: {    redirectUris: webRedirectUris    implicitGrantSettings: {      enableIdTokenIssuance: true      enableAccessTokenIssuance: false    }    homePageUrl: 'https://myapp.azurewebsites.net'    logoutUrl: 'https://myapp.azurewebsites.net/signout-oidc'  }  // Single-page application settings  spa: {    redirectUris: spaRedirectUris  }
高风险

模板预配租户级用户读取权限,且指南提供一次性批准全部权限的命令

原文依据:4 处
发现了什么

Bicep 默认请求 `User.Read.All` 应用权限,并同时请求邮件和用户目录相关委托权限。另一段指南建议运行“为所有权限授予管理员同意”的命令。应用权限不需要用户在场,并始终需要管理员同意。

为什么需要注意

管理员若部署模板并执行该同意命令,服务主体可在无人登录的情况下读取租户内所有用户的完整资料;用户同意登录还可能让应用读取邮件。权限范围超过多数基础登录应用所需。

模板默认请求 Mail.Read 等委托权限及可在无用户上下文下读取全租户用户资料的 User.Read.All 应用权限;指南另给出批准该应用全部已配置权限的管理员同意命令。若管理员按示例部署并执行该命令,应用将获得超出简单登录所需的访问。用户应要求逐项说明权限用途,只批准必需权限,并从通用模板中移除高权限默认项。

references/BICEP-EXAMPLE.bicep:121来自说明文档打开原文件
  // Required API permissions (Microsoft Graph)  requiredResourceAccess: [    {      // Microsoft Graph API      resourceAppId: '00000003-0000-0000-c000-000000000000'      resourceAccess: [        {          // User.Read - Delegated          id: 'e1fe6dd8-ba31-4d61-89e7-88639da4683d'          type: 'Scope'        }        {          // User.ReadBasic.All - Delegated          id: 'b340eb25-3456-403f-be2f-af7a0d370277'          type: 'Scope'        }        {          // Mail.Read - Delegated          id: '570282fd-fa5c-430d-a7fd-fc8dc98a9dca'          type: 'Scope'        }        {          // User.Read.All - Application          id: 'df021288-bdef-4463-88db-98f22de89214'          type: 'Role'        }      ]    }  ]
查看另外 3 个位置
references/api-permissions.md:89来自说明文档打开原文件
### Common Application Permissions| Permission | What it allows | Admin Consent Required ||------------|---------------|----------------------|| `User.Read.All` | Read all users' full profiles | Yes (Always) || `User.ReadWrite.All` | Read and write all users' profiles | Yes (Always) || `Mail.Read` | Read mail in all mailboxes | Yes (Always) || `Mail.Send` | Send mail as any user | Yes (Always) || `Calendars.Read` | Read calendars in all mailboxes | Yes (Always) || `Directory.Read.All` | Read directory data | Yes (Always) || `Directory.ReadWrite.All` | Read and write directory data | Yes (Always) || `Group.ReadWrite.All` | Read and write all groups | Yes (Always) |
references/cli-commands.md:231来自说明文档打开原文件
### Grant admin consent```bash# Grant admin consent for all permissionsaz ad app permission admin-consent --id $APP_ID```**Note:** Admin consent is required for application permissions and some delegated permissions.
references/api-permissions.md:23来自说明文档打开原文件
### Application Permissions (App Context)**What:** Application acts with its own identity (no user)**When to use:**- Background services, daemons- Scheduled jobs- API-to-API calls without user**Examples:**- Read all users in organization- Send mail as any user- Access all SharePoint sites**Requirement:** Always requires admin consent
中风险

控制台应用指引同时启用设备代码流和密码流

原文依据:1 处
发现了什么

指南说明“允许公共客户端流”会启用设备代码流和资源所有者密码流,却对所有控制台应用建议打开。启用设备代码并不等于必须同时允许应用直接处理用户密码。

为什么需要注意

如果应用后来实现或被诱导使用资源所有者密码流,用户密码会进入客户端处理路径;该流程与 MFA、条件访问和现代无密码登录能力不兼容或受限,扩大凭据泄露面。

指南明确说明同一设置会启用设备代码流和资源所有者密码流,却对控制台应用一概建议开启。若应用只需要设备代码或交互式登录,这会额外允许直接处理用户密码的旧式流程,扩大凭据暴露和误用面。用户应要求作者按实际 OAuth 流程决定设置,并确认不需要时禁用资源所有者密码流。

references/first-app-registration.md:95来自说明文档打开原文件
### Advanced Settings**Allow public client flows:**- **What it is:** Enables device code flow, resource owner password flow- **For console apps:** Turn this **ON**- **For web apps:** Keep **OFF**
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

8 个说明模块

该 Skill 是面向 Entra 应用注册的操作指南;它提供门户步骤、Azure CLI 命令和 Bicep 模板。执行这些内容会在当前登录的 Azure 租户中创建或修改应用、权限、凭据和服务主体,而不是只生成本地示例。

查看原文
SKILL.md:37来自说明文档打开原文件
### Step 1: Register the ApplicationCreate an app registration in the Azure portal or using Azure CLI.**Portal Method:**1. Navigate to Azure Portal → Microsoft Entra ID → App registrations2. Click "New registration"3. Provide name, supported account types, and redirect URI4. Click "Register"**CLI Method:** See [references/cli-commands.md](references/cli-commands.md)**IaC Method:** See [references/BICEP-EXAMPLE.bicep](references/BICEP-EXAMPLE.bicep)
references/cli-commands.md:257来自说明文档打开原文件
### Create service principal```bash# Create service principal for the appaz ad sp create --id $APP_ID```

示例应用使用 MSAL 获取令牌,然后把 Bearer 令牌发送到 Microsoft Graph 的 `/me` 接口并打印用户资料。此网络访问与身份验证示例的声明用途一致。

查看原文
references/console-app-example.md:190来自说明文档打开原文件
def call_graph_api(access_token):    """Call Microsoft Graph API with access token"""    headers = {        'Authorization': f'Bearer {access_token}',        'Content-Type': 'application/json'    }        response = requests.get(        'https://graph.microsoft.com/v1.0/me',        headers=headers    )        if response.status_code == 200:        user_data = response.json()        print("\nUser profile from Microsoft Graph:")        print(json.dumps(user_data, indent=2))    else:

文档明确建议最小权限、避免硬编码密钥,并在生产环境优先使用托管身份。这些是指导性保护措施,不会自动限制后续 CLI 或模板的实际权限。

查看原文
SKILL.md:161来自说明文档打开原文件
|----------|---------------|| **Never hardcode secrets** | Use environment variables, Azure Key Vault, or managed identity || **Rotate secrets regularly** | Set expiration, automate rotation || **Use certificates over secrets** | More secure for production || **Least privilege permissions** | Request only required API permissions || **Enable MFA** | Require multi-factor authentication for users || **Use managed identity** | For Azure-hosted apps, avoid secrets entirely || **Validate tokens** | Always validate issuer, audience, expiration || **Use HTTPS only** | All redirect URIs must use HTTPS (except localhost) || **Monitor sign-ins** | Use Entra ID sign-in logs for anomaly detection |
从这里开始 · 工作说明SKILL.md
entra-app-registration
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。

文件引用关系图

26 处引用
哪些文件发起引用引用了什么
连线表示真实的文件引用,不是运行顺序。点击节点可高亮相关连线,并查看具体文件和原文位置。虚线表示还有文件需要定位。
文件与检查记录17 个文件

检查范围与遗漏

逐文件查看涉及的内容

下方列出本次涉及的原文范围;纳入检查不代表已查清所有问题。

  • SKILL.md已纳入全文
  • references/api-permissions.md已纳入全文
  • references/BICEP-EXAMPLE.bicep已纳入全文
  • references/cli-commands.md已纳入全文
  • references/console-app-example.md已纳入全文
  • references/first-app-registration.md已纳入全文
  • references/oauth-flows.md已纳入全文
  • references/sdk/azure-identity-dotnet.md已纳入全文
  • references/sdk/azure-identity-java.md已纳入全文
  • references/sdk/azure-identity-py.md已纳入全文
  • references/sdk/azure-identity-rust.md已纳入全文
  • references/sdk/azure-identity-ts.md已纳入全文
  • references/sdk/azure-keyvault-py.md已纳入全文
  • references/sdk/azure-keyvault-secrets-ts.md已纳入全文
  • references/sdk/microsoft-azure-webjobs-extensions-authentication-events-dotnet.md已纳入全文
  • references/troubleshooting.md已纳入全文
  • references/auth-best-practices.md已纳入全文

这份报告只针对上方版本。我们看了拿到的代码和说明文件,没有实际运行 Skill,也没有检查它另外安装的软件包。因此,这不是“保证安全”的承诺;换了版本或使用环境,结果也可能不同。

  • SKILL.md工作说明
  • references/BICEP-EXAMPLE.bicep配套文件
  • references/api-permissions.md配套文件
  • references/auth-best-practices.md配套文件
  • references/cli-commands.md配套文件
  • references/console-app-example.md配套文件
  • references/first-app-registration.md配套文件
  • references/oauth-flows.md配套文件
  • references/sdk/azure-identity-dotnet.md配套文件
  • references/sdk/azure-identity-java.md配套文件
  • references/sdk/azure-identity-py.md配套文件
  • references/sdk/azure-identity-rust.md配套文件
  • references/sdk/azure-identity-ts.md配套文件
  • references/sdk/azure-keyvault-py.md配套文件
  • references/sdk/azure-keyvault-secrets-ts.md配套文件
  • references/sdk/microsoft-azure-webjobs-extensions-authentication-events-dotnet.md配套文件
  • references/troubleshooting.md配套文件

代码和说明中提到的操作

连接外部网站
SKILL.md:58来自说明文档打开原文件
- **SPAs**: Add redirect URIs, enable implicit grant flow if necessary- **Mobile/Desktop**: Use `http://localhost` or custom URI scheme- **Services**: No redirect URI needed for client credentials flow
SKILL.md:188来自说明文档打开原文件
- [Microsoft Identity Platform Documentation](https://learn.microsoft.com/entra/identity-platform/)- [OAuth 2.0 and OpenID Connect protocols](https://learn.microsoft.com/entra/identity-platform/v2-protocols)
SKILL.md:189来自说明文档打开原文件
- [Microsoft Identity Platform Documentation](https://learn.microsoft.com/entra/identity-platform/)- [OAuth 2.0 and OpenID Connect protocols](https://learn.microsoft.com/entra/identity-platform/v2-protocols)- [MSAL Documentation](https://learn.microsoft.com/entra/msal/)
读取密钥或账号配置
SKILL.md:59来自说明文档打开原文件
- **Mobile/Desktop**: Use `http://localhost` or custom URI scheme- **Services**: No redirect URI needed for client credentials flow
SKILL.md:73来自说明文档打开原文件
### Step 4: Create Client Credentials (if needed)
SKILL.md:129来自说明文档打开原文件
**Implementation:** Use Client Credentials flow (see [references/oauth-flows.md#client-credentials-flow](references/oauth-flows.md#client-credentials-flow))
读取文件
SKILL.md:66来自说明文档打开原文件
**Common Microsoft Graph Permissions:**- `User.Read` - Read user profile- `User.ReadWrite.All` - Read and write all users
references/api-permissions.md:84来自说明文档打开原文件
| `Calendars.ReadWrite` | Read and write calendars | No || `Files.Read.All` | Read all files user can access | No || `Sites.Read.All` | Read items in all site collections | Yes |
references/api-permissions.md:216来自说明文档打开原文件
- User can: Only read their own profile- App granted: User.Read.All
运行命令
references/api-permissions.md:144来自说明文档打开原文件
```bash# List all Graph permissions (warning: long output)
references/api-permissions.md:174来自说明文档打开原文件
**CLI Method:**```bashaz ad app permission admin-consent --id $APP_ID
references/api-permissions.md:183来自说明文档打开原文件
**CLI:**```bashaz ad app permission list --id $APP_ID
安装其他软件包
references/console-app-example.md:128来自说明文档打开原文件
```bashpip install msal requests```
references/console-app-example.md:257来自说明文档打开原文件
npm init -ynpm install @azure/msal-node axios```
references/sdk/azure-identity-py.md:9来自说明文档打开原文件
```bashpip install azure-identity```
读取了多少行
2,795
文件校验值(用于核对版本)
891b19139d694dbbac241cf088d08f4d10ae6e5dbe86f4d9fff41db39fe39190