JohannesLks/CVE-2026-50338
GitHub: JohannesLks/CVE-2026-50338
针对 Spring Cloud Azure B2C Resource Server 跨签发者身份验证绕过漏洞(CVE-2026-50338)的 Python 概念证明工具,用于验证受影响版本接受伪造 AAD token 的安全缺陷。
Stars: 0 | Forks: 0
# CVE-2026-50338
Spring Cloud Azure B2C Resource Server 跨签发者身份验证绕过
## 描述
`spring-cloud-azure-autoconfigure` 中的 `AadB2cResourceServerAutoConfiguration`
构建了一个信任六个 AAD 系列签发者
(`login.microsoftonline.com`、`sts.windows.net`、`sts.chinacloudapi.cn`,以及各自的 v1 和
v2)的 `JwtDecoder`,这些签发者是通过
`AadB2cTrustedIssuerRepository.java:30` 从 `AadTrustedIssuerRepository` 继承的。它没有安装 `tid` 声明验证器,
并且 `aud` 断言使用了 `containsAll`(对于空的 audience 会空洞为真)。
在同一租户中拥有 AAD 应用注册的攻击者可以生成一个
`client_credentials` token,其 `iss` 为 `https://sts.windows.net//`
并且其 `aud` 与 B2C 应用的 client-id 匹配。B2C resource server
会接受它,因为 AAD 签发者在其受信任集合中,并且没有进一步的声明
验证会拒绝这种跨身份验证系统的 token。
这是 CVE-2026-33117(AAD resource server)的 B2C 孪生漏洞。PR #49033 修复了
AAD 路径;而 B2C 路径直到 PR #49252(于 2026-06-02 合并,
在 2026 年 7 月安全更新中发布)之前都未被触及。
如果设置 `tenant-id=common`,任何 Entra 租户的 token 都会被接受。
受影响版本:`spring-cloud-azure-starter-active-directory-b2c` <= 5.19.0。
在 2026 年 7 月安全更新中已修复
([PR #49252](https://github.com/Azure/azure-sdk-for-java/pull/49252))。
## 用法
```
pip install msal requests
# 针对存在漏洞的 Spring Boot B2C resource server:
python3 poc.py \
--target http://localhost:8080/profile \
--tenant-id \
--client-id \
--client-secret \
--victim-api
# 不使用 MSAL(原始 HTTP token 请求):
python3 poc.py \
--target http://localhost:8080/profile \
--tenant-id \
--client-id \
--client-secret \
--victim-api \
--no-msal
# 详细输出(完整 token claims 和响应):
python3 poc.py ... -v
```
攻击者的应用注册需要:
- 一个 client secret
- 对受影响的 B2C 应用的 client-id(或其下的某个 scope)具有 API 权限
## 要求
- Python 3.8+,`msal`,`requests`
- 一个包含应用注册的 Entra ID 租户(攻击者角色)
- 一个使用 `spring-cloud-azure-starter-active-directory-b2c`
<= 5.19.0 的 Spring Boot 应用作为目标
## 文件
| 文件 | 描述 |
|------|-------------|
| `poc.py` | Python PoC:生成 AAD token,发送到 B2C endpoint,报告绕过情况 |
| `README.md` | 漏洞详情与用法 |
| `LICENSE` | GPLv3 许可证 |
## 参考
- https://msrc.microsoft.com/update-guide/vulnerability/CVE-2026-50338
- https://msrc.microsoft.com/update-guide/vulnerability/CVE-2026-33117
- https://johannes-moeller.dev/blog/cve-2026-50338-spring-cloud-azure-b2c-cross-issuer
- https://github.com/Azure/azure-sdk-for-java/pull/49252
- https://github.com/Azure/azure-sdk-for-java/pull/49033
## 法律声明
本项目基于 GNU GPLv3 发布。
它仅用于防御性安全研究、教育和授权
测试。未经所有者明确许可,请勿将此代码用于
系统或服务。
未经授权的使用可能违反适用法律。作者不授权
测试第三方系统,也不对滥用行为负责。
有关保修和责任条款,请参阅 LICENSE 文件。
标签:Azure AD, GHAS, Java安全, Modbus, PoC, Spring Cloud, 暴力破解, 认证绕过, 逆向工具